Presets of linter configurations
$ npm i -D @itcase/lint eslint stylelint prettier
Create a eslint.config.mjs
configuration file in the root of your project with the following content:
import eslint from '@itcase/lint/eslint/index.js'
export default eslint
Create a eslint.config.mjs
configuration file in the root of your project with the following content:
import eslint from '@itcase/lint/eslint/index.js'
import eslintMobx from '@itcase/lint/eslint/mobx/index.js'
export default [...eslint, ...eslintMobx]
Create a eslint.config.mjs
configuration file in the root of your project with the following content:
export default {
extends: ['@itcase/lint/stylelint/index.js'],
}
Create a prettier.config.mjs
configuration file in the root of your project with the following content:
import prettier from '@itcase/lint/prettier/index.js'
export default prettier
- Use
husky
andlint-staged
npm i -D husky lint-staged
- Create a
.lintstagedrc
configuration file in the root of your project with the following content:
{
"*.css": ["npx stylelint --fix"],
"*.(js|jsx|ts|tsx)": ["npx eslint --fix"]
}
- Add pre-commit hook in
.husky/pre-commit
#!/bin/bash
if grep --include=*.{json,css,html} --exclude-dir={dist,node_modules,bower_components,.git} -nri --color -B 1 -A 1 '<\{7\} HEAD\|^\=\.{7\}\|>\.{7\}' .; then
echo 'Fix conflicts'
exit 1
else ./node_modules/lint-staged/bin/lint-staged.js; fi