1.0.14 • Published 8 months ago

@itcase/lint v1.0.14

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

ITCase Lint

Presets of linter configurations

Installation

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

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]

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,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