⚠ 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: That package has the exact same feature set at the time of writing but will be maintained and extended.
Work on Please make sure to switch. |
This package provides a reasoned reactive shareable ESLint configuration in several variations.
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. |
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!
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.
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.
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 ofdangerzone
-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:
// eslintrc.js in your project
module.exports = require('eslint-config-rasenplanscher/eslintrc.make')({
priorities: [ 'IMPORTANT', 'HELPFUL', 'TASTE' ],
dangerzone: [ 'curly' ],
overrides: {
root: true,
parserOptions: {
ecmaVersion: 2021,
},
},
})
- fix README
- support for
eslint-plugin-react
- add
browser
environment foreslint-plugin-react
,eslint-plugin-react-hooks
, andeslint-plugin-vue
- add
node
environment foreslint-plugin-node
- 26 new rule configurations
- import/no-deprecated
- react/display-name
- react/jsx-key
- react/jsx-no-comment-textnodes
- react/jsx-no-duplicate-props
- react/jsx-no-target-blank
- react/jsx-no-undef
- react/jsx-uses-react
- react/jsx-uses-vars
- react/no-children-prop
- react/no-danger-with-children
- react/no-deprecated
- react/no-direct-mutation-state
- react/no-find-dom-node
- react/no-is-mounted
- react/no-render-return-value
- react/no-string-refs
- react/no-unescaped-entities
- react/no-unknown-property
- react/no-unsafe
- react/prop-types
- react/react-in-jsx-scope
- react/require-render-return
- vue/jsx-uses-vars
- vue/require-render-return
- vue/script-setup-uses-vars
- support for
eslint-plugin-compat
- 37 new rule configurations
- no-void
- @typescript-eslint/adjacent-overload-signatures
- @typescript-eslint/array-type
- @typescript-eslint/await-thenable
- @typescript-eslint/ban-ts-comment
- @typescript-eslint/ban-tslint-comment
- @typescript-eslint/ban-types
- @typescript-eslint/explicit-function-return-type
- @typescript-eslint/no-empty-interface
- @typescript-eslint/no-explicit-any
- @typescript-eslint/no-extra-non-null-assertion
- @typescript-eslint/no-floating-promises
- @typescript-eslint/no-for-in-array
- @typescript-eslint/no-inferrable-types
- @typescript-eslint/no-meaningless-void-operator
- @typescript-eslint/no-misused-new
- @typescript-eslint/no-misused-promises
- @typescript-eslint/no-namespace
- @typescript-eslint/no-non-null-asserted-nullish-coalescing
- @typescript-eslint/no-non-null-asserted-optional-chain
- @typescript-eslint/no-non-null-assertion
- @typescript-eslint/no-this-alias
- @typescript-eslint/no-unsafe-argument
- @typescript-eslint/no-unsafe-assignment
- @typescript-eslint/no-unsafe-call
- @typescript-eslint/no-unsafe-member-access
- @typescript-eslint/no-unsafe-return
- @typescript-eslint/no-var-requires
- @typescript-eslint/prefer-as-const
- @typescript-eslint/prefer-namespace-keyword
- @typescript-eslint/prefer-nullish-coalescing
- @typescript-eslint/restrict-plus-operands
- @typescript-eslint/restrict-template-expressions
- @typescript-eslint/triple-slash-reference
- @typescript-eslint/unbound-method
- compat/compat
- import/no-namespace
- 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
- getter-return
- no-async-promise-executor
- no-compare-neg-zero
- no-import-assign
- no-loss-of-precision
- no-magic-numbers
- no-misleading-character-class
- no-prototype-builtins
- no-restricted-imports
- no-setter-return
- no-unused-expressions
- no-use-before-define
- prefer-const
- prefer-destructuring
- prefer-regex-literals
- prefer-template
- radix
- require-atomic-updates
- require-await
- require-unicode-regexp
- require-yield
- sort-imports
- @typescript-eslint/brace-style
- @typescript-eslint/comma-dangle
- @typescript-eslint/comma-spacing
- @typescript-eslint/default-param-last
- @typescript-eslint/dot-notation
- @typescript-eslint/func-call-spacing
- @typescript-eslint/init-declarations
- @typescript-eslint/keyword-spacing
- @typescript-eslint/no-array-constructor
- @typescript-eslint/no-dupe-class-members
- @typescript-eslint/no-duplicate-imports
- @typescript-eslint/no-empty-function
- @typescript-eslint/no-extra-parens
- @typescript-eslint/no-extra-semi
- @typescript-eslint/no-implied-eval
- @typescript-eslint/no-invalid-this
- @typescript-eslint/no-loss-of-precision
- @typescript-eslint/no-magic-numbers
- @typescript-eslint/no-redeclare
- @typescript-eslint/no-restricted-imports
- @typescript-eslint/no-shadow
- @typescript-eslint/no-throw-literal
- @typescript-eslint/no-unused-expressions
- @typescript-eslint/no-unused-vars
- @typescript-eslint/no-use-before-define
- @typescript-eslint/no-useless-constructor
- @typescript-eslint/object-curly-spacing
- @typescript-eslint/padding-line-between-statements
- @typescript-eslint/quotes
- @typescript-eslint/require-await
- @typescript-eslint/space-before-function-paren
- @typescript-eslint/space-infix-ops
- import/default
- import/export
- import/extensions
- import/named
- import/namespace
- import/no-absolute-path
- import/no-duplicates
- import/no-named-as-default-member
- import/no-named-as-default
- import/no-unresolved
- import/order
- import/unambiguous
- node/no-restricted-import
- node/no-restricted-require
- simple-import-sort/exports
- simple-import-sort/imports
- note in README about de-prioritization of detailed rules documentation
- call to action for un-documented rule configurations
- 147 new rule configurations
- accessor-pairs
- array-bracket-newline
- array-bracket-spacing
- arrow-parens
- block-scoped-var
- block-spacing
- computed-property-spacing
- constructor-super
- default-case-last
- default-case
- default-param-last + @typescript-eslint/default-param-last
- dot-location
- dot-notation + @typescript-eslint/dot-notation
- eol-last
- for-direction
- id-denylist
- id-length
- implicit-arrow-linebreak
- indent
- init-declarations + @typescript-eslint/init-declarations
- key-spacing
- linebreak-style
- new-parens
- no-alert
- no-array-constructor + @typescript-eslint/no-array-constructor
- no-caller
- no-class-assign
- no-cond-assign
- no-confusing-arrow
- no-console
- no-const-assign
- no-control-regex
- no-debugger
- no-delete-var
- no-div-regex
- no-dupe-args
- no-dupe-class-members + @typescript-eslint/no-dupe-class-members
- no-dupe-else-if
- no-dupe-keys
- no-duplicate-imports + @typescript-eslint/no-duplicate-imports
- no-empty-character-class
- no-empty-function + @typescript-eslint/no-empty-function
- no-empty-pattern
- no-empty
- no-eval
- no-ex-assign
- no-extend-native
- no-extra-bind
- no-extra-boolean-cast
- no-extra-label
- no-extra-parens + @typescript-eslint/no-extra-parens
- no-extra-semi + @typescript-eslint/no-extra-semi
- no-fallthrough
- no-floating-decimal
- no-global-assign
- no-implied-eval + @typescript-eslint/no-implied-eval
- no-inner-declarations
- no-invalid-regexp
- no-invalid-this + @typescript-eslint/no-invalid-this
- no-irregular-whitespace
- no-iterator
- no-labels
- no-lone-blocks
- no-lonely-if
- no-multi-assign
- no-multi-spaces
- no-multi-str
- no-multiple-empty-lines
- no-new-func
- no-new-object
- no-new-symbol
- no-new-wrappers
- no-new
- no-obj-calls
- no-octal-escape
- no-octal
- no-proto
- no-redeclare + @typescript-eslint/no-redeclare
- no-regex-spaces
- no-self-assign
- no-self-compare
- no-sequences
- no-shadow-restricted-names
- no-shadow + @typescript-eslint/no-shadow
- no-sparse-arrays
- no-tabs
- no-template-curly-in-string
- no-throw-literal + @typescript-eslint/no-throw-literal
- no-trailing-spaces
- no-undef-init
- no-undef
- no-undefined
- no-unmodified-loop-condition
- no-unneeded-ternary
- no-unreachable-loop
- no-unreachable
- no-unsafe-finally
- no-unsafe-negation
- no-unsafe-optional-chaining
- no-unused-labels
- no-useless-backreference
- no-useless-catch
- no-useless-computed-key
- no-useless-concat
- no-useless-constructor + @typescript-eslint/no-useless-constructor
- no-useless-escape
- no-useless-return
- no-var
- no-void
- no-whitespace-before-property
- no-with
- object-curly-spacing + @typescript-eslint/object-curly-spacing
- object-property-newline
- operator-linebreak
- padded-blocks
- padding-line-between-statements + @typescript-eslint/padding-line-between-statements
- rest-spread-spacing
- semi-spacing
- space-before-blocks
- space-unary-ops
- spaced-comment
- switch-colon-spacing
- template-curly-spacing
- use-isnan
- valid-typeof
- yield-star-spacing
- @typescript-eslint/lines-between-class-members
- node/handle-callback-err
- node/no-new-require
- node/no-path-concat
- fix
peerDependencies
- note in README about
parserOptions.project
for@typescript-eslint/eslint-plugin
- 8 new rule configurations
- no-constant-condition
- @typescript-eslint/no-unnecessary-boolean-literal-compare
- @typescript-eslint/no-unnecessary-condition
- @typescript-eslint/no-unnecessary-qualifier
- @typescript-eslint/no-unnecessary-type-arguments
- @typescript-eslint/no-unnecessary-type-assertion
- @typescript-eslint/no-unnecessary-type-constraint
- @typescript-eslint/strict-boolean-expressions
- 30 new rule configurations
- comma-dangle + @typescript-eslint/comma-dangle
- comma-spacing + @typescript-eslint/comma-spacing
- comma-style
- eqeqeq
- func-call-spacing + @typescript-eslint/func-call-spacing
- keyword-spacing + @typescript-eslint/keyword-spacing
- no-duplicate-case
- no-unused-vars + @typescript-eslint/no-unused-vars
- one-var-declaration-per-line
- one-var
- quotes + @typescript-eslint/quotes
- space-before-function-paren + @typescript-eslint/space-before-function-paren
- space-infix-ops + @typescript-eslint/space-infix-ops
- wrap-iife
- yoda
- @typescript-eslint/consistent-type-definitions
- @typescript-eslint/indent
- import/no-extraneous-dependencies
- unused-imports/no-unused-imports-ts
- unused-imports/no-unused-imports
- unused-imports/no-unused-vars-ts
- unused-imports/no-unused-vars
- Reactiveness
- 4 levels/variants:
default
,important
,all
,all+dangerzone
- 29 rule configurations
- array-element-newline
- brace-style + @typescript-eslint/brace-style
- camelcase
- consistent-return
- curly
- id-match
- indent
- lines-between-class-members
- new-cap
- no-case-declarations
- no-func-assign
- no-label-var
- no-mixed-spaces-and-tabs
- no-nonoctal-decimal-escape
- no-restricted-properties
- no-return-assign
- no-this-before-super
- no-unexpected-multiline
- no-useless-call
- no-useless-rename
- prefer-arrow-callback
- prefer-numeric-literals
- prefer-rest-params
- prefer-spread
- semi-style
- semi
- sort-keys
- space-in-parens