opinionated-eslint-config
v0.2.0
Published
An opinionated linter configuration
Readme
Opinionated eslint config
A custom eslint configuration which has strong opinions.
Because of this, it is recommended to run eslint with the --cache option.
Besides that I also recommend the --max-warnings 0 option.
Inspired by @antfu/eslint-config.
How to use
Install with npm i -D opinionated-eslint-config.
Add the script "lint": "eslint . --cache --max-warnings 0" to your package.json scripts.
Create an eslint.config.mjs file in the root of your project with the following content:
import opinionated from 'opinionated-eslint-config';
export default opinionated();The argument of the functions gets passed along to the @antfu/eslint-config,
so see the documentation there for extra options.
To add or modify rules, you can make use of functions such as append and override,
as described here.
All the examples below can be chained.
In case you want to override the TypeScript linter parser options,
you want to override the opinionated/typescript/setup config.
For example:
import opinionated from 'opinionated-eslint-config';
export default opinionated().override(
'opinionated/typescript/setup',
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
}
}
);The ignored files are defined by [ '.git/', '**/node_modules/', '**/dist', 'coverage' ].
More patterns can be ignored by appending them to the configuration:
import opinionated from 'opinionated-eslint-config';
export default opinionated().append({
ignores: [ 'test/assets/*', 'componentsjs-error-state.json' ],
});There is a set of rules specific for test files.
These are determined with the glob [ 'test/**/*.ts' ].
This can be modified as follows:
import opinionated from 'opinionated-eslint-config';
export default opinionated().override(
'opinionated/test',
{
files: [ 'my-tests/**/*.ts' ],
});Depending on your setup, the jest linting rules might be unable to automatically detect your jest version. In that case you want to add the following to your configuration:
import opinionated from 'opinionated-eslint-config';
export default opinionated().override(
'opinionated/test',
{
settings: {
jest: {
version: 30,
},
},
});