1.1.15 • Published 4 months ago

@itcase/lint v1.1.15

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

ITCase Lint

Presets of linter configurations

Installation

$ npm i -D @itcase/lint eslint stylelint prettier

Setting 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:

  1. 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.
  1. 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 eslint

ESLint 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 prettier

git-hook

  1. Use husky and lint-staged
npm i -D husky lint-staged
  1. 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"]
}
  1. 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; fi
1.0.19

11 months ago

1.0.18

11 months ago

1.0.17

11 months ago

1.0.16

11 months ago

1.0.22

11 months ago

1.0.21

11 months ago

1.0.20

11 months ago

1.0.26

11 months ago

1.0.25

11 months ago

1.0.24

11 months ago

1.0.23

11 months ago

1.0.29

11 months ago

1.0.28

11 months ago

1.0.27

11 months ago

1.0.33

11 months ago

1.0.32

11 months ago

1.0.31

11 months ago

1.0.30

11 months ago

1.0.37

9 months ago

1.0.36

10 months ago

1.0.35

10 months ago

1.0.34

10 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.0.39

9 months ago

1.0.38

9 months ago

1.1.9

6 months ago

1.1.8

6 months ago

1.1.7

6 months ago

1.1.6

6 months ago

1.1.5

6 months ago

1.1.4

7 months ago

1.1.3

7 months ago

1.1.2

7 months ago

1.0.40

9 months ago

1.1.12

4 months ago

1.0.44

7 months ago

1.1.11

4 months ago

1.0.43

7 months ago

1.1.10

5 months ago

1.0.42

7 months ago

1.0.41

8 months ago

1.0.48

7 months ago

1.1.15

4 months ago

1.1.14

4 months ago

1.0.46

7 months ago

1.1.13

4 months ago

1.0.45

7 months ago

1.0.49

7 months ago

1.0.15

11 months ago

1.0.14

1 year ago

1.0.11

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago