vscode報錯,不符和eslint規范,保存時單引號變雙引號,代碼尾部分號和逗號自動去除


具體參照:https://www.jianshu.com/p/3cfd91231cc7

在項目根目錄下新建.prettierrc(prettier插件的配置文件)文件,在文件中寫入:

{
  "semi": true,//在代碼尾部添加分號
  "singleQuote": true,//把雙引號換成單引號
  "trailingComma": "es5"//在代碼尾部添加逗號
}

在.eslintrc.js(eslint插件的配置文件)文件中的rules屬性中添加:

'no-unused-vars': 'warn',//把該條提示信息轉換成警告信息

我的.eslintrc.js配置:

module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: ['plugin:vue/essential', '@vue/standard'],
  parserOptions: {
    parser: 'babel-eslint',
  },
  rules: {
    indent: ['off', 2],
    'no-tabs': 'off',
    semi: [0],
    'no-mixed-spaces-and-tabs': [0],
    singleQuote: 0,
    'space-before-function-paren': 0,
    'no-unused-vars': 'warn', //把該條提示信息轉換成警告信息
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  },
};

 

Prettier 代碼格式化插件 -- 配置翻譯:

參考:https://www.jianshu.com/p/4be58a69b20f


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM