@jtomaszewski/eslint-config
v4.0.1
Published
ESLint config to be used in some of our projects, that includes recommended rules of the following plugins:
Downloads
3
Readme
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-config
Add all peer dependencies of
@jtomaszewski/eslint-config
as dev dependencies in your project. Usenpm info @jtomaszewski/eslint-config peerDependencies
to 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-node
with 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
overrides
to your.eslintrc.js
that 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