@darwinhomes/eslint-config v1.0.6
@darwin-homes/eslint-config
Shareable ESLint config for Darwin Homes.
Usage
npm install --save-dev @darwinhomes/eslint-config
Then, add the following to your package.json
:
{
"scripts": {
"lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx --cache"
},
"eslintConfig": {
"extends": "@darwinhomes",
"settings": {
"import/resolver": {
"typescript": {
"project": "./tsconfig.json"
}
}
}
}
}
If you're using a version of React that doesn't require import React
when using JSX, you can add "plugin:react/jsx-runtime"
to the "eslintConfig.extends".
You can also add "eslintIgnore": []
or pass --ignore-path .gitignore
to exclude ignored files from formatting.
You'll also want to add .eslintcache
to your .gitignore.
You may need to disable (or add) additional plugins or rules to work with existing code or alternative frameworks, depending on the project.
Once you've set up eslint (and Prettier, if desired, using our config), you can set up git hooks to run the linters pre-commit using lint-staged
and husky
(see their docs for the most up-to-date setup instructions):
npx mrm@2 lint-staged # You need to temporarily add `eslint` and `prettier` to your devDependencies or this will fail
Be sure to add tsc --noEmit
(ideally aliased as npm run type-check
) to your Husky config.