我从eslint收到此警告:
X已定义,但从未用于从react或react-native导入的每种类型。使用FC
和ViewProps
的示例(请参见下图)。
这是我的.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"
}],
},
};
答案 0 :(得分:3)
解决了将'plugin:@ typescript-eslint / recommended'添加到.eslintrc中的'extends'数组的相同问题
此外,如果您需要它,我的扩展程序中还会提供“ plugin:react / recommended”和“ airbnb”