我正在用create-react-app构建一个React应用程序。未定义错误'文档':eslint/React
运行eslint时出现以下错误: 8:3错误'document'未定义no-undef。
下面是.jsx文件和我的eslint配置。 我的应用程序运行时没有错误,但是我在2个文件中得到了这个eslint错误。
index.jsx:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(
<App />,
document.getElementById('root'),
);
eslintrc.js:
module.exports = {
"extends": "airbnb",
"plugins": [
"react",
"jsx-a11y",
"import"
],
"env": {
"jest": true
}
};
我该如何解决这个问题?目前,我将忽略这两个文件......但我宁愿找到一个长期解决方案。
不知道为什么这不是谷歌的最佳结果。这绝对是解决方案。我没有意识到facebook反应测试脚本使用-env = jsdom命令行参数做了什么 – Steve
@Steve谢谢你的支持。很高兴帮助你! –