标签:bash tor ref action rip pac ams commit art
npm install -D stylelint prettier eslint
// yarn
yarn add stylelint prettier eslint -D
安装@umijs/fabric,一个包含 prettier,eslint,stylelint 的配置文件合集
npm i @umijs/fabric
const fabric = require(‘@umijs/fabric‘);
module.exports = {
...fabric.stylelint,
};
module.exports = {
extends: [require.resolve(‘@umijs/fabric/dist/eslint‘)]
globals: {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true,
page: true,
REACT_APP_ENV: true,
},
rules: {
camelcase: ‘off‘,
‘no-console‘: ‘error‘,
‘no-unused-vars‘: ‘error‘,
‘no-else-return‘: [0],
...
}
};
const fabric = require(‘@umijs/fabric‘);
module.exports = {
...fabric.prettier,
};
// .stylelintignore 忽略stylelint检查的文件
// .prettierignore 忽略prettier检查的文件
// .eslintignore 忽略eslint检查的文件
npm install --save-dev husky lint-staged
// package.json
"scripts": {
"start": "umi dev",
"build": "umi build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write ‘**/*.{js,jsx,tsx,ts,less,md,json}‘",
"test": "umi-test",
"test:coverage": "umi-test --coverage",
"lint": "eslint --ext .js src --fix --cache",
"lint-staged": "lint-staged",
"lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx --fix"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"**/*.{js,jsx,less}": [
"prettier --write",
"git add"
],
"**/*.{js,jsx}": "npm run lint-staged:js",
"**/*.less": "stylelint --syntax less"
},
lint-staged添加git add 意味只检查本次提交文件否则检查所有
"editor.codeActionsOnSave": {
"source.fixAll": true
}
配置完后重启VSCode
标签:bash tor ref action rip pac ams commit art
原文地址:https://www.cnblogs.com/zpsakura/p/14315542.html