From 3f46ccfe203fa5aad5767699df339a9b2f0294e3 Mon Sep 17 00:00:00 2001 From: Filipp Riabchun Date: Tue, 19 May 2020 20:21:07 +0200 Subject: [PATCH] Revert "[flow] `no-unused-modules`: add flow type support" This reverts commit 05085bbd --- CHANGELOG.md | 5 +++- src/rules/no-unused-modules.js | 7 ++---- tests/files/no-unused-modules/flow-0.js | 1 - tests/files/no-unused-modules/flow-1.js | 2 -- tests/files/no-unused-modules/flow-2.js | 2 -- tests/src/rules/no-unused-modules.js | 32 ------------------------- 6 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 tests/files/no-unused-modules/flow-0.js delete mode 100644 tests/files/no-unused-modules/flow-1.js delete mode 100644 tests/files/no-unused-modules/flow-2.js diff --git a/CHANGELOG.md b/CHANGELOG.md index de430cf59..c6e9ec975 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]) @@ -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 @@ -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 diff --git a/src/rules/no-unused-modules.js b/src/rules/no-unused-modules.js index 60416d21c..9d2d91a1b 100644 --- a/src/rules/no-unused-modules.js +++ b/src/rules/no-unused-modules.js @@ -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. @@ -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) } @@ -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) } diff --git a/tests/files/no-unused-modules/flow-0.js b/tests/files/no-unused-modules/flow-0.js deleted file mode 100644 index 46bda6879..000000000 --- a/tests/files/no-unused-modules/flow-0.js +++ /dev/null @@ -1 +0,0 @@ -import { type FooType } from './flow-2'; diff --git a/tests/files/no-unused-modules/flow-1.js b/tests/files/no-unused-modules/flow-1.js deleted file mode 100644 index bb7266d3c..000000000 --- a/tests/files/no-unused-modules/flow-1.js +++ /dev/null @@ -1,2 +0,0 @@ -// @flow strict -export type Bar = number; diff --git a/tests/files/no-unused-modules/flow-2.js b/tests/files/no-unused-modules/flow-2.js deleted file mode 100644 index 0cbb836a6..000000000 --- a/tests/files/no-unused-modules/flow-2.js +++ /dev/null @@ -1,2 +0,0 @@ -// @flow strict -export type FooType = string; diff --git a/tests/src/rules/no-unused-modules.js b/tests/src/rules/no-unused-modules.js index d409e41ed..a066dd33f 100644 --- a/tests/src/rules/no-unused-modules.js +++ b/tests/src/rules/no-unused-modules.js @@ -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: [