ESLint不会在未使用的变量上警告我,也不会在未导入的组件上发出警告。我尝试了所有的帖子,但我没有任何解决方案:/
免责声明:我知道我没有为example....Why导入导航栏ESLint没有警告我吗?谢谢!
.eslintrc.json
{
"env": {
"browser": true,
"es2020": true,
"node": true,
"jest": true
},
"extends": [
"standard",
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"prettier/@typescript-eslint",
"plugin:react-hooks/recommended",
"prettier/standard",
"prettier/react"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint", "prettier", "react-hooks"],
"rules": {
"no-unused-vars": "error",
"prettier/prettier": "error",
"space-before-function-paren": "off",
"react/prop-types": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"@typescript-eslint/no-empty-function": "off",
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": ["off"]
}
}
还有我的index.tsx
import React from 'react'
import Head from 'next/head'
const data = [
{ id: 1, name: 'artfol', url: 'http://google.com', alt: 'artfol' },
{ id: 2, name: 'FAQ', url: 'http://google.com', alt: 'FAQ' }
]
const Home: React.FC = () => {
return (
<div>
<Head>
<title>Create Next App</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<main>
<Navbar />
</main>
</div>
)
}
export default Home
发布于 2021-04-26 23:09:36
我找到了错误所在。Prettier合并了每个扩展到"prettier“中,所以我的代码看起来像这样
{
"env": {
"browser": true,
"es2021": true,
"node": true,
"jest": true
},
"extends": [
"plugin:react/recommended",
"standard",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"settings": {
"react": { "version": "detect" }
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint", "prettier"],
"rules": {
"prettier/prettier": "error",
"space-before-function-paren": "off",
"react/prop-types": "off"
}
}
同样eslint给我一个错误,由于反应未使用的var,所以我注释如下
// eslint-disable-next-line no-use-before-define
import React from 'react'https://stackoverflow.com/questions/67267467
复制相似问题