使eslint与eslint-plugin-vue一起工作时出错

时间:2018-04-17 23:42:25

标签: javascript eslint

我不是前端开发者,但我正试图在Rails 5.1应用程序中提取我的javascript / Vue.js文件。我对节点生态系统并不熟悉。我收到以下错误,想知道从哪里开始解决这个问题:

@admin.register(Course)
class CourseAdmin(admin.ModelAdmin):
    inlines = [
        ChapterInline,
    ]
    #...

我的.eslint.js文件是:

Tue Apr 17$ eslint javascript/ --ext .vue
Cannot find module 'eslint-plugin-vue'
Referenced from: /Users/jt/repos/embers2/.eslintrc.js
Error: Cannot find module 'eslint-plugin-vue'
Referenced from: /Users/jt/repos/embers2/.eslintrc.js
    at ModuleResolver.resolve (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/util/module-resolver.js:74:19)
    at resolve (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:466:29)
    at load (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:542:26)
    at configExtends.reduceRight (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:421:36)
    at Array.reduceRight (<anonymous>)
    at applyExtends (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:403:28)
    at loadFromDisk (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:514:22)
    at Object.load (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:550:20)
    at Config.getLocalConfigHierarchy (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config.js:228:44)
    at Config.getConfigHierarchy (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config.js:180:43)
Tue Apr 17$ 

我的package.json是:

module.exports = {
  extends: [
    // add more generic rulesets here, such as:
    // 'eslint:recommended',
    'plugin:vue/essential',
    'airbnb-base'

  ],
  rules: {
    // override/add rules settings here, such as:
    // 'vue/no-unused-vars': 'error'
  }
};

我从哪里开始调试这个?这个生态系统对我来说仍然是非常不透明的。

编辑#1

enter image description here

1 个答案:

答案 0 :(得分:0)

您需要按照以下说明在.vscode/settings.json中设置eslint工作目录

{
  "eslint.workingDirectories": [
    "./client",
  ]
}

在这里,./client路径是相对于您启动Visual Studio代码的位置,即项目根目录的位置

enter image description here