gpt4 book ai didi

reactjs - 'FC' 已定义但从未使用过。eslint(无未使用的变量)

转载 作者:行者123 更新时间:2023-12-01 21:45:18 24 4
gpt4 key购买 nike

我从 eslint 收到这个警告:

X 已定义但从未用于从 react 或 react-native 导入的每种类型。 FCViewProps 的示例(见下图)。

这是我的 .eslintrc.js:

module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: [
'airbnb',
"plugin:import/typescript",
],
parser: "@typescript-eslint/parser",
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'react',
],
rules: {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
"linebreak-style": 0,
"jsx-a11y/label-has-associated-control": ["error", {
"required": {
"some": ["nesting", "id"]
}
}],
"jsx-a11y/label-has-for": ["error", {
"required": {
"some": ["nesting", "id"]
}
}],
"react/jsx-props-no-spreading": [1, {
"custom": "ignore"
}],
},
};

enter image description here

enter image description here

最佳答案

解决了在 .eslintrc 中添加 'plugin:@typescript-eslint/recommended' 到 'extends' 数组的相同问题

此外,如果你需要它,我的扩展中有“plugin:react/recommended”和“airbnb”

关于reactjs - 'FC' 已定义但从未使用过。eslint(无未使用的变量),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60819425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com