@bulb/eslint-config-bulb

ESLint rules for Bulb packages

Usage no npm install needed!

<script type="module">
  import bulbEslintConfigBulb from 'https://cdn.skypack.dev/@bulb/eslint-config-bulb';
</script>

README

@bulb/eslint-config-bulb

A shared ESLint config for TypeScript codebases at Bulb.

This config extends the following existing configs, in this order of precedence:

If your project is not using React, the React rules mostly won't have any impact.

If your project is not using Typescript+Prettier, update your project to use Typescript+Prettier immediately.

You can refer to index.ts for the full list of rules.

Getting started

To install:

yarn add --dev eslint@^6 @bulb/eslint-config-bulb

Then add the following to .eslintrc.json in the root of the directory you want to lint:

{
  "extends": ["@bulb/eslint-config-bulb", "@bulb/eslint-config-bulb/jest"]
}

If you're using mocha for testing, use the following instead:

{
  "extends": ["@bulb/eslint-config-bulb", "@bulb/eslint-config-bulb/mocha"]
}

The Jest config assumes your test files are using the extension .test.tsx?, mocha assumes .spec.ts.

Per-project rule overrides

Different projects have different needs. You can override rules in your .eslintrc.json. If you find yourself disabling the same rules in multiple projects, consider updating this config instead.

What about TSLint?

TSLint is being deprecated in favor of ESLint.

Add a lint script to package.json

Add the following script to the scripts section of your package.json:

{
  // ... other package.json stuff

  "scripts": {
    // ... other scripts

    "lint": "eslint --cache 'src/**/*.{ts,tsx,js,jsx}'"
  }
}

You may need to adjust the folders and file extensions based on your project.

Next steps

After getting ESLint set up locally, you probably want to:

  1. Add a lint check commit hook using lint-staged.
  2. Add a lint step to your build.