Opinionated eslint defaults for js/node repositories. If you need to check the documentation in order to overwrite some rules in your repository, go to https://eslint.org/docs/rules/ and have a look.
-
If you don't already have a
package.json
file, create one withnpm init
. -
Then you need to install the packages needed by the config
npx install-peerdeps --dev eslint-config-azedo
-
Now, if you have a look at your
package.json
file, you can see that it has a bunch of new packages underdevDependencies
-
Next you need to import this config in your
.eslintrc
in order to use them. (Thereact config
is enabled by default, but in case you want to use thenode config
just change the extends string toeslint-config-azedo/node-config
)
module.exports = {
extends: ['eslint-config-azedo']
}
- You can also use our automated script in order to create the
.eslintrs.js
,.prettierrc.js
andvscode/settings.json
files (they will not be replaced in case you already have them!)
# Run this on your project's main folder (root folder)
./node_modules/eslint-config-azedo/utils/setup.js
# You can also use the node command if you prefer (you don't need to!)
node node_modules/eslint-config-azedo/utils/setup.js
- Lastly, don't forget to add a script in your
package.json
file to run these rules against your codebase.
"scripts": {
"lint": "eslint '*/**/*.{js,jsx,ts,tsx}' --fix"
}
-
And that's it! Now you should be able to run these rules whenever you want.
-
One suggestion is that you add the script above
lint
in your repo:- As a
pre-push
hook (with husky):
"husky": { "hooks": { "pre-push": "npm run lint" } }
- And/or as a step in your CI pipelines
linting: stage: codeQuality script: - npm run lint
- As a
-
One last thing. Feel free to customize these rules in your repository by overwriting them in the
.eslintrc
file or adding more rules that are necessary (or make more sense) for your codebase.
- If you can't use the automated script (because you already had the package in your repo), delete the
node_modules
folder from your repo and install this config package again!
# On your project's main folder (root folder), type - PLEASE BE CAREFUL WITH THIS RM COMMAND!!!!!
rm -rf node_modules
# Then, in the same main folder (root folder), install the project's dependencies again (since they should already be in package.json, just run the global npm install command)
npm i