@seattletimes/st-eslint-config
v1.1.9
Published
shared eslint config
Downloads
97
Maintainers
Keywords
Readme
Install eslint extension in VScode
- Open VScode
- Settings -> Extensions
- Look under the "RECOMMENDED" tab, find ESLint (dbaeumer.vscode-eslint)
- Install ESLint extension and switch to the ESLint "Pre-release" setting -> Restart extension
- Make sure it's enabled
Migrating new repo to use this eslint config
- Create an eslint.config.mjs file at the root, c/p the following into it:
// eslint.config.mjs
import { reactEslintConfig, vanillaEslintConfig } from '@seattletimes/st-eslint-config';
export default [
...reactEslintConfig,
{
// overrides
rules: {},
// add file paths that make sense in the repo
files: [
"src/**/*.js",
"src/**/*.ts",
"src/**/*.jsx",
"src/**/*.tsx",
"*.js",
"*.mjs",
],
},
];
- Delete .eslintrc.js
- npm install --save-dev @seattletimes/st-eslint-config
- Update “lint” script in package.json
"lint": "./node_modules/.bin/eslint --quiet"
Auto-formatting
- 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
- Run
npm run build
- Run
npm version patch
- Push to github,
- Run
npm publish