Skip to content

ESLint config for Fishbrain TypeScript projects

License

Notifications You must be signed in to change notification settings

fishbrain/eslint-config-fishbrain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESLint config for Fishbrain TypeScript React projects

Base config Version React config Version

Usage

Install the dependency:

yarn add -D @fishbrain/eslint-config-base
# Or, for React projects
yarn add -D @fishbrain/eslint-config-react

Create 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",
  }
}

Overriding rules

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',
    },
  },
];

Ignoring files

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
  },
];

Recommended Prettier settings

Add this to package.json to get correct config for prettier

  "prettier": {
    "singleQuote": true,
    "trailingComma": "all"
  }

Browser compatibility settings

If you want to target certain browsers you can also set them in package.json.

  "browserslist": ["chrome 70", "last 1 versions", "not ie <= 8"]

Releasing

  1. Run yarn workspaces foreach -A version <patch|minor|major>.
  2. Merge all changes to develop
  3. Run /golive eslint-config-fishbrain in Slack.
  4. Merge the created go live PR.

About

ESLint config for Fishbrain TypeScript projects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published