Install the dependency:
yarn add -D @fishbrain/eslint-config-base
# Or, for React projects
yarn add -D @fishbrain/eslint-config-reactCreate a file in the root of your project named eslint.config.js, or eslint.config.mjs if ESM is not enabled.
Populate it with the following content:
import { config, looseTypes, configWithoutJest } from '@fishbrain/eslint-config-base';
export default [
...config, // or configWithoutJest if the project doesn't use Jest.
...looseTypes, // Use this if the project is poorly typed.
];You can run linting with a script in package.json. Note that we reference ESLint from node_modules directly
as it's installed as a dependency of our config and is not available by calling eslint:
{
"scripts": {
"lint": "node_modules/.bin/eslint src some_other_dir some_file.js",
}
}Rules can be overriden in a project by editing the eslint.config.js file like so:
export default [
...config,
{
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
},
},
];You can ignore files using a glob pattern. Note that the ignores object needs to be on its own without other rules to be applied globally to all rules.
export default [
{
ignores: ['src/__generated__/**/*', 'setupTests.js'],
},
...config,
{
// Other custom rules and config
},
];Add this to package.json to get correct config for prettier
"prettier": {
"singleQuote": true,
"trailingComma": "all"
}If you want to target certain browsers you can also set them in package.json.
"browserslist": ["chrome 70", "last 1 versions", "not ie <= 8"]- Run
yarn workspaces foreach -A version <patch|minor|major>. - Merge all changes to
develop - Run
/golive eslint-config-fishbrainin Slack. - Merge the created go live PR.