Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[flow] no-unused-modules: add flow type support" #1770

Merged
merged 1 commit into from May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -15,7 +15,8 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
- [`order`]: Recognize pathGroup config for first group ([#1719], [#1724], thanks [@forivall], [@xpl])
- [`no-unused-modules`]: Fix re-export not counting as usage when used in combination with import ([#1722], thanks [@Ephem])
- [`no-duplicates`]: Handle TS import type ([#1676], thanks [@kmui2])
- [``newline-after-import`: recognize decorators ([#1139], thanks [@atos1990])
- [`newline-after-import`]: recognize decorators ([#1139], thanks [@atos1990])
- [`no-unused-modules`]: Revert "[flow] `no-unused-modules`: add flow type support" ([#1770], thanks [@Hypnosphi])

### Changed
- TypeScript config: Disable [`named`][] ([#1726], thanks [@astorije])
Expand Down Expand Up @@ -675,6 +676,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#1770]: https://github.com/benmosher/eslint-plugin-import/issues/1770
[#1726]: https://github.com/benmosher/eslint-plugin-import/issues/1726
[#1724]: https://github.com/benmosher/eslint-plugin-import/issues/1724
[#1722]: https://github.com/benmosher/eslint-plugin-import/issues/1722
Expand Down Expand Up @@ -1156,3 +1158,4 @@ for info on changes for earlier releases.
[@kmui2]: https://github.com/kmui2
[@arvigeus]: https://github.com/arvigeus
[@atos1990]: https://github.com/atos1990
[@Hypnosphi]: https://github.com/Hypnosphi
7 changes: 2 additions & 5 deletions src/rules/no-unused-modules.js
Expand Up @@ -64,7 +64,6 @@ const VARIABLE_DECLARATION = 'VariableDeclaration'
const FUNCTION_DECLARATION = 'FunctionDeclaration'
const CLASS_DECLARATION = 'ClassDeclaration'
const DEFAULT = 'default'
const TYPE_ALIAS = 'TypeAlias'

/**
* List of imports per file.
Expand Down Expand Up @@ -563,8 +562,7 @@ module.exports = {
if (declaration) {
if (
declaration.type === FUNCTION_DECLARATION ||
declaration.type === CLASS_DECLARATION ||
declaration.type === TYPE_ALIAS
declaration.type === CLASS_DECLARATION
) {
newExportIdentifiers.add(declaration.id.name)
}
Expand Down Expand Up @@ -889,8 +887,7 @@ module.exports = {
if (node.declaration) {
if (
node.declaration.type === FUNCTION_DECLARATION ||
node.declaration.type === CLASS_DECLARATION ||
node.declaration.type === TYPE_ALIAS
node.declaration.type === CLASS_DECLARATION
) {
checkUsage(node, node.declaration.id.name)
}
Expand Down
1 change: 0 additions & 1 deletion tests/files/no-unused-modules/flow-0.js

This file was deleted.

2 changes: 0 additions & 2 deletions tests/files/no-unused-modules/flow-1.js

This file was deleted.

2 changes: 0 additions & 2 deletions tests/files/no-unused-modules/flow-2.js

This file was deleted.

32 changes: 0 additions & 32 deletions tests/src/rules/no-unused-modules.js
Expand Up @@ -680,38 +680,6 @@ describe('do not report unused export for files mentioned in package.json', () =
})
})

describe('correctly report flow types', () => {
ruleTester.run('no-unused-modules', rule, {
valid: [
test({
options: unusedExportsOptions,
code: 'import { type FooType } from "./flow-2";',
parser: require.resolve('babel-eslint'),
filename: testFilePath('./no-unused-modules/flow-0.js'),
}),
test({
options: unusedExportsOptions,
code: `// @flow strict
export type FooType = string;`,
parser: require.resolve('babel-eslint'),
filename: testFilePath('./no-unused-modules/flow-2.js'),
}),
],
invalid: [
test({
options: unusedExportsOptions,
code: `// @flow strict
export type Bar = string;`,
parser: require.resolve('babel-eslint'),
filename: testFilePath('./no-unused-modules/flow-1.js'),
errors: [
error(`exported declaration 'Bar' not used within other modules`),
],
}),
],
})
})

describe('Avoid errors if re-export all from umd compiled library', () => {
ruleTester.run('no-unused-modules', rule, {
valid: [
Expand Down