Opinionated and strict ESLint configs for Node and React projects.
Note
These configs are compatibles with the legacy format only. Upgrading to new flat config format will be considered once it has been adopted by major frameworks.
This package is not available on NPM and therefore needs to be installed directly from GitHub.
-
Install ESLint version
8.57.1
:npm i -D eslint@8.57.1
-
Manually add this package to your
devDependencies
in yourpackage.json
:"devDependencies": { "@rdcavanha/eslint-config": "git+https://github.com/rdcavanha/eslint-config.git" }
If no version is specified, the last commit on the
master
branch will be used. To specify a version, add it to the end of the URL:"devDependencies": { "@rdcavanha/eslint-config": "git+https://github.com/rdcavanha/eslint-config.git#v3.0.0" }
-
In your project, create an ESLint config file
.eslintrc.cjs
and extend the config you would like to you use. For example, in a React + TypeScript project, the config would look like this:module.exports = { extends: ['@rdcavanha/eslint-config/typescript/react'], parserOptions: { project: './tsconfig.eslint.json', }, settings: { typescript: { project: './tsconfig.eslint.json', }, }, };
-
If your project uses TypeScript, create a file named
tsconfig.eslint.json
and add all the files that should be linted. Example of a Vite project:{ "extends": "./tsconfig.json", "include": ["src", ".eslintrc.cjs", "vite.config.ts"] }
ESLint configurations are particularly tricky to test with some package managers due to the need of dependency hoisting. The easiest way to try a rule/plugin change is:
- Fork this repo and create a new branch.
- On your branch, do the changes you need, such as enabling/disabling rules and etc.
- Commit and push your changes so you generate a commit hash and make it available in your remote repository.
- In the project you want to use this config, add the commit hash of your changes at the end of dependency URL. For example:
"devDependencies": { "@rdcavanha/eslint-config": "git+https://github.com/rdcavanha/eslint-config.git#commitHashHere" }
- Run
npm i
or the equivalent command of your package manager. - Repeat these steps as needed until the changes are to your liking.