Description
I've been really interested in using the import/no-unused-modules
rule in one of my React projects, but it seems to be incorrectly reporting an error when it sees the export { default } from 'foo'
syntax:
/usr/src/app/app/pages/About/index.js
1:1 error exported declaration 'default' not used within other modules import/no-unused-modules
It's been a bit tricky for me to reproduce with a smaller example, as it seems to be somewhat reliant on the Babel and Webpack plugins, but I have been able to produce a branch of my project with 95% of the files removed and still demonstrate the issue. I think I've gotten the problem narrowed to the following four files in that branch:
//==============================================================================
// app/init.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import Routes from './routes';
ReactDOM.render((
<BrowserRouter>
<Routes />
</BrowserRouter>
), document.getElementById('root'));
//==============================================================================
// app/routes.jsx
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import About from './pages/About';
export default () => (
<Switch>
<Route path="/about" component={About} />
</Switch>
);
//==============================================================================
// app/pages/About/index.js
export { default } from './About';
//==============================================================================
// app/pages/About/About.jsx
import React from 'react';
export default class About extends React.Component {
render() {
return (
<article>
<header>
About the SF Service Guide
</header>
</article>
);
}
}
Any help I could get with this would be greatly appreciated. If there's a way for me to dump out extra logging information, I'd be willing to attach it here.
Here are the versions of relevant packages, and you can check out the package.json in the branch I linked to for the full details:
- eslint-plugin-import@2.20.0
- @babel/core@7.4.4
- webpack@4.17.4
On the branch I linked to, you should be able to reproduce the problem with the following commands:
git clone https://github.com/ShelterTechSF/askdarcel-web.git -b test-unused-modules
cd askdarcel-web
npm install
npm run lint