@voxpelli/eslint-config
My personal ESLint config which extends standard / semistandard with a couple of extra checks that I find helpful in my projects.
Includes the semistandard rules directly rather than relying on eslint-config-semistandard, as that package isn't always trailing the main eslint-config-standard package.
This package follows semantic versioning. Tightening of any checks is a breaking change, therefore that will only happen in major releases. Minor and patch releases will only include relaxation of rules or fixing of minor obvious oversights.
Can I use this in my own project?
Absolutely, go ahead! I maintain this project as if multiple people are using it. Be sure to give me feedback and if you like it, give me a ping and say so, would make my day
Usage
Install
Be sure to install the correct versions of peer dependencies that this module requires, else you will likely get an incorrect rule setup.
To easily install all correct peer dependencies, you can use install-peerdeps
:
install-peerdeps --dev @voxpelli/eslint-config
Configure
Add an .eslintrc
, or other ESLint configuration, that extends this config:
{
"extends": "@voxpelli",
"root": true
}
Configure, ESM
Instead of simply extending @voxpelli
you can extend @voxpelli/eslint-config/esm
and get a version of the rules that enforces ESM best practices as well.
standard?
How does this differ from pure🛑 = changed toerror
level⚠️ = changed towarn
level- 🔇 = deactivated
🔧 = changed config😬 = will not pass vanilla standard linting
🔧 Changed standard rules
🔧 ⚠️ 😬 comma-dangle
– changed – prefer dangling commas in everything but functions + is it set towarn
rather thanerror
as I gradually move to this setup🔇 dot-notation
– deactivated – clashes with thenoPropertyAccessFromIndexSignature
check in TypeScript, which I use🔧 😬 no-multi-spaces
– changed – setsignoreEOLComments
totrue
, can be useful for more readable comments across multiple lines and I see no real downsides to it (Incompatible with standard)🔧 no-unused-vars
– changed – sets"args": "all", "argsIgnorePattern": "^_",
because I personally don't feel limited by Express error handlers + wants to stay in sync with TypeScriptnoUnusedParameters
- 🔧😬
semi
andno-extra-semi
– changed – adopts the semicolons setup from semistandard (Incompatible with plain standard, compatible with semistandard) - 🔧
⚠️ n/no-deprecated-api
– changed – changed towarn
instead oferror
as often it's not an urgent thing to fix
➕ Added ESLint core rules
⚠️ func-style
– disallows function declarations, good to be consistent with how functions are declared⚠️ no-console
– warns on existence ofconsole.log
and similar, as they are mostly used for debugging and should not be committed🛑 no-constant-binary-expression
– errors when binary expressions are detected to constantly evaluate a specific way🛑 no-nonoctal-decimal-escape
– there's no reason not to ban it- 🛑
no-unsafe-optional-chaining
– enforces one to be careful with.?
and not use it in ways that can inadvertently cause errors orNaN
results ⚠️ no-warning-comments
– warns of the existence ofFIXME
comments, as they should always be fixed before pushing- 🛑
object-shorthand
– requires the use of object shorthands for properties, more tidy - 🛑
quote-props
– requires properties to be quoted when needed but otherwise disallows it
📦 Added ESLint rule package
plugin:n/recommended
plugin:security/recommended
plugin:mocha/recommended
plugin:unicorn/recommended
plugin:promise/recommended
plugin:jsdoc/recommended
🔧 Overrides of added ESLint rule packages
-
🔇 jsdoc/check-types
– deactivated – to improve use with types in js. -
🔇 jsdoc/no-undefined-types
– deactivated – to improve use with types in js. -
🔇 jsdoc/require-jsdoc
– deactivated – to improve use with types in js. -
🔇 jsdoc/require-param-description
– deactivated – to improve use with types in js. -
🔇 jsdoc/require-property-description
– deactivated – to improve use with types in js. -
🔇
jsdoc/require-returns-description
– deactivated – to improve use with types in js. -
🔇 jsdoc/require-yields
– deactivated – to improve use with types in js. -
🔧 jsdoc/tag-lines
– changed – to enforce an empty line between description and tags, but disallow them elsewhere. -
🔇
jsdoc/valid-types
– deactivated – to improve use with types in js. -
🔇 mocha/no-mocha-arrows
– deactivated – while Mocha discourages arrow functions I find it more readable to use them + I find it safe when type checking ones test files as then the type checking will notify one when one tries to do athis.setTimeout()
or similar in an arrow function where there is no such local context -
🔇 n/no-process-exit
– deactivated – added byplugin:n/recommended
, but deactivated in favor ofunicorn/no-process-exit
-
🔇 security/detect-object-injection
– deactivated – causes too many false errors -
🔇 security/detect-unsafe-regex
– deactivated – at least early on wasn't very stable -
🔧 unicorn/catch-error-name
– changed – I prefererr
overerror
as I finderror
to be a far too similar name to the built inError
class -
🔇 unicorn/explicit-length-check
– deactivated – I don't see an issue withif (string.length)
instead ofif (string.length !== 0)
-
⚠️ unicorn/unicorn/no-await-expression-member
– changed – eg. useful in chai tests -
⚠️ unicorn/unicorn/no-negated-condition
– deactivated – turned off, there are valid cases for this, so it simply gets noisy -
🔇 unicorn/numeric-separators-style
– deactivated – currently not enough good support for this in engines -
⚠️ unicorn/prefer-add-event-listener
– changed – set towarn
instead oferror
-
⚠️ unicorn/prefer-event-target
– changed – set towarn
instead oferror
-
🔇
unicorn/prefer-module
– deactivated – only useful when you know you're targetting ESM -
⚠️ unicorn/prefer-spread
– changed – set towarn
instead oferror
-
⚠️ unicorn/prefer-string-replace-all
– changed – set towarn
instead oferror
-
🔇 unicorn/prevent-abbreviations
– deactivated – same asunicorn/catch-error-name
, I prefer an abbreviatederr
over a non-abbreviatederror
because the latter is too similar toError
for my taste -
🔧 unicorn/switch-case-braces
– changed – I prefer to avoid braces incase
statements rather than enforcing them
➕ Additional standalone ESLint rules
-
⚠️ es-x/no-exponential-operators
– disallows the use of the**
operator, as that's in most cases a mistake and one really meant to write*
-
⚠️ import/no-deprecated
– disallows the use of explicitly deprecated code (code marked with@deprecated
) -
🛑
import/no-order
– enforces a specific ordering of imports
Extended ESM config
By extending @voxpelli/eslint-config/esm
instead of @voxpelli
you will get these differences:
🔧 Overrides of rules
⚠️ func-style
– enforces function declarations whenever an arrow function isn't used. Better to doexport function foo () {
thanexport const foo = function () {
🛑 unicorn/prefer-module
– changed – restored to itsplugin:unicorn/recommended
value oferror
Alternatives
See also
-
voxpelli/ghatemplates
– the templates I use withghat
to update GitHub Actions in my projects -
voxpelli/renovate-config-voxpelli
– the shareable Renovate setup I use in my projects -
voxpelli/tsconfig
– the shareabletsconfig.json
setup I use in my projects