我正在使用 create-react-app 构建一个 React 应用程序。
运行 ESLint 时出现以下错误:
8:3 error 'document' is not defined no-undef.
我的应用程序运行没有错误,但我在 2 个文件中遇到了这个 ESLint 错误。查看这些.jsx
文件之一和我的 ESLint 配置。
索引.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
}
};
我怎样才能解决这个问题 ?目前我将简单地忽略这两个文件......但我宁愿找到一个长期的解决方案。