eslint-config-silent
v0.30.0
Published
Silence all rules that you don't have to care about.
Downloads
389
Maintainers
Readme
eslint-config-silent
ESLint is annoying sometimes, but if a rule is:
- Fully automatic fixable.
- Automatic fix is reliable.
- Against the rule won't cause runtime error.
Then why you have to care about it? Just let ESLint do the job, you don't need be bothered.
Installation
You can install it via yarn or npm.
$ yarn add eslint-config-silent --dev
$ npm install eslint-config-silent --save-dev
Usage
This config only turns rules off, but you don't want to keep them off all the time, so you should use a environment variable to control it.
.eslintrc.js
'use strict';
const config = {
root: true,
extends: 'some-other-config-you-use',
};
if (process.env.NODE_ENV !== 'production') {
config.extends = [config.extends, 'silent'];
}
module.exports = config;
And you need a chance to let ESLint fix them, lint-staged is a great tool that allows you to do that.
package.json
{
"lint-staged": {
"*.js": ["cross-env NODE_ENV=production eslint --fix", "git add"]
}
}
And that's it, enjoy your silent ESLint (cross-env is a tool that set environment variables across platforms).
A few ESLint plugins are supported as well:
- @babel/eslint-plugin
- @typescript-eslint/eslint-plugin
- eslint-plugin-ava
- eslint-plugin-flowtype
- eslint-plugin-import
- eslint-plugin-prettier
- eslint-plugin-react
- eslint-plugin-unicorn
- eslint-plugin-vue
Add extra exclusions for the plugins you use like so:
.eslintrc.js
'use strict';
const config = {
root: true,
extends: 'some-other-config-you-use',
};
if (process.env.NODE_ENV !== 'production') {
config.extends = [
config.extends,
'silent',
'silent/@babel',
'silent/@typescript-eslint',
'silent/ava',
'silent/flowtype',
'silent/import',
'silent/prettier',
'silent/react',
'silent/unicorn',
'silent/vue',
];
}
module.exports = config;
If you extend a config which uses a plugin, it is recommended to add 'silent/that-plugin'
(if available). For example, eslint-config-airbnb enables eslint-plugin-react rules, so 'silent/react'
is recommended:
.eslintrc.js
'use strict';
const config = {
root: true,
extends: 'airbnb',
};
if (process.env.NODE_ENV !== 'production') {
config.extends = [config.extends, 'silent', 'silent/react'];
}
module.exports = config;
If you’re unsure which plugins are used, you can usually find them in your package.json
.
FAQ
What if someone uses git commit --no-verify
?
You can set a CI job to lint your code (without --fix
parameter), so if some code is not fixed, you will know. Like this repo.
How can I override my custom rules?
You can write .eslintrc.js
like this:
'use strict';
const silent = require('eslint-config-silent');
const config = {
root: true,
extends: 'some-other-config-you-use',
rules: {
'your-custom-rule': 'error',
},
};
if (process.env.NODE_ENV !== 'production') {
config.rules = [...config.rules, ...silent.rules];
}
module.exports = config;
Contributing
If you find a rule should or shouldn't be included in this config, please open a issue.
Credits
This config is inspired by eslint-config-prettier.