no-console: [2, { allow: ["warn", "error"] }]
An eslint plugin to warn on usage of console.log
.
Table of Contents generated with DocToc
npm i -S eslint-plugin-no-console-log
Add plugins
section and specify eslint-plugin-no-console-log as a plugin.
{
"plugins": [
"no-console-log"
]
}
Then, enable the rule.
{
"rules": {
"no-console-log/no-console-log": 1
}
}
This rule warns when it sees console.log
only. Other variants, like console.warn
are allowed, as it's assumed you've left them there on purpose. If you'd like to disable all console methods use the built-in rule no-console
.
The following patterns are considered warnings:
console.log('hi')
The following patterns are not warnings:
console.time('timer')
console.timeEnd('timer')
console.warn('oops')
console.error('kittens!')
If you want to disable all console
use to enforce a custom logging option.
Tests are in eslint's RuleTester.
npm test
will run the testsnpm run tdd
will run the tests on every file change.
To publish, run npm run release -- [{patch,minor,major}]
NOTE: you might need to sudo ln -s /usr/local/bin/node /usr/bin/node
to ensure node is in your path for the git hooks to work
- npm > 2.0.0 So that passing args to a npm script will work.
npm i -g npm
- git > 1.8.3 So that
git push --follow-tags
will work.brew install git
Artistic 2.0 © Joey Baker and contributors. A copy of the license can be found in the file LICENSE
.