Commit 8f1f8c97 authored by v_liuhuaizhi's avatar v_liuhuaizhi

eslint --init

parent f0e7cf87
......@@ -2,9 +2,10 @@
build/*.js
# 忽略src/assets目录下文件的语法检查
src/assets
src/utils
# 忽略public目录下文件的语法检查
public
# 忽略当前目录下为js的文件的语法检查
*.js
# 忽略当前目录下为vue的文件的语法检查
*.vue
\ No newline at end of file
# 忽略permission
src/store/modules/permission.js
# 忽略打包文件
dist
// ESlint 检查配置
module.exports = {
// 此项是用来告诉eslint找当前配置文件不能往父级查找
root: true,
// 此项是用来指定javaScript语言类型和风格,sourceType用来指定js导入的方式,默认是script,此处设置为module,指某块导入方式
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
},
// 此项指定环境的全局变量
env: {
browser: true,
node: true,
es6: true,
es6: true
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
// 下面这些rules是用来设置从插件来的规范代码的规则,使用必须去掉前缀eslint-plugin-
// 主要有如下的设置规则,可以设置字符串也可以设置数字,两者效果一致
// "off" -> 0 关闭规则
// "warn" -> 1 开启警告规则
// "error" -> 2 开启错误规则
// it is base on https://github.com/vuejs/eslint-config-vue
rules: {
"vue/max-attributes-per-line": [2, {
"singleline": 10,
"multiline": {
"max": 1,
"allowFirstLine": false
// 强制规定每行的最大属性数
'vue/max-attributes-per-line': [2, {
'singleline': 10,
'multiline': {
'max': 1,
'allowFirstLine': false
}
}],
"vue/singleline-html-element-content-newline": "off",
"vue/multiline-html-element-content-newline":"off",
"vue/name-property-casing": ["error", "PascalCase"],
"vue/no-v-html": "off",
'vue/singleline-html-element-content-newline': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/name-property-casing': ['error', 'PascalCase'],
'vue/no-v-html': 'off',
'vue/require-prop-types': 'off',
'vue/no-mutating-props': 'off',
'vue/require-valid-default-prop': 'off',
'vue/require-default-prop': 'off',
'no-return-assign': 'off',
'no-labels': 'off',
'no-constant-condition': 'off',
'vue/no-side-effects-in-computed-properties': 'off',
'no-prototype-builtins': 'off',
// 定义对象的set存取器属性时,强制定义get
'accessor-pairs': 2,
// =>的前/后括号
'arrow-spacing': [2, {
'before': true,
'after': true
}],
// 规则在打开的块令牌内和同一行上的下一个令牌内强制执行一致的间距。此规则还会在同一行中的关闭块标记和以前的标记内强制实施一致的间距。
'block-spacing': [2, 'always'],
// 述了花括号相对于其控制语句和正文的位置。1tbs强制执行一个真正的大括号风格
'brace-style': [2, '1tbs', {
'allowSingleLine': true
'allowSingleLine': true // "allowSingleLine": true(默认false)允许一个块打开和关闭括号在同一行上
}],
'camelcase': [0, {
'properties': 'always'
}],
// 尾随逗号
'comma-dangle': [2, 'never'],
// 逗号周围的间距
'comma-spacing': [2, {
'before': false,
'after': true
......@@ -48,7 +72,7 @@ module.exports = {
'curly': [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
'eqeqeq': ["error", "always", {"null": "ignore"}],
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
'generator-star-spacing': [2, {
'before': true,
'after': true
......@@ -71,11 +95,11 @@ module.exports = {
'capIsNew': false
}],
'new-parens': 2,
'no-array-constructor': 2,
'no-array-constructor': 0,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-cond-assign': 0,
'no-const-assign': 2,
'no-control-regex': 0,
'no-delete-var': 2,
......@@ -100,10 +124,6 @@ module.exports = {
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [2, {
'allowLoop': false,
'allowSwitch': false
}],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
......@@ -124,7 +144,6 @@ module.exports = {
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
......
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
......@@ -10,18 +10,8 @@
"build:prod": "vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{js,vue}": [
"eslint --fix",
"git add"
]
"lint": "eslint --ext .js,.vue src",
"prepare": "husky install"
},
"keywords": [
"vue",
......@@ -79,7 +69,8 @@
"sass-loader": "10.1.1",
"script-ext-html-webpack-plugin": "2.1.5",
"svg-sprite-loader": "5.1.1",
"vue-template-compiler": "2.6.12"
"vue-template-compiler": "2.6.12",
"husky": "^8.0.0"
},
"engines": {
"node": ">=8.9",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment