校驗template模板的規範,vue元件、props、data等順序一系列推薦風格等
用於校驗js的語法規範,這裡使用airbnb規則
npm i -
d prettier eslint-plugin-prettier eslint-config-prettier
'prettier/prettier':[
'error',,
],
,}
"lint"
:"eslint --ext .js,.vue --ignore-path .gitignore ."
,"lintfix"
:"eslint --fix --ext .js,.vue --ignore-path .gitignore ."
,
cannot find module 'eslint/lib/formatters/stylish'
刪除專案下的package-lock.json檔案;
刪除node_modules資料夾;
執行 npm install 重新安裝npm包
.editorconfig完整配置
.eslintrc.js完整配置# editorconfig.org
root =
true[*
] # 所有檔案都使用配置
charset = utf-
8 # 編碼格式
indent_style = space # tab鍵縮排的樣式,由space和table兩種 一般**中是space
indent_size =
4 # 縮排size為2
end_of_line = lf # 以lf換行 預設win為crlf mac和linux為lf
insert_final_newline =
true # 末尾加一行空行
trim_trailing_whitespace =
true # 去掉行尾多餘空格 [
*.md]
trim_trailing_whitespace =
false
參考:module.exports =
, env:
, parser:
'vue-eslint-parser'
,extends:[
'plugin:vue/recommended'
,'plugin:prettier/recommended'
,'eslint:recommended',]
,// 此項是用來配置標準的js風格,就是說寫**的時候要規範的寫,如果你使用vs-code我覺得應該可以避免出錯
rules:,]
,'vue/max-attributes-per-line':[
'error',,
},],
indent:[2
,4,]
,// 縮排4
'comma-dangle':0
,// 物件字面量項尾不能有逗號
'new-cap':0
,// 函式名首行大寫必須使用new方式呼叫,首行小寫必須用不帶new方式呼叫
'no-console':0
,// 禁止使用console
'no-extra-semi':0
,// 禁止多餘的冒號
'no-new':0
,// 禁止在使用new構造乙個例項後不賦值
'no-undef':0
,// 不能有未定義的變數
'quote-props':0
,// 屬性名不限制
//"space-before-function-paren": [2, "never"], // 函式定義時括號前面要不要有空格
'no-unused-expressions'
:'off'
,// 禁止無用的表示式
'generator-star-spacing'
:'off'
,// 生成器函式*的前後空格
'no-debugger'
: process.env.
node_env
==='production'
?'error'
:'off'
,// 禁止使用debugger
quotes:[2
,'single'],
'prettier/prettier':[
'error',,
],},
};
vue.js的官方eslint外掛程式
vue專案 安裝eslint校驗
eslint 風格校驗 step 1 安裝npm i eslint eslint config standard eslint plugin standard eslint plugin promise eslint plugin import eslint plugin node d.eslint...
vue 使用eslint開發專案
1 安裝 npm i eslint eslint config standard eslint plugin standard eslint plugin promise eslint plugin import eslint plugin node d2 建立.eslintrc,這樣就可以檢測 了...
vue 關掉vue專案中的ESlint
在新建專案的時候,還信心滿滿的要標準開發,於是開啟了eslint 檢測,後來才發現,想法的太天真,空格縮排不對都要報錯,而且我對錯誤是0容忍。並且一般都是用外掛程式對 進行格式化,但還是很多錯誤,實在不想一遍遍去排查,於是找了找資料,關掉專案中eslint 但是eslint也有可取之處。它可輔助規範...