Eslint在VScode中不起作用,但是在终端中起作用

奥列格

我有由rush(https://rushjs.io/管理的单一存储库

代码的结构为:

在此处输入图片说明

如您所见,有两个eslint配置和两个目录node_modules(它只是由rush创建的符号链接)。

Eslint可以完美地工作。

但是我在前面的eslint config遇到了一些麻烦。当我yarn eslint --ext .js --ext .jsx ./src从目录运行它时front,它可以工作。

但是,当eslint从vscode启动时,它不起作用。在输出中,我看到:

Consider running eslint --debug /Users/oleg/Desktop/projects/hire/front/src/pages/config.js from a terminal to obtain a trace about the configuration files used.
[Error - 2:04:08 PM] 
Failed to load plugin 'react' declared in 'front/.eslintrc': Cannot find module 'eslint-plugin-react'
Require stack:
- /Users/oleg/Desktop/projects/hire/__placeholder__.js
Referenced from: /Users/oleg/Desktop/projects/hire/front/.eslintrc
Happened while validating /Users/oleg/Desktop/projects/hire/front/src/pages/config.js
This can happen for a couple of reasons:
1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
2. If ESLint is installed globally, then make sure 'eslint-plugin-react' is installed globally as well.
3. If ESLint is installed locally, then 'eslint-plugin-react' isn't installed correctly.

eslint-plugin-react 已经在front / package.json中安装并定义

您有什么想法,为什么eslint无法工作?

PS Eslint配置:

{
  "parser": "babel-eslint",
  "extends": [
    "airbnb",
    "plugin:react/recommended"
  ],
  "env": {
    "browser": true,
    "node": true,
    "jest": true,
    "es6": true
  },
  "plugins": [
    "react",
    "jsx-a11y"
  ],
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    "newline-before-return": "error",
    "newline-after-var": "error",
    "arrow-parens": [
      "error",
      "always"
    ],
    "arrow-body-style": [
      2,
      "as-needed"
    ],
    "comma-dangle": [
      2,
      "always-multiline"
    ],
    "import/imports-first": 0,
    "import/newline-after-import": 0,
    "import/no-extraneous-dependencies": 0,
    "import/no-named-as-default": 0,
    "import/no-unresolved": 2,
    "import/prefer-default-export": 0,
    "indent": [
      2,
      2,
      {
        "SwitchCase": 1
      }
    ],
    "max-len": 0,
    "newline-per-chained-call": 0,
    "no-confusing-arrow": 0,
    "no-console": 1,
    "no-use-before-define": 0,
    "prefer-template": 2,
    "class-methods-use-this": 0,
    "react/forbid-prop-types": 0,
    "react/jsx-first-prop-new-line": [
      2,
      "multiline"
    ],
    "react/jsx-no-target-blank": 0,
    "react/require-extension": 0,
    "react/self-closing-comp": 0,
    "react/display-name": 0,
    "require-yield": 0,
    "import/no-webpack-loader-syntax": 0,
    "react/prop-types": [
      0
    ]
  },
  "settings": {
    "babel-plugin-root-import": {
      "rootPathPrefix": "~/",
      "rootPathSuffix": "src/"
    }, 
    "import/resolver": {
      "webpack": {
        "config": "./webpack/webpack.prod.js"
      }
    }    
  },
  "globals": {
    "CONFIG": true
  }
}
Mykybo

添加到工作区设置:

{
    "eslint.workingDirectories": [
        "back",
        "front"
    ]
}

并可能:

{
    "eslint.workingDirectories": [
        { 
            "directory": "front", 
            "changeProcessCWD": true
        }
    ]
}

问题在于vscode / eslint在哪里寻找依赖关系。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

内部联接在PHP中不起作用,但是在phpMyAdmin SQL中起作用

我的反应状态在函数中不起作用,但是在呈现时起作用

getUserMedia()在普通Chrome中不起作用,但是在启动pwa-chrome时起作用

Eslint 在 Sublime Text 3 或终端中不起作用

集成Powershell内核在vscode终端中不起作用

在php中执行sql查询不起作用,但是在phpmyadmin中执行查询

在python2中可以,但是在python3中不起作用

为什么console.log在JSC环境中不起作用,但是在Safari的调试控制台中起作用

为什么此功能不起作用,但是在Eclipse中却不显示错误?

ForEach在mongodb上不起作用,但是在本地数组声明中可以正常工作

Python脚本在crontab中不起作用,但是在没有

我想做样式表,但是在PHP中不起作用

Jar不起作用,但是程序在IDE中起作用

experimentalObjectRestSpread在ESLint中不起作用

Blackslash在终端中不起作用

javac在ubuntu终端中不起作用

终端命令在 PhpStorm 中不起作用

删除键在终端中不起作用

终端在WebStorm 9中不起作用

如果--help在终端中不起作用

Nautilus 的“在终端中打开”不起作用

在终端中运行不起作用

bs4:“ soup.title.string”在IDLE上不起作用,但是在终端上

VSCode中的全局搜索不起作用

代码不起作用。但是在调试时会

'.contains'在android手机中不起作用,但是在网页中可以正常工作

MongoDB(pymongo)$ avg和$ stdDevPop在$ project中不起作用,但是在$ group中它们可以完美地工作

从X导入Y在终端中起作用,但在从终端执行的脚本中不起作用

Laravel 4分页不起作用链接可以,但是在每个页面中显示所有结果