@seattletimes/st-eslint-config

1.1.3 • Public • Published

Install eslint extension in VScode

  1. Open VScode
  2. Settings -> Extensions
  3. Look under the "RECOMMENDED" tab, find ESLint (dbaeumer.vscode-eslint)
  4. Install ESLint extension and switch to the ESLint "Pre-release" setting -> Restart extension
  5. Make sure it's enabled

Migrating new repo to use this eslint config

  1. Create an eslint.config.mjs file at the root, c/p the following into it:
// eslint.config.mjs
import eslintConfig from '@seattletimes/st-eslint-config';

export default [
  ...eslintConfig,
  {
    // overrides
    rules: {},
    // add file paths that make sense in the repo
    files: [
      "src/**/*.js",
      "src/**/*.ts",
      "src/**/*.jsx",
      "src/**/*.tsx",
      "*.js",
      "*.mjs",
    ],
  },
];
  1. Delete .eslintrc.js
  2. npm install --save-dev @seattletimes/st-eslint-config
  3. Update “lint” script in package.json
"lint": "./node_modules/.bin/eslint --quiet"

Auto-formatting

  1. if .vscode doesn't exist in the repo already, symlink it from the project root. For example, from inside st-spruce-deuce I would run ln -s ../../.vscode .vscode

Why "--quiet"?

Prettier rules (spacing, style-related stuff) are set to "warn" so that VScode will format-on-save using those rules. However, we don't want those rules to fail our builds. "--quiet" tell eslint to ignore rules set to "warn", so that the build will only fail on errors.

Strategy for transitioning repos to new eslint config

First priority is to improve dev experience moving forward, not necessarily to retroactively fix coding style differences. When you first introduce this eslint config there will be LOTS of errors. Rather than fixing all of these, I recommend using eslint exceptions to grandfather them in. This way we can gradually clean up the codebase at our own pace. We can do this by using "eslint-disable-next-line", like this:

// eslint-disable-next-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line react/no-unused-prop-types
// eslint-disable-next-line react/function-component-definition  

What are the eslint rules?

Recommended rules for eslint, react, typescript, and prettier

Updating the npm package

  1. Run npm version patch
  2. Push to github,
  3. Run npm publish --access public

Readme

Keywords

Package Sidebar

Install

npm i @seattletimes/st-eslint-config

Weekly Downloads

27

Version

1.1.3

License

ISC

Unpacked Size

6.38 kB

Total Files

6

Last publish

Collaborators

  • bgamble
  • it-seattletimes
  • plell
  • seattletimes-news