①在頁面的根目錄創建一個文件夾 這個文件叫 [ .prettierrc ] 的格式化配置項文件, 文件內容的格式是json格式的
{ // 把 true 改成 false 這樣在格式化代碼的時候 就不會額外添加 分號了 "semi": false, // singleQuote 代表單引號的意思 true 表示啟用單引號 "singleQuote": true }
禁用某項eslint規則:
在項目目錄打開 .eslintrc.js 文件
在rules對象添加報錯的屬性,並設置為0,表示禁用該項。
一般在報錯的error: 后面有個括號,把括號中的內容粘貼過來,放在reels中。
案例:
在項目目錄打開 .eslintrc.js 文件
在rules對象添加報錯的屬性,並設置為0,表示禁用該項。
一般在報錯的error: 后面有個括號,把括號中的內容粘貼過來,放在reels中。
案例:
Failed to compile. ./src/components/Login.vue Module Error (from ./node_modules/.pnpm/registry.npm.taobao.org/eslint-loader/2.2.1_eslint@5.16.0+webpack@4.41.2/node_modules/eslint-loader/index.js): error: Extra semicolon (semi) at src/components/Login.vue:54:51:
以這個報錯為例: error 后面的括號中有個 semi 把這個semi復制一下,打開項目根目錄的.eslintrc.js 文件
module.exports = { root: true, env: { node: true }, 'extends': [ 'plugin:vue/essential', '@vue/standard' ], rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', }, parserOptions: { parser: 'babel-eslint' } }
這里的rules,在后面添加一行 'semi':0
module.exports = { root: true, env: { node: true }, 'extends': [ 'plugin:vue/essential', '@vue/standard' ], rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'semi':0 }, parserOptions: { parser: 'babel-eslint' } }
這樣就可以禁用某項eslint語法檢測。