Javascript eslint错误:加载规则时出错';react/jsx键';
在为下一个.js/typescript项目设置linting时,我遇到了这个问题。 每当我尝试运行Javascript eslint错误:加载规则时出错';react/jsx键';,javascript,reactjs,typescript,eslint,eslint-plugin-react,Javascript,Reactjs,Typescript,Eslint,Eslint Plugin React,在为下一个.js/typescript项目设置linting时,我遇到了这个问题。 每当我尝试运行npx eslint时--ext.ts、.tsx或VS代码中的eslint插件,我得到以下错误: Error: Error while loading rule 'react/jsx-key': Fragment pragma React.Fragment is not a valid identifier Occurred while linting ... 谷歌和stackoverflow搜索
npx eslint时--ext.ts、.tsx
或VS代码中的eslint插件,我得到以下错误:
Error: Error while loading rule 'react/jsx-key': Fragment pragma React.Fragment is not a valid identifier
Occurred while linting ...
谷歌和stackoverflow搜索没有给我任何东西(据我所知)
我正在运行eslint@7.10.0
和eslint插件-react@7.20.6
。两者都是本地安装的(但我也尝试了全局安装)
我还尝试重新安装我的node\u模块
我的eslintrc
如下所示:
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
"ecmaFeatures": {
"jsx": true
},
},
plugins: ['@typescript-eslint', 'react'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'prettier',
'prettier/@typescript-eslint',
],
settings: {
react: {
createClass: 'createReactClass', // Regex for Component Factory to use,
// default to "createReactClass"
pragma: 'React', // Pragma to use, default to "React"
fragment: 'React.Fragment', // Fragment to use, default to "React.Fragment"
version: 'detect', // React version. "detect" automatically picks the version you have installed.
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
// default to latest and warns if missing
// It will default to "detect" in the future
flowVersion: '0.53', // Flow version
},
propWrapperFunctions: [
// The names of any function used to wrap propTypes, e.g. `forbidExtraProps`. If this isn't set, any propTypes wrapped in a function will be skipped.
'forbidExtraProps',
{
property: 'freeze',
object: 'Object',
},
{
property: 'myFavoriteWrapper',
},
],
linkComponents: [
// Components used as alternatives to <a> for linking, eg. <Link to={ url } />
'Hyperlink',
{
name: 'Link',
linkAttribute: 'to',
},
],
},
};
module.exports={
根:是的,
解析器:“@typescript eslint/parser”,
解析选项:{
tsconfigRootDir:uuu dirname,
项目:['./tsconfig.json'],
“ecmaFeatures”:{
“jsx”:正确
},
},
插件:['@typescript eslint','react'],
扩展:[
“eslint:推荐”,
'插件:@typescript eslint/推荐',
'插件:@typescript eslint/建议需要进行类型检查',
'插件:反应/推荐',
'插件:反应挂钩/推荐',
“更漂亮”,
'prettier/@typescript eslint',
],
设置:{
反应:{
createClass:'createReactClass',//组件工厂要使用的正则表达式,
//默认为“createReactClass”
pragma:'React',//要使用的pragma,默认为“React”
fragment:'React.fragment',//要使用的片段,默认为“React.fragment”
版本:'detect',//React version。“detect”自动选择您安装的版本。
//如果要覆盖检测到的值,还可以使用“16.0”、“16.3”等。
//默认为“最新”,如果缺少,则发出警告
//它将在将来默认为“检测”
flowVersion:'0.53',//流版本
},
PropWrapper函数:[
//用于包装propTypes的任何函数的名称,例如“禁止ExtraProps”。如果未设置该名称,则将跳过包装在函数中的任何propTypes。
"道具",,
{
属性:“冻结”,
对象:“对象”,
},
{
属性:“myFavoriteWrapper”,
},
],
链接组件:[
//用作链接替代品的组件,例如。
“超级链接”,
{
名称:'链接',
linkAttribute:'到',
},
],
},
};
我觉得我正在运行一个非常标准的设置,所以有人知道问题可能出在哪里吗
提前谢谢大家