⚠ Deprecation Notice ⚠ |
---|
Due to a shift in focus and plans for additional features out of scope for a package like this, there is now a successor, in spirit and in code:
👉 @professional-js/eslint-config
(GitHub)
That package has the exact same feature set at the time of writing but will be maintained and extended.
Work on eslint-config-rasenplanscher ceases immediately and completely.
Please make sure to switch.
|
eslint-config-rasenplanscher
This package provides a reasoned reactive shareable ESLint configuration in several variations.
What does that mean?
“reasoned”
The settings in this configuration are not generally built on gut feelings but on reasoning regarding how code formatting can improve productivity. All of that is documented in the project itself, so if you want to know why a rule is configured as it is, look at the markdown files you can find in the Github repository.
If you disagree with something rationally, please open an issue to help me correct my thinking. If you disagree based on a gut feeling, please keep it to yourself until you either understand the truth found here or you can make a rational argument.
Also, if you'd like a setting that's missing here, just open a PR and it shall be included if the reasoning is up to snuff.
Note |
---|
Due to time constraints, this goal has been de-prioritized. If you are unclear why a certain rule is configured the way it is, please open an issue. PRs are also still welcome, of course. |
“reactive”
This configuration determines whether your project uses the eslint plugins it has rules for and only activates those rules for the available plugins. That way, you can set up your project and just add the plugins you're interested in. The configuration will handle the rest.
And yes, on first publish, there's only a few rules. Live with it or get active!
“shareable”
That's eslint-speak for an npm package that you can add to your project's dev dependencies and include in your estlintrc's extends
configuration.
variations
I hope that this will be interesting to others than myself. Therefore, I want to enable others to use this to the degree they are comfortable with. What that means is that you can use all the rules in here, just the most important ones, or something in between that will cover a lot but leave you in peace with what goes into the area of nit-picking.
What's in it, how to use it
First, install it (as well as the plugins you want):
npm install --save-dev eslint-config-rasenplanscher eslint@^8.7.0 @typescript-eslint/eslint-plugin@^5.10.0 @typescript-eslint/parser@^5.10.0 eslint-plugin-compat@^4.0.2 eslint-plugin-import@^2.25.4 eslint-plugin-node@^11.1.0 eslint-plugin-react@^7.28.0 eslint-plugin-simple-import-sort@^7.0.0 eslint-plugin-unused-imports@^2.0.0
Then either add this to your package.json
:
"eslintConfig": {
"root": true,
"extends": "rasenplanscher",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
}
},
…or create a file named .eslintrc.json
with following contents in the root folder of your project:
{
"root": true,
"extends": "rasenplanscher",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
}
}
When using @typescript-eslint/eslint-plugin
(you should 😉),
you need to also add @typescript-eslint/parser
to your dependencies and set the appropriate typescript configuration:
{
"root": true,
"extends": "rasenplanscher",
"parserOptions": {
"ecmaVersion": 2021,
"project": "./tsconfig.json",
"sourceType": "module"
}
}
If your project is a multi-package monorepo, see @typescript-eslint
's docs on configuring a monorepo.
If you want to relax or strengthen your setup, you can choose from these setups (from smallest to largest):
rasenplanscher/eslintrc.important
:
The really important rules that will actually prevent errors – Never go without these!rasenplanscher
:
Adds more rules that will help avoid confusion. Most projects will profit from these.rasenplanscher/eslintrc.all
:
Adds more rules. These will help legibility, and therefore maintainability. Since these will be regarded as just “personal preference” by some people, they are opt-in.rasenplanscher/eslintrc.all.dangerzone
:
Modifies a few rules to enable some advanced patterns that really should be used only by those who really know what they do. If you want to use this, first familiarize yourself with the Pro Tips of dangerzone
-enabled rules. If you don't know how, this is not for you yet.
⚠ dangerzone
If you want more control over what's going on, especially if you want to go into the danger zone step by step (which is definitely recommended), your best friend is eslintrc.make.js
which exposes the API that the ready-made extendable files use themselves:
module.exports = require('eslint-config-rasenplanscher/eslintrc.make')({
priorities: [ 'IMPORTANT', 'HELPFUL', 'TASTE' ],
dangerzone: [ 'curly' ],
overrides: {
root: true,
parserOptions: {
ecmaVersion: 2021,
},
},
})
Changelog
[2.2.1]
[2.2.0]
- support for
eslint-plugin-react
- add
browser
environment for eslint-plugin-react
, eslint-plugin-react-hooks
, and eslint-plugin-vue
- add
node
environment for eslint-plugin-node
- 26 new rule configurations
[2.1.0]
- support for
eslint-plugin-compat
- 37 new rule configurations
[2.0.0]
- Breaking Change: deactivate overridden rules instead of ignoring
- Breaking Change: emit warnings instead of errors for
TASTE
level rules - support for
eslint-plugin-vue
- support for
eslint-plugin-simple-import-sort
- 70 new rule configurations
[1.3.0]
- note in README about de-prioritization of detailed rules documentation
- call to action for un-documented rule configurations
- 147 new rule configurations
[1.2.0]
- fix
peerDependencies
- note in README about
parserOptions.project
for @typescript-eslint/eslint-plugin
- 8 new rule configurations
[1.1.0]
- 30 new rule configurations
[1.0.0]
- Reactiveness
- 4 levels/variants:
default
, important
, all
, all+dangerzone
- 29 rule configurations