简体   繁体   English

在通过Yarn管理的VSCode中使用自定义eslint配置文件

[英]Use custom eslint config file in VSCode that is managed via Yarn

I have eslint installed and running in VSCode, but it is not using our config file. 我在VSCode中安装并运行了eslint,但它没有使用我们的配置文件。

The settings I have changed are 我改变的设置是

{
  "eslint.nodePath": "C:\\Users\\PARAGON\\Documents\\AllCode\\ParagonCore\\clients\\utilities\\paragon-scripts\\node_modules",
  "eslint.options": {
    "configFile": "C:\\Users\\PARAGON\\Documents\\AllCode\\ParagonCore\\clients\\utilities\\paragon-scripts\\configuration\\.eslintrc.js",
  },
  "eslint.packageManager": "yarn",
}

UPDATE: 更新:

modified nodePath and fixed file path mistake 修改了nodePath和修复文件路径错误

[Info  - 12:30:26 PM] ESLint library loaded from: 
C:\Users\PARAGON\AppData\Local\Yarn\config\global\node_modules\eslint\lib\api.js
[Error - 12:30:26 PM] Cannot read config file: C:\Users\PARAGON\Documents\AllCode\Paragon\ParagonCore\clients\utilities\paragon-scripts\configuration\.eslintrc.js Error: Cannot find module 'C:\Users\PARAGON\Documents\AllCode\Paragon\ParagonCore\clients\utilities\paragon-scripts\configuration\.eslintrc.js'
[Error - 12:32:56 PM] 
Failed to load plugin react: Cannot find module 'eslint-plugin-react'
Happened while validating C:\Users\PARAGON\Documents\AllCode\ParagonCore\clients\job-grid\source\scripts\components\AssignToUser.jsx
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.

Consider running eslint --debug C:\Users\PARAGON\Documents\AllCode\ParagonCore\clients\job-grid\source\scripts\components\AssignToUser.jsx from a terminal to obtain a 
trace about the configuration files used.

Failed to load plugin react: Cannot find module 'eslint-plugin-react'
Happened while validating C:\Users\PARAGON\Documents\AllCode\ParagonCore\clients\job-grid\source\scripts\components\controls\CreateJob.jsx
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.

Consider running eslint --debug 
C:\Users\PARAGON\Documents\AllCode\ParagonCore\clients\job-
grid\source\scripts\components\controls\CreateJob.jsx from a terminal to 
obtain a trace about the configuration files used.

First, make sure you do not have the package installed globally. 首先,确保您没有全局安装软件包。 Then, set "eslint.nodePath" to the location of your node_modules directory that is parallel to the configuration directory. 然后,将"eslint.nodePath"设置为与配置目录并行的node_modules目录的位置。

  1. yarn global remove eslint
  2. "eslint.nodePath": "C:/.../node_modules"
  3. open some files and look for "ESLint library loaded from:" in the Output window 打开一些文件并在“输出”窗口中查找“从:加载的ESLint库”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM