天天看點

error: No ESLint configuration found

ESLint使用的時候報錯:error: No ESLint configuration found

問題描述:在新項目送出後,同僚下載下傳最新代碼說我送出的代碼格式有問題,發現是ESLint插件沒有下載下傳,下載下傳啟動後校驗規則還是不對,而且報錯找不到相關配置。

解決辦法:1.如果項目中能找到.eslintrc.js則修改相關配置和檢測規則,詳細規則見連結: ESLint規則說明

2.如果項目中不存在,則按照如下配置新增.eslintrc.js檔案

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

module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint'
  },
  env: {
    browser: true,
    es6: true,
    node: 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: [
    'vue'
  ],
  // 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'
  }
}

           

繼續閱讀