1.1.15 • Published 7 months ago

@itcase/lint v1.1.15

Weekly downloads
-
License
MIT
Repository
github
Last release
7 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

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.37

11 months ago

1.0.36

12 months ago

1.0.35

1 year ago

1.0.34

1 year ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.39

11 months ago

1.0.38

11 months ago

1.1.9

8 months ago

1.1.8

8 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.0.40

11 months ago

1.1.12

7 months ago

1.0.44

9 months ago

1.1.11

7 months ago

1.0.43

9 months ago

1.1.10

7 months ago

1.0.42

9 months ago

1.0.41

11 months ago

1.0.48

9 months ago

1.1.15

7 months ago

1.1.14

7 months ago

1.0.46

9 months ago

1.1.13

7 months ago

1.0.45

9 months ago

1.0.49

9 months ago

1.0.15

1 year 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