JSX 不允许在扩展名为“.js”的文件中使用 eslint-config-Airbnb
2022-08-30 04:03:25
						我已经安装了 eslint-config-Airbnb 它应该为 React 预先配置 ESLINT:
我们的默认导出包含我们所有的 ESLint 规则,包括 ECMAScript 6+ 和 React。它需要 eslint、eslint-plugin-import、eslint-plugin-react 和 eslint-plugin-jsx-a11y。
我的扩展其配置:.eslintrc
{ "extends": "eslint-config-airbnb",
  "env": {
    "browser": true,
    "node": true,
    "mocha": true
  },
  "rules": {
    "new-cap": [2, { "capIsNewExceptions": ["List", "Map", "Set"] }],
    "react/no-multi-comp": 0,
    "import/default": 0,
    "import/no-duplicates": 0,
    "import/named": 0,
    "import/namespace": 0,
    "import/no-unresolved": 0,
    "import/no-named-as-default": 2,
    "comma-dangle": 0,  // not sure why airbnb turned this on. gross!
    "indent": [2, 2, {"SwitchCase": 1}],
    "no-console": 0,
    "no-alert": 0,
    "linebreak-style": 0
  },
  "plugins": [
    "react", "import"
  ],
  "settings": {
    "import/parser": "babel-eslint",
    "import/resolve": {
      "moduleDirectory": ["node_modules", "src"]
    }
  },
  "globals": {
    "__DEVELOPMENT__": true,
    "__CLIENT__": true,
    "__SERVER__": true,
    "__DISABLE_SSR__": true,
    "__DEVTOOLS__": true,
    "socket": true,
    "webpackIsomorphicTools": true
  }
}
不幸的是,当我在其中使用React JSX代码.js文件时,我收到以下错误:
 error  JSX not allowed in files with extension '.js'              react/jsx-filename-extension
如前所述,eslint-config-Airbnb配置的反应不是已经支持JSX了吗?
应该做些什么来消除该错误?
 
					 
				 
				    		 
				    		 
				    		 
				    		