【发布时间】:2017-11-10 06:09:03
【问题描述】:
查看 import/no-named-as-default eslint 规则的文档后,我仍然对自己做错了什么感到困惑。
我有以下文件结构
.
├── ButtonBack.css
├── ButtonBack.jsx
├── __tests__
│ └── ButtonBack.test.jsx
└── index.js
ButtonBack.jsx 包含以下代码
import React from 'react';
import PropTypes from 'prop-types';
export default class ButtonBack extends React.Component {
... code removed to keep example short ...
}
__tests__/ButtonBack.test.jsx 包含以下代码
import React from 'react';
import { shallow } from 'enzyme';
import ButtonBack from '../ButtonBack'; // <== this line has an eslint warning
... code removed to keep example short ...
问题是,我的 linter 说 import ButtonBack from '../ButtonBack 违反了以下 lint 规则:
我不明白为什么我的 import 语句违反了 lint 规则。删除 ButtonBack.jsx (export default class extends React.Component) 中的类名称也不能解决问题。
【问题讨论】:
-
ButtonBack.jsx中还有其他的exports,还是只有export default class ButtonBack? -
只有一个出口。
-
您是否找到了解决方案,还是您只是禁用了该规则?
-
我刚刚禁用了规则。 ??????
-
这个 ESLint 规则很烂
标签: javascript eslint es6-modules