@cewald/eslint-config
v1.4.0
Published
Personal JS/TS coding style-guide
Downloads
484
Readme
@cewald/eslint-config
package source
This is a company-wide coding style-guide using eslint
, @stylistic/eslint-plugin
as formatter and optional linting for TailwindCSS using eslint-plugin-tailwindcss
.
It should be applied to all JS/TS projects to unify the company coding-styles.
Install & setup eslint
and prettier
with this package
Install packages:
npm i -D eslint @cewald/eslint-config
Add
eslint.config.mjs
to root directory:import config from '@cewald/eslint-config' export default [ ...config() ]
For autoformat on save in VSCode, add VSCode settings to workspace settings in
.vscode/settings.json
:{ "editor.formatOnSave": false, "editor.codeActionsOnSave": { "source.fixAll.eslint": "always" } }
Add linting commands to
package.json
:"scripts": { "lint": "eslint", "lint:fix": "eslint --fix", }
Remove unnecessary packages
Setup linting and format pre-commit hooks with husky
With this configured changed files will automatically be formatted and linted on commit.
Install deps:
npm i -D husky lint-staged
Create hook for
husky
in.husky/pre-commit
:npx lint-staged
Add
lint-staged
config topackage.json
:"lint-staged": { "*": [ "npm run lint:fix" ] }
Development
- Simply run
npm run dev
- You can use
npm link
to use a local version in your local repos
Debug eslint
config
In case you have to debug rules or how they are applied, there is a whole guide for it here:
https://eslint.org/docs/latest/use/configure/debug
Anyway the config-inspector
is the best tool:
https://eslint.org/docs/latest/use/configure/debug#use-the-config-inspector
Just run npx eslint --inspect-config
from the root folder and you can see which rules are applied in a nice and conveniant interface.