A strict ESLint configuration
This is a strict shareable ESLint configuration. All ESLint core rules and a variety of ESLint plugins have been carefully considered. Overrides are used to apply rules based on context.
Install @remcohaszing/eslint
using npm
.
npm install --save-dev \
eslint \
@remcohaszing/eslint \
prettier
First configure Prettier. For example, create a
.editorconfig
with the following content:
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 100
trim_trailing_whitespace = true
And create a .prettierrc.yaml
with the following content:
proseWrap: always
singleQuote: true
trailingComma: all
Next, create eslint.config.js
with the following content:
export { default } from '@remcohaszing/eslint'
This configuration enabled ESLint for TypeScript automatically.
Some rules from @typescript-eslint/eslint-plugin
require TypeScript type checking features to be
enabled. Unfortunately, this makes ESLint slow. Enabling these rules is recommended for small
projects only. To enable this, add the following to eslint.config.js
:
import config, { typechecking } from '@remcohaszing/eslint'
export default [...config, ...typechecking]
Code blocks in Markdown are linted by default using
@eslint/markdown
. The type checking rules from
@typescript-eslint/eslint-plugin
don’t work with markdown code blocks.
prettier/prettier
is disabled, because it doesn’t play nice with eslint-plugin-markdown
.
Some other rules have been turned off, because these rules may conflict with the purpose of the documentation.
Rules can be disabled by adding an extra ESLint configuration item to the configuration array. For example:
import config from '@remcohaszing/eslint'
export default [
...config,
{
rules: {
'no-console': 'off'
}
}
]
By default ESLint ignores node_modules/
and all dotfiles. This ESLint configuration also ignores
the patterns from .gitignore
.
All ESLint that are turned on will trigger error, not warnings. The notable exceptions is
@typescript-eslint/no-deprecated
.
This is to allow a smooth migration if a dependency decides to deprecate an API. To turn make warnings cause ESLint to exit with exit code 1, run:
eslint
This project requires Node.js 22 or greater.