3.1.0 • Published 2 years ago

shaw-lint v3.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

shaw-lint

Warning

This tool will no longer be updated, if you need to use it, please install V1, V3 is not available now

introduction

shaw-lint integrates ESLint + PretTier for code check and format, now supports React/Vue/Node + typescript.

usage

install

npm install eslint typescript prettier yorkie shaw-lint -D

// or yarn

yarn add eslint typescript prettier yorkie shaw-lint -D

eslint config

1、reeact + typescript

module.exports = {
  extends: [require.resolve('shaw-lint/react')],
  rules: {},
};

2、vue + typescript

module.exports = {
  extends: [require.resolve('shaw-lint/vue')],
  rules: {},
};

3、node + typescript

module.exports = {
  extends: [require.resolve('shaw-lint/node')],
  rules: {},
};

git hooks

install packages

npm i lint-staged husky -D
// or yarn
yarn add lint-staged husky -D

package.json config

  1. react
{
  "scripts": {
    "lint": "eslint 'src/**/*.{js,jsx,tsx,ts}' --cache",
    "lint:fix": "eslint 'src/**/*.{js,jsx,tsx,ts}' --cache --fix",
    "prettier": "prettier --write 'src/**/*.{less,scss,css,md,json}'",
  },
  "gitHooks": {
     "pre-commit": "tsc --noEmit && lint-staged"
  },
  "lint-staged": {
    "src/**/*.{js,jsx,ts,tsx}": [
      "eslint --cache --fix",
      "git add ."
    ],
    "*.{less,scss,css,md,json}": [
      "npm run prettier",
      "git add ."
    ]
  },
}
  1. vue
{
  "scripts": {
    "lint": "eslint 'src/**/*.{js,vue}' --cache",
    "lint:fix": "eslint 'src/**/*.{js,vue}' --cache --fix",
    "prettier": "prettier --write 'src/**/*.{less,scss,css,md,json}'",
  },
  "gitHooks": {
    "pre-commit": "tsc --noEmit && lint-staged"  // ts项目可通过tsc --noEmit校验类错误
  },
  "lint-staged": {
    "src/**/*.{js,vue}": [
      "eslint --cache --fix",
      "git add ."
    ],
    "*.{less,scss,css,md,json}": [
      "npm run prettier",
      "git add ."
    ]
  },
}