【发布时间】:2021-10-17 19:28:05
【问题描述】:
我对 eslint 有疑问。它不适用于 VS 代码(React 项目)中的 app.js,但它适用于其他项目文件..所有配置文件都是正确的,并且 ESLint 库已从项目文件夹中正确加载..请放心关于这个问题。提前致谢。
[Info - 11:58:44 AM] ESLint 服务器正在启动 [Info - 11:58:44 AM] 在节点 v14.16.0 中运行的 ESLint 服务器 [Info - 11:58:44 AM] ESLint 服务器正在运行。 [信息 - 上午 11:58:45] ESLint 库从以下位置加载: ///Documents/todo/node_modules/eslint/lib/api.js
我的 .eslintrc.js
module.exports = {
env: {
browser: true,
es6: true,
},
extends: [
'plugin:react/recommended',
'airbnb',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'react',
],
rules: {
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
'react/prop-types': 'off',
},
};
【问题讨论】:
-
我认为问题与vscode有关,与eslint无关
-
请试试这个
eslint . --ext .js命令并发送结果,如果你得到nothing或类似<count> problem的东西,那么你的eslint 工作正常 -
谢谢,@NishargShah 我尝试了
eslint . --ext .js并在终端中遇到了一些错误......但我不明白为什么 eslint 只能通过终端使用此文件,但同时与其他文件完美配合项目文件。
标签: reactjs visual-studio-code eslint