Popular eslint configurations
Course: ESLint, Prettier and Pre-commit hooks - chapter 6
You can roll your own config, like we did in the last slide
module.exports = { root: true, env: { browser: true, es2020: true }, extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended', ], ignorePatterns: ['dist', '.eslintrc.cjs'], parser: '@typescript-eslint/parser', plugins: ['react-refresh'], rules: { 'react-refresh/only-export-components': [ 'warn', { allowConstantExport: true }, ], },}Or you can use a popular one created by other people, for example

Using airbnb config
Section titled “Using airbnb config”- Add dependencies
yarn add eslint-config-airbnb eslint-config-airbnb-typescript eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-import @typescript-eslint/eslint-plugin- Update .eslintrc.cjs
module.exports = { root: true, env: { browser: true, es2020: true }, parserOptions: { ecmaVersion: "latest", sourceType: "module", project: ["./tsconfig.json", "./tsconfig.node.json"], tsconfigRootDir: __dirname, }, extends: [ "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended", "airbnb", "airbnb/hooks", ], ignorePatterns: ["dist", ".eslintrc.cjs", "vite.config.ts"], parser: "@typescript-eslint/parser", plugins: ["react-refresh"], rules: { "react/jsx-filename-extension": [ 1, { extensions: [".js", ".jsx", ".ts", ".tsx"] }, ], "react-refresh/only-export-components": [ "warn", { allowConstantExport: true }, ], },};💡 If you try doing the same in the new config system (for eg, the node.js project), you’ll face some issues.
New config system - ‣
- Update .eslintrc.cjs (read README.md)
parserOptions: { ecmaVersion: 'latest', sourceType: 'module', project: ['./tsconfig.json', './tsconfig.node.json'], tsconfigRootDir: __dirname, },- Try running the lint command
yarn lint
- Try fixing them automatically
npm run lint -- --fix- Fix the rest of the errors manually
- Update .eslintrc.cjs to ignore
vite.config.js
ignorePatterns: ['dist', '.eslintrc.cjs', 'vite.config.ts'],