gpt4 book ai didi

react-native - .eslintrc.js 不适用于规则 "off"

转载 作者:行者123 更新时间:2023-12-05 07:31:39 25 4
gpt4 key购买 nike

native 并且在配置 eslint 时遇到问题。这是我的 .eslintrc.js。

module.exports = {
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"jest": true,
},
"plugins": [
"react",
"node"
],
"rules": {
"no-use-before-define": "off",
"react/jsx-filename-extension": "off",
"node/no-unsupported-features/es-syntax": ["error", {
"version": ">=6.0.0",
"ignores": ["modules", "destructuring"]
}],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/prop-types": "off",
}
};

在 App.js 中,

const { navigation } = this.props;

我收到了 eslint 错误。

[eslint] Destructuring are not supported yet on Node 4.0.0. (node/no-unsupported-features) 
[eslint] 'navigation' is missing in props validation (react/prop-types)

还有在 App.js 中,

<View style={styles.container}>
<UpArrow title="cancel" />
<SecondsSpinner seconds={this.state.imageTime} changeImageTime={this.changeImageTime} />
<DownArrow title="save" />
</View>

我遇到了错误

[eslint] JSX not allowed in files with extension '.js' (react/jsx-filename-extension)

所以我

  • 关闭“react/prop-types”,
  • 设置“react/jsx-filename-extension”: [1, { "extensions": [".js", ".jsx"] }]
  • 设置“忽略”:[“解构”]。

但它们不起作用。我不知道为什么以及如何解决这个问题。是否有任何其他文件来配置 eslint?提前致谢。

EDIT1) "ignores": ["modules"] 有效。好奇怪。

EDIT2) 我正在使用 vscode 并在编辑器上不断出现错误,所以我认为是因为 .eslintrc 文件。但是现在我认为是vscode的问题。我设置了

"eslint.options": { "configFile": "/Users/com/vscode/AwesomeProject/.eslintrc.js" } 

在 Workspace Settings 中就可以了

最佳答案

尝试:

module.exports = {
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"jest": true,
},
"plugins": [
"react",
"node"
],
"rules": {
"no-use-before-define": 0,
"react/jsx-filename-extension": 0,
"node/no-unsupported-features/es-syntax": ["error", {
"version": ">=6.0.0",
"ignores": ["modules", "destructuring"]
}],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/prop-types": 0,
}
};

关于react-native - .eslintrc.js 不适用于规则 "off",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51719879/

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