[update] add dependency Eslint & AirBnb

This commit is contained in:
peterlu14
2022-12-07 13:05:39 +08:00
parent 5e7e3caa9e
commit b7f52c902c
3 changed files with 1511 additions and 5 deletions
+88
View File
@@ -0,0 +1,88 @@
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'airbnb-base',
'plugin:vue/vue3-essential',
'standard-with-typescript'
],
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: [ 'vue' ],
rules: {
// 程式碼單行長度不能超過 120
'max-len': [ 'error', 120 ],
// 陣列超過3個元素,需要換行
'array-element-newline': [ 'error', { minItems: 3 } ],
// 允許無名函示
'func-names': [ 'error', 'as-needed' ],
// 不允許連續空格
'no-multi-spaces': 'error',
// 空2格
indent: [ 'error',
2,
{ SwitchCase: 1 } ],
// 使用單引號,字符串中包含了一個其它引號 允許"a string containing 'single' quotes"
quotes: [ 'error',
'single',
{ avoidEscape: true } ],
// 對像大括號空格 { a:b } => { a:b }
'object-curly-spacing': [ 'error', 'always' ],
// 括號去除空格 foo( 'bar' ) => foo('bar');
'space-in-parens': [ 'error', 'never' ],
// 對象分號前後只有一個空格{ "foo" : 42 } => { "foo": 42 };
'key-spacing': [ 'error', { mode: 'strict' } ],
// 逗號前後的空格 [1, 2, 3 ,4] => [1, 2, 4, 4]
'comma-spacing': [ 'error', { before: false, after: true } ],
// 括號內使用空格 [ 1,2 ] => [ 1,2 ]
'array-bracket-spacing': [ 'error', 'always' ],
// if else 風格
'brace-style': [ 'error', '1tbs' ],
// 函數調用空格 fn () => fn()
'func-call-spacing': [ 'error', 'never' ],
// 函數左括號空格 function name () {} => function name(){}
'space-before-function-paren': [ 'error', 'never' ],
// 語句塊的空格 function name() {} => function name(){}
// 'space-before-blocks': [ 'error', 'never' ],
// 關鍵字前後空格 if () => if()
'keyword-spacing': [
'error', {
overrides: {
if: { after: false, before: false },
else: { after: false, before: false }
}
}
],
// 對象取值不能有空格 obj . foo => obj.foo
'no-whitespace-before-property': 'error',
// 最大連續空行數
'no-multiple-empty-lines': [ 'error', { max: 2, maxEOF: 1, maxBOF: 0 } ],
// 代碼塊中去除前後空行
'padded-blocks': [ 'error', 'never' ],
// ;前後空格 var foo ; var bar; => var foo;var bar;
'semi-spacing': [ 'error', { before: false, after: false } ],
// 操作符是否空格 a=0 => a = 0
'space-infix-ops': 'error',
// 操作符空格 + -
'space-unary-ops': 'error',
// 箭頭函數空格 ()=>{} => () => {}
'arrow-spacing': [ 'error', { before: true, after: true } ],
// 擴展運算符 {... f} => {...f}
'rest-spread-spacing': 'error',
// 字符串拼接使用模版字符串 'hello' + world => `hello${world}`
'prefer-template': 'error',
// 模版字符串中去除空格 `${ fo }` =>${fo}
'template-curly-spacing': [ 'error', 'never' ],
// 鍊式調用換行
'newline-per-chained-call': [ 'error', { ignoreChainWithDepth: 1 } ],
// 禁止重複模塊導入
'no-duplicate-imports': 'error',
// 註釋各一個 //a => // a
'spaced-comment': [ 'error', 'always' ]
}
}
+9 -1
View File
@@ -9,14 +9,22 @@
"preview": "vite preview"
},
"dependencies": {
"eslint-config-airbnb-base": "^15.0.0",
"pinia": "^2.0.27",
"vue": "^3.2.41",
"vue-router": "^4.1.6"
},
"devDependencies": {
"@types/node": "^18.11.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@vitejs/plugin-vue": "^3.2.0",
"typescript": "^4.6.4",
"eslint": "^8.0.1",
"eslint-config-standard-with-typescript": "^23.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-vue": "^9.8.0",
"typescript": "*",
"vite": "^3.2.3",
"vue-tsc": "^1.0.9"
}
+1414 -4
View File
File diff suppressed because it is too large Load Diff