问题描述
在为我的next.js / typescript项目设置棉绒时,我遇到了这个问题。
每当我尝试在VS Code中运行npx eslint . --ext .ts,.tsx
或eslint插件时,都会出现此错误:
Error: Error while loading rule 'react/jsx-key': Fragment pragma React.Fragment is not a valid identifier
Occurred while linting ...
Google和stackoverflow搜索都没有给我任何帮助(据我所知)。
我正在运行eslint@7.10.0
和eslint-plugin-react@7.20.6
。两者都在本地安装(但我也尝试了全局安装)。
我还尝试重新安装node_modules
。
我的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',};
我觉得我正在运行一个非常标准的设置,所以有人知道问题可能在哪里吗?
谢谢大家!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)