@itcase/lint v1.1.15
ITCase Lint
Presets of linter configurations
Installation
$ npm i -D @itcase/lint eslint stylelint prettierSetting up sorting configuration
The sorting configuration is located in the perfectionist folder along the path: eslint/perfectionist.
Example: Setting up sortJSXProps
Sorting rules are defined in eslint/perfectionist/sortJSXProps.js.
Here's how to set up the order and rules:
groups:
- This array defines the order in which the props will be sorted.
- Add the prop names in the order you want them to be.
customRulesForGroups:
If the prop sort order depends on the template (rather than the exact name), set up the rule here.
For example:
const groups = [
'className',
'key',
// ...
'callback',
]
const customRulesForGroups = {
callback: '^on.*',
}Usage
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'
export default eslintESLint with MobX
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]ESLint with React Native
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 eslintReactNative from '@itcase/lint/eslint/react-native/index.js'
export default [...eslint, ...eslintReactNative]ESLint with MobX, React Native
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'
import eslintReactNative from '@itcase/lint/eslint/react-native/index.js'
export default [...eslint, ...eslintMobx, ...eslintReactNative]Stylelint
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'],
}Prettier
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 prettiergit-hook
- Use
huskyandlint-staged
npm i -D husky lint-staged- Create a
.lintstagedrcconfiguration 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,.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; fi12 months ago
12 months ago
12 months ago
1 year ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
10 months ago
10 months ago
11 months ago
11 months ago
8 months ago
8 months ago
9 months ago
10 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
9 months ago
5 months ago
8 months ago
5 months ago
8 months ago
6 months ago
8 months ago
9 months ago
8 months ago
5 months ago
5 months ago
8 months ago
5 months ago
8 months ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago