1. 程式人生 > >vue-eslint配置檔案

vue-eslint配置檔案

在vue的配置檔案.eslintrc.js中配置以下選項 這樣只需要右鍵格式化以下資料夾,大部分eslint規則報錯就會被幹掉了

// https://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint'
  },
  env: {
    browser: true,
  },
  extends: [
    // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. 'plugin:vue/essential', // https://github.com/standard/standard/blob/master/docs/RULES-en.md 'standard' ], // required to lint *.vue files plugins: [ 'html' ], // add your custom rules here
rules: { // allow async-await 'generator-star-spacing': 'off', // allow debugger during development 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', // js語句結尾必須使用 ; // 'semi': ['off', 'always'], 'semi': ['error', 'always'], // 三等號 'eqeqeq': 0, // 強制在註釋中 // 或 /* 使用一致的空格
'spaced-comment': 0, // 關鍵字後面使用一致的空格 'keyword-spacing': 0, // 強制在 function的左括號之前使用一致的空格 'space-before-function-paren': 0, // 引號型別 "quotes": [0, "single"], "vue/no-parsing-error": [2, { "x-invalid-end-tag": false }] } }

另外如果有些檔案不想被eslint檢測可以在.eslintignore資料夾中這樣配置

build/*
config/*
test/*
src/store/*
src/utils/*
src/router/*
src/personalCenter/view/orders/info.vue