@jtomaszewski/eslint-config v4.0.1
Introduction
ESLint config to be used in some of our projects, that includes recommended rules of the following plugins:
- eslint-config-airbnb / eslint-config-airbnb-base / eslint-config-airbnb-typescript
- eslint-plugin-react
- eslint-plugin-react-hooks
- eslint-plugin-jsx-a11y
- eslint-config-prettier
- eslint-import-resolver-typescript
- eslint-plugin-import
- eslint-plugin-jest
- eslint-plugin-promise
- eslint-plugin-unicorn
With some slight modifications to some of the defaults on our side.
Usage
Setup eslint as you would normally do.
yarn add -D @jtomaszewski/eslint-configAdd all peer dependencies of
@jtomaszewski/eslint-configas dev dependencies in your project. Usenpm info @jtomaszewski/eslint-config peerDependenciesto look them up.Extend the config as in the following example:
Node.js service:
// .eslintrc.js module.exports = { parser: "@typescript-eslint/parser", parserOptions: { project: ["./tsconfig.json"], }, extends: [require.resolve("@jtomaszewski/eslint-config/configs/ts-node")], };Node.js service without TS:
// .eslintrc.js module.exports = { parser: "babel-eslint", extends: [require.resolve("@jtomaszewski/eslint-config/configs/node")], };Front-end React app:
// .eslintrc.js module.exports = { parser: "@typescript-eslint/parser", parserOptions: { project: ["./tsconfig.json"], }, extends: [require.resolve("@jtomaszewski/eslint-config/configs/ts-react")], };Cypress:
// .eslintrc.js module.exports = { parser: "@typescript-eslint/parser", parserOptions: { project: ["./tsconfig.json"], }, extends: [ require.resolve("@jtomaszewski/eslint-config/configs/ts-cypress"), ], };Replace
ts-nodewith other name of another config file if your environment differs.
Adding it to existing codebase
If your codebase is large and introducing this config makes eslint yell with hundreds of errors, you might find following advices to be useful:
- keep a list of ignored "legacy" files by adding
overridesto your.eslintrc.jsthat ignores some rules in some of your files (until they get improved). You can generate this automatically using transform-eslint-errors-into-overrides script. - use https://github.com/IanVS/eslint-nibble
Releasing
yarn release