From 4d32d68558e3cc995ddbdffc30c96d10a634f6fe Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:47:59 -0400 Subject: [PATCH 01/18] [New] TypeScript config: add .cts and .mts extensions --- CHANGELOG.md | 7 ++++++- config/typescript.js | 11 +++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d5b23d828..cd7a4380a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ## [Unreleased] +### Added +- TypeScript config: add .cts and .mts extensions ([#2851], thanks [@Zamiell]) + ## [2.28.1] - 2023-08-18 ### Fixed @@ -1088,6 +1091,7 @@ for info on changes for earlier releases. [`memo-parser`]: ./memo-parser/README.md [#2854]: https://github.com/import-js/eslint-plugin-import/pull/2854 +[#2851]: https://github.com/import-js/eslint-plugin-import/pull/2851 [#2850]: https://github.com/import-js/eslint-plugin-import/pull/2850 [#2842]: https://github.com/import-js/eslint-plugin-import/pull/2842 [#2835]: https://github.com/import-js/eslint-plugin-import/pull/2835 @@ -1896,4 +1900,5 @@ for info on changes for earlier releases. [@xpl]: https://github.com/xpl [@yndajas]: https://github.com/yndajas [@yordis]: https://github.com/yordis -[@zloirock]: https://github.com/zloirock +[@Zamiell]: https://github.com/Zamiell +[@zloirock]: https://github.com/zloirock \ No newline at end of file diff --git a/config/typescript.js b/config/typescript.js index 9fd789dbf7..ff7d0795c8 100644 --- a/config/typescript.js +++ b/config/typescript.js @@ -1,19 +1,22 @@ /** - * Adds `.jsx`, `.ts` and `.tsx` as an extension, and enables JSX/TSX parsing. + * This config: + * 1) adds `.jsx`, `.ts`, `.cts`, `.mts`, and `.tsx` as an extension + * 2) enables JSX/TSX parsing */ // Omit `.d.ts` because 1) TypeScript compilation already confirms that // types are resolved, and 2) it would mask an unresolved // `.ts`/`.tsx`/`.js`/`.jsx` implementation. -const allExtensions = ['.ts', '.tsx', '.js', '.jsx']; +const typeScriptExtensions = ['.ts', '.cts', '.mts', '.tsx']; -module.exports = { +const allExtensions = [...typeScriptExtensions, '.js', '.jsx']; +module.exports = { settings: { 'import/extensions': allExtensions, 'import/external-module-folders': ['node_modules', 'node_modules/@types'], 'import/parsers': { - '@typescript-eslint/parser': ['.ts', '.tsx'], + '@typescript-eslint/parser': typeScriptExtensions, }, 'import/resolver': { node: { From 04e68a2179c17b6b73b0c589ca8c092cdb1cb1e5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 18 Aug 2023 16:24:35 -0700 Subject: [PATCH 02/18] [resolvers/webpack] [fix] use the `dirname` of the `configPath` as `basedir` Fixes #2859 --- resolvers/webpack/CHANGELOG.md | 2 ++ resolvers/webpack/index.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/resolvers/webpack/CHANGELOG.md b/resolvers/webpack/CHANGELOG.md index 457cd36ed4..bd567c4cb5 100644 --- a/resolvers/webpack/CHANGELOG.md +++ b/resolvers/webpack/CHANGELOG.md @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). This change log adheres to standards from [Keep a CHANGELOG](https://keepachangelog.com). ## Unreleased + - [fix] use the `dirname` of the `configPath` as `basedir` ([#2859]) ## 0.13.6 - 2023-08-16 - [refactor] revert back to `lodash/isEqual` @@ -197,6 +198,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange [#181]: https://github.com/import-js/eslint-plugin-import/pull/181 [#164]: https://github.com/import-js/eslint-plugin-import/pull/164 +[#2859]: https://github.com/import-js/eslint-plugin-import/issues/2859 [#2268]: https://github.com/import-js/eslint-plugin-import/issues/2268 [#1219]: https://github.com/import-js/eslint-plugin-import/issues/1219 [#788]: https://github.com/import-js/eslint-plugin-import/issues/788 diff --git a/resolvers/webpack/index.js b/resolvers/webpack/index.js index 1eea7d7ab5..ebd77af1ed 100644 --- a/resolvers/webpack/index.js +++ b/resolvers/webpack/index.js @@ -183,7 +183,7 @@ function createResolveSync(configPath, webpackConfig, cwd) { if (typeof configPath === 'string') { // This can be changed via the settings passed in when defining the resolver - basedir = cwd || configPath; + basedir = cwd || path.dirname(configPath); log(`Attempting to load webpack path from ${basedir}`); } From 6b95a021938139726b3f862beb37012d6e2afab2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 19 Aug 2023 10:37:28 -0700 Subject: [PATCH 03/18] [resolvers/webpack] v0.13.7 --- resolvers/webpack/CHANGELOG.md | 2 ++ resolvers/webpack/package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/resolvers/webpack/CHANGELOG.md b/resolvers/webpack/CHANGELOG.md index bd567c4cb5..99746c7706 100644 --- a/resolvers/webpack/CHANGELOG.md +++ b/resolvers/webpack/CHANGELOG.md @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). This change log adheres to standards from [Keep a CHANGELOG](https://keepachangelog.com). ## Unreleased + +## 0.13.7 - 2023-08-19 - [fix] use the `dirname` of the `configPath` as `basedir` ([#2859]) ## 0.13.6 - 2023-08-16 diff --git a/resolvers/webpack/package.json b/resolvers/webpack/package.json index c3363611b0..28a6184f7c 100644 --- a/resolvers/webpack/package.json +++ b/resolvers/webpack/package.json @@ -1,6 +1,6 @@ { "name": "eslint-import-resolver-webpack", - "version": "0.13.6", + "version": "0.13.7", "description": "Resolve paths to dependencies, given a webpack.config.js. Plugin for eslint-plugin-import.", "main": "index.js", "scripts": { From 87051212306f8cd08cb62555b94fae259146468c Mon Sep 17 00:00:00 2001 From: Anix Date: Tue, 27 Oct 2020 14:20:05 +0000 Subject: [PATCH 04/18] [New] `newline-after-import`: new option `exactCount` and docs update Fixes #1901. Fixes #514. Co-authored-by: Anix Co-authored-by: reosarevok --- CHANGELOG.md | 3 +- docs/rules/newline-after-import.md | 91 +++++++++++++++----- src/rules/newline-after-import.js | 17 +++- tests/src/rules/newline-after-import.js | 108 ++++++++++++++++++++++++ 4 files changed, 193 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd7a4380a6..567ed26459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ### Added - TypeScript config: add .cts and .mts extensions ([#2851], thanks [@Zamiell]) +- [`newline-after-import`]: new option `exactCount` and docs update ([#1933], thanks [@anikethsaha] and [@reosarevok]) ## [2.28.1] - 2023-08-18 @@ -1901,4 +1902,4 @@ for info on changes for earlier releases. [@yndajas]: https://github.com/yndajas [@yordis]: https://github.com/yordis [@Zamiell]: https://github.com/Zamiell -[@zloirock]: https://github.com/zloirock \ No newline at end of file +[@zloirock]: https://github.com/zloirock diff --git a/docs/rules/newline-after-import.md b/docs/rules/newline-after-import.md index fec6b23aca..ef5aeed767 100644 --- a/docs/rules/newline-after-import.md +++ b/docs/rules/newline-after-import.md @@ -12,70 +12,119 @@ This rule supports the following options: - `count` which sets the number of newlines that are enforced after the last top-level import statement or require call. This option defaults to `1`. + - `exactCount` which enforce the exact numbers of newlines that is mentioned in `count`. This option defaults to `false`. + - `considerComments` which enforces the rule on comments after the last import-statement as well when set to true. This option defaults to `false`. Valid: ```js -import defaultExport from './foo' +import defaultExport from './foo'; -const FOO = 'BAR' +const FOO = 'BAR'; ``` ```js -import defaultExport from './foo' -import { bar } from 'bar-lib' +import defaultExport from './foo'; +import { bar } from 'bar-lib'; -const FOO = 'BAR' +const FOO = 'BAR'; ``` ```js -const FOO = require('./foo') -const BAR = require('./bar') +const FOO = require('./foo'); +const BAR = require('./bar'); -const BAZ = 1 +const BAZ = 1; ``` Invalid: ```js import * as foo from 'foo' -const FOO = 'BAR' +const FOO = 'BAR'; ``` ```js -import * as foo from 'foo' -const FOO = 'BAR' +import * as foo from 'foo'; +const FOO = 'BAR'; -import { bar } from 'bar-lib' +import { bar } from 'bar-lib'; ``` ```js -const FOO = require('./foo') -const BAZ = 1 -const BAR = require('./bar') +const FOO = require('./foo'); +const BAZ = 1; +const BAR = require('./bar'); ``` With `count` set to `2` this will be considered valid: ```js -import defaultExport from './foo' +import defaultExport from './foo'; -const FOO = 'BAR' +const FOO = 'BAR'; +``` + +```js +import defaultExport from './foo'; + + + +const FOO = 'BAR'; ``` With `count` set to `2` these will be considered invalid: ```js -import defaultExport from './foo' -const FOO = 'BAR' +import defaultExport from './foo'; +const FOO = 'BAR'; ``` ```js -import defaultExport from './foo' +import defaultExport from './foo'; -const FOO = 'BAR' +const FOO = 'BAR'; +``` + +With `count` set to `2` and `exactCount` set to `true` this will be considered valid: + +```js +import defaultExport from './foo'; + + +const FOO = 'BAR'; +``` + +With `count` set to `2` and `exactCount` set to `true` these will be considered invalid: + +```js +import defaultExport from './foo'; +const FOO = 'BAR'; +``` + +```js +import defaultExport from './foo'; + +const FOO = 'BAR'; +``` + +```js +import defaultExport from './foo'; + + + +const FOO = 'BAR'; +``` + +```js +import defaultExport from './foo'; + + + + +const FOO = 'BAR'; ``` With `considerComments` set to `false` this will be considered valid: diff --git a/src/rules/newline-after-import.js b/src/rules/newline-after-import.js index 8855e26e52..9b469110be 100644 --- a/src/rules/newline-after-import.js +++ b/src/rules/newline-after-import.js @@ -69,6 +69,7 @@ module.exports = { type: 'integer', minimum: 1, }, + exactCount: { type: 'boolean' }, considerComments: { type: 'boolean' }, }, additionalProperties: false, @@ -78,7 +79,12 @@ module.exports = { create(context) { let level = 0; const requireCalls = []; - const options = { count: 1, considerComments: false, ...context.options[0] }; + const options = { + count: 1, + exactCount: false, + considerComments: false, + ...context.options[0], + }; function checkForNewLine(node, nextNode, type) { if (isExportDefaultClass(nextNode) || isExportNameClass(nextNode)) { @@ -94,7 +100,10 @@ module.exports = { const lineDifference = getLineDifference(node, nextNode); const EXPECTED_LINE_DIFFERENCE = options.count + 1; - if (lineDifference < EXPECTED_LINE_DIFFERENCE) { + if ( + lineDifference < EXPECTED_LINE_DIFFERENCE + || options.exactCount && lineDifference !== EXPECTED_LINE_DIFFERENCE + ) { let column = node.loc.start.column; if (node.loc.start.line !== node.loc.end.line) { @@ -107,7 +116,7 @@ module.exports = { column, }, message: `Expected ${options.count} empty line${options.count > 1 ? 's' : ''} after ${type} statement not followed by another ${type}.`, - fix: (fixer) => fixer.insertTextAfter( + fix: options.exactCount && EXPECTED_LINE_DIFFERENCE < lineDifference ? undefined : (fixer) => fixer.insertTextAfter( node, '\n'.repeat(EXPECTED_LINE_DIFFERENCE - lineDifference), ), @@ -132,7 +141,7 @@ module.exports = { column, }, message: `Expected ${options.count} empty line${options.count > 1 ? 's' : ''} after import statement not followed by another import.`, - fix: (fixer) => fixer.insertTextAfter( + fix: options.exactCount && EXPECTED_LINE_DIFFERENCE < lineDifference ? undefined : (fixer) => fixer.insertTextAfter( node, '\n'.repeat(EXPECTED_LINE_DIFFERENCE - lineDifference), ), diff --git a/tests/src/rules/newline-after-import.js b/tests/src/rules/newline-after-import.js index 8f3338eee8..bd11da4191 100644 --- a/tests/src/rules/newline-after-import.js +++ b/tests/src/rules/newline-after-import.js @@ -46,6 +46,16 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), { parserOptions: { ecmaVersion: 6 }, options: [{ considerComments: true }], }, + { + code: ` + const x = () => require('baz') && require('bar') + + // Some random single line comment + var bar = 42; + `, + parserOptions: { ecmaVersion: 6 }, + options: [{ considerComments: true, count: 1, exactCount: true }], + }, { code: ` const x = () => require('baz') && require('bar') @@ -122,6 +132,21 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), { parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, options: [{ count: 2 }], }, + { + code: `import foo from 'foo';\n\n\nvar bar = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 2, exactCount: true }], + }, + { + code: `import foo from 'foo';\n\nvar bar = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 1, exactCount: true }], + }, + { + code: `import foo from 'foo';\n\n\nvar bar = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 1 }], + }, { code: `import foo from 'foo';\n\n\n\n\nvar bar = 'bar';`, parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, @@ -141,6 +166,11 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), { parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, options: [{ count: 4 }], }, + { + code: `var foo = require('foo-module');\n\n\n\n\nvar foo = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 4, exactCount: true }], + }, { code: `require('foo-module');\n\nvar foo = 'bar';`, parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, @@ -620,5 +650,83 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), { parserOptions: { sourceType: 'module' }, parser: parsers.BABEL_OLD, })) || [], + { + code: `import foo from 'foo';\n\nexport default function() {};`, + output: `import foo from 'foo';\n\n\nexport default function() {};`, + options: [{ count: 2, exactCount: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE_MULTIPLE(2), + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, + { + code: `import foo from 'foo';\n\n\n\nexport default function() {};`, + output: `import foo from 'foo';\n\n\n\nexport default function() {};`, + options: [{ count: 2, exactCount: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE_MULTIPLE(2), + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, + { + code: `import foo from 'foo';\n\n\n\n\nexport default function() {};`, + output: `import foo from 'foo';\n\n\n\n\nexport default function() {};`, + options: [{ count: 2, exactCount: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE_MULTIPLE(2), + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, + { + code: ` + import foo from 'foo'; + + + // Some random single line comment + var bar = 42; + `, + output: ` + import foo from 'foo'; + + + // Some random single line comment + var bar = 42; + `, + errors: [{ + line: 2, + column: 9, + message: IMPORT_ERROR_MESSAGE, + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ considerComments: true, count: 1, exactCount: true }], + }, + { + code: `import foo from 'foo';export default function() {};`, + output: `import foo from 'foo';\n\nexport default function() {};`, + options: [{ count: 1, exactCount: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE, + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, + { + code: `const foo = require('foo');\n\n\n\nconst bar = function() {};`, + output: `const foo = require('foo');\n\n\n\nconst bar = function() {};`, + options: [{ count: 2, exactCount: true }], + errors: [{ + line: 1, + column: 1, + message: 'Expected 2 empty lines after require statement not followed by another require.', + }], + parserOptions: { ecmaVersion: 2015 }, + }, ), }); From 66cb10f302a23c0b72c4a3ead26374a6729a9017 Mon Sep 17 00:00:00 2001 From: Kinland <16787581+kinland@users.noreply.github.com> Date: Mon, 25 Sep 2023 19:16:00 -0700 Subject: [PATCH 05/18] [Fix] `newline-after-import`: fix `exactCount` with `considerComments` false positive, when there is a leading comment Fixes #2882. --- CHANGELOG.md | 5 +- src/rules/newline-after-import.js | 2 +- tests/src/rules/newline-after-import.js | 133 ++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 567ed26459..6af7f748a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ### Added - TypeScript config: add .cts and .mts extensions ([#2851], thanks [@Zamiell]) - [`newline-after-import`]: new option `exactCount` and docs update ([#1933], thanks [@anikethsaha] and [@reosarevok]) +- [`newline-after-import`]: fix `exactCount` with `considerComments` false positive, when there is a leading comment ([#2884], thanks [@kinland]) ## [2.28.1] - 2023-08-18 @@ -1091,6 +1092,7 @@ for info on changes for earlier releases. [`memo-parser`]: ./memo-parser/README.md +[#2884]: https://github.com/import-js/eslint-plugin-import/pull/2884 [#2854]: https://github.com/import-js/eslint-plugin-import/pull/2854 [#2851]: https://github.com/import-js/eslint-plugin-import/pull/2851 [#2850]: https://github.com/import-js/eslint-plugin-import/pull/2850 @@ -1769,6 +1771,7 @@ for info on changes for earlier releases. [@kentcdodds]: https://github.com/kentcdodds [@kevin940726]: https://github.com/kevin940726 [@kgregory]: https://github.com/kgregory +[@kinland]: https://github.com/kinland [@kirill-konshin]: https://github.com/kirill-konshin [@kiwka]: https://github.com/kiwka [@klimashkin]: https://github.com/klimashkin @@ -1776,8 +1779,8 @@ for info on changes for earlier releases. [@knpwrs]: https://github.com/knpwrs [@KostyaZgara]: https://github.com/KostyaZgara [@kylemh]: https://github.com/kylemh -[@laysent]: https://github.com/laysent [@laurens-dg]: https://github.com/laurens-dg +[@laysent]: https://github.com/laysent [@le0nik]: https://github.com/le0nik [@leipert]: https://github.com/leipert [@lemonmade]: https://github.com/lemonmade diff --git a/src/rules/newline-after-import.js b/src/rules/newline-after-import.js index 9b469110be..a33bb615b9 100644 --- a/src/rules/newline-after-import.js +++ b/src/rules/newline-after-import.js @@ -169,7 +169,7 @@ module.exports = { let nextComment; if (typeof parent.comments !== 'undefined' && options.considerComments) { - nextComment = parent.comments.find((o) => o.loc.start.line === endLine + 1); + nextComment = parent.comments.find((o) => o.loc.start.line >= endLine && o.loc.start.line <= endLine + options.count + 1); } // skip "export import"s diff --git a/tests/src/rules/newline-after-import.js b/tests/src/rules/newline-after-import.js index bd11da4191..6a8fb83e40 100644 --- a/tests/src/rules/newline-after-import.js +++ b/tests/src/rules/newline-after-import.js @@ -142,6 +142,31 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), { parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, options: [{ count: 1, exactCount: true }], }, + { + code: `import foo from 'foo';\n\n// Some random comment\nvar bar = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 2, exactCount: true }], + }, + { + code: `import foo from 'foo';\n// Some random comment\nvar bar = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 1, exactCount: true }], + }, + { + code: `import foo from 'foo';\n\n\n// Some random comment\nvar bar = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 2, exactCount: true, considerComments: true }], + }, + { + code: `import foo from 'foo';\n\n// Some random comment\nvar bar = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 1, exactCount: true, considerComments: true }], + }, + { + code: `/**\n * A leading comment\n */\nimport foo from 'foo';\n\n// Some random comment\nexport {foo};`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 2, exactCount: true }], + }, { code: `import foo from 'foo';\n\n\nvar bar = 'bar';`, parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, @@ -171,6 +196,16 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), { parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, options: [{ count: 4, exactCount: true }], }, + { + code: `var foo = require('foo-module');\n\n// Some random comment\n\n\nvar foo = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 4, exactCount: true }], + }, + { + code: `var foo = require('foo-module');\n\n\n\n// Some random comment\nvar foo = 'bar';`, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ count: 4, exactCount: true, considerComments: true }], + }, { code: `require('foo-module');\n\nvar foo = 'bar';`, parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, @@ -683,6 +718,72 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), { }], parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, }, + { + code: `import foo from 'foo';\n// some random comment\nexport default function() {};`, + output: `import foo from 'foo';\n\n// some random comment\nexport default function() {};`, + options: [{ count: 2, exactCount: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE_MULTIPLE(2), + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, + { + code: `import foo from 'foo';\n// some random comment\n\n\nexport default function() {};`, + output: `import foo from 'foo';\n// some random comment\n\n\nexport default function() {};`, + options: [{ count: 2, exactCount: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE_MULTIPLE(2), + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, + { + code: `import foo from 'foo';\n// some random comment\n\n\n\nexport default function() {};`, + output: `import foo from 'foo';\n// some random comment\n\n\n\nexport default function() {};`, + options: [{ count: 2, exactCount: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE_MULTIPLE(2), + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, + { + code: `import foo from 'foo';\n// some random comment\nexport default function() {};`, + output: `import foo from 'foo';\n\n\n// some random comment\nexport default function() {};`, + options: [{ count: 2, exactCount: true, considerComments: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE_MULTIPLE(2), + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, + { + code: `import foo from 'foo';\n\n// some random comment\nexport default function() {};`, + output: `import foo from 'foo';\n\n\n// some random comment\nexport default function() {};`, + options: [{ count: 2, exactCount: true, considerComments: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE_MULTIPLE(2), + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, + { + code: `import foo from 'foo';\n\n\n\n// some random comment\nexport default function() {};`, + output: `import foo from 'foo';\n\n\n\n// some random comment\nexport default function() {};`, + options: [{ count: 2, exactCount: true, considerComments: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE_MULTIPLE(2), + }], + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + }, { code: ` import foo from 'foo'; @@ -728,5 +829,37 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), { }], parserOptions: { ecmaVersion: 2015 }, }, + { + code: `const foo = require('foo');\n\n\n\n// some random comment\nconst bar = function() {};`, + output: `const foo = require('foo');\n\n\n\n// some random comment\nconst bar = function() {};`, + options: [{ count: 2, exactCount: true }], + errors: [{ + line: 1, + column: 1, + message: 'Expected 2 empty lines after require statement not followed by another require.', + }], + parserOptions: { ecmaVersion: 2015 }, + }, + { + code: `import foo from 'foo';// some random comment\nexport default function() {};`, + output: `import foo from 'foo';\n\n// some random comment\nexport default function() {};`, + options: [{ count: 1, exactCount: true, considerComments: true }], + errors: [{ + line: 1, + column: 1, + message: IMPORT_ERROR_MESSAGE, + }], + parserOptions: { ecmaVersion: 2015, considerComments: true, sourceType: 'module' }, + }, + { + code: `const foo = require('foo');\n\n\n// some random comment\nconst bar = function() {};`, + options: [{ count: 2, exactCount: true, considerComments: true }], + errors: [{ + line: 1, + column: 1, + message: 'Expected 2 empty lines after require statement not followed by another require.', + }], + parserOptions: { ecmaVersion: 2015 }, + }, ), }); From 2c281d15d06dc54c90cfa5c28b276b189ecd8f3f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 22 Oct 2023 22:25:32 -0700 Subject: [PATCH 06/18] [resolvers/webpack] [refactor] use `hasown` instead of `has` --- resolvers/webpack/index.js | 4 ++-- resolvers/webpack/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resolvers/webpack/index.js b/resolvers/webpack/index.js index ebd77af1ed..3ca2874dd8 100644 --- a/resolvers/webpack/index.js +++ b/resolvers/webpack/index.js @@ -9,7 +9,7 @@ const fs = require('fs'); const isCore = require('is-core-module'); const resolve = require('resolve/sync'); const semver = require('semver'); -const has = require('has'); +const hasOwn = require('hasown'); const isRegex = require('is-regex'); const log = require('debug')('eslint-plugin-import:resolver:webpack'); @@ -382,7 +382,7 @@ function findExternal(source, externals, context, resolveSync) { // else, vanilla object for (const key in externals) { - if (!has(externals, key)) { continue; } + if (!hasOwn(externals, key)) { continue; } if (source === key) { return true; } } return false; diff --git a/resolvers/webpack/package.json b/resolvers/webpack/package.json index 28a6184f7c..0810ca70dd 100644 --- a/resolvers/webpack/package.json +++ b/resolvers/webpack/package.json @@ -34,7 +34,7 @@ "debug": "^3.2.7", "enhanced-resolve": "^0.9.1", "find-root": "^1.1.0", - "has": "^1.0.3", + "hasown": "^2.0.0", "interpret": "^1.4.0", "is-core-module": "^2.13.0", "is-regex": "^1.1.4", From 30d61b6dc45e712899a4b9184964a948251adfcf Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 22 Oct 2023 22:26:45 -0700 Subject: [PATCH 07/18] [resolvers/webpack] [deps] update `array.prototype.find`, `is-core-module`, `resolve` --- resolvers/webpack/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resolvers/webpack/package.json b/resolvers/webpack/package.json index 0810ca70dd..b348b6e2bb 100644 --- a/resolvers/webpack/package.json +++ b/resolvers/webpack/package.json @@ -30,16 +30,16 @@ }, "homepage": "https://github.com/import-js/eslint-plugin-import/tree/HEAD/resolvers/webpack", "dependencies": { - "array.prototype.find": "^2.2.1", + "array.prototype.find": "^2.2.2", "debug": "^3.2.7", "enhanced-resolve": "^0.9.1", "find-root": "^1.1.0", "hasown": "^2.0.0", "interpret": "^1.4.0", - "is-core-module": "^2.13.0", + "is-core-module": "^2.13.1", "is-regex": "^1.1.4", "lodash": "^4.17.21", - "resolve": "^2.0.0-next.4", + "resolve": "^2.0.0-next.5", "semver": "^5.7.2" }, "peerDependencies": { From 6d2540f2eefc063d07a841088836e1dcee652cd9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 22 Oct 2023 22:28:03 -0700 Subject: [PATCH 08/18] [resolvers/webpack] v0.13.8 --- resolvers/webpack/CHANGELOG.md | 5 +++++ resolvers/webpack/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/resolvers/webpack/CHANGELOG.md b/resolvers/webpack/CHANGELOG.md index 99746c7706..4fed046b46 100644 --- a/resolvers/webpack/CHANGELOG.md +++ b/resolvers/webpack/CHANGELOG.md @@ -5,6 +5,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ## Unreleased +## 0.13.8 - 2023-10-22 + - [refactor] use `hasown` instead of `has` + - [deps] update `array.prototype.find`, `is-core-module`, `resolve` + + ## 0.13.7 - 2023-08-19 - [fix] use the `dirname` of the `configPath` as `basedir` ([#2859]) diff --git a/resolvers/webpack/package.json b/resolvers/webpack/package.json index b348b6e2bb..3fa47d9362 100644 --- a/resolvers/webpack/package.json +++ b/resolvers/webpack/package.json @@ -1,6 +1,6 @@ { "name": "eslint-import-resolver-webpack", - "version": "0.13.7", + "version": "0.13.8", "description": "Resolve paths to dependencies, given a webpack.config.js. Plugin for eslint-plugin-import.", "main": "index.js", "scripts": { From 78f50b852a0dc187ccbfd6b4592e4f59ba78d339 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 22 Oct 2023 23:08:13 -0700 Subject: [PATCH 09/18] [Deps] update `array-includes`, `array.prototype.findlastindex`, `array.prototype.flat`, `array.prototype.flatmap`, `eslint-import-resolver-node`, `is-core-module`, `object.fromentries`, `object.groupby`, `object.values` --- package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 6128a4e76b..2fdc9c4c2f 100644 --- a/package.json +++ b/package.json @@ -103,21 +103,21 @@ "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" }, "dependencies": { - "array-includes": "^3.1.6", - "array.prototype.findlastindex": "^1.2.2", - "array.prototype.flat": "^1.3.1", - "array.prototype.flatmap": "^1.3.1", + "array-includes": "^3.1.7", + "array.prototype.findlastindex": "^1.2.3", + "array.prototype.flat": "^1.3.2", + "array.prototype.flatmap": "^1.3.2", "debug": "^3.2.7", "doctrine": "^2.1.0", - "eslint-import-resolver-node": "^0.3.7", + "eslint-import-resolver-node": "^0.3.9", "eslint-module-utils": "^2.8.0", "has": "^1.0.3", - "is-core-module": "^2.13.0", + "is-core-module": "^2.13.1", "is-glob": "^4.0.3", "minimatch": "^3.1.2", - "object.fromentries": "^2.0.6", - "object.groupby": "^1.0.0", - "object.values": "^1.1.6", + "object.fromentries": "^2.0.7", + "object.groupby": "^1.0.1", + "object.values": "^1.1.7", "semver": "^6.3.1", "tsconfig-paths": "^3.14.2" } From ec6a8ea3c386241daaf208fe78da151b30415357 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 22 Oct 2023 23:08:57 -0700 Subject: [PATCH 10/18] [Refactor] use `hasown` instead of `has` --- package.json | 2 +- src/rules/no-anonymous-default-export.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2fdc9c4c2f..1d9acd4f2b 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.9", "eslint-module-utils": "^2.8.0", - "has": "^1.0.3", + "hasown": "^2.0.0", "is-core-module": "^2.13.1", "is-glob": "^4.0.3", "minimatch": "^3.1.2", diff --git a/src/rules/no-anonymous-default-export.js b/src/rules/no-anonymous-default-export.js index 59a3cbfdac..4f6947e814 100644 --- a/src/rules/no-anonymous-default-export.js +++ b/src/rules/no-anonymous-default-export.js @@ -3,7 +3,7 @@ * @author Duncan Beevers */ -import has from 'has'; +import hasOwn from 'hasown'; import values from 'object.values'; import fromEntries from 'object.fromentries'; @@ -65,7 +65,7 @@ const schemaProperties = fromEntries(values(defs).map((def) => [def.option, { type: 'boolean', }])); -const defaults = fromEntries(values(defs).map((def) => [def.option, has(def, 'default') ? def.default : false])); +const defaults = fromEntries(values(defs).map((def) => [def.option, hasOwn(def, 'default') ? def.default : false])); module.exports = { meta: { From 6d34c88a91a9cb7556700b7cb83c8a27731ff302 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 22 Oct 2023 23:12:22 -0700 Subject: [PATCH 11/18] Bump to 2.29.0 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6af7f748a4..bc3fc1918d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ## [Unreleased] +## [2.29.0] - 2023-10-22 + ### Added - TypeScript config: add .cts and .mts extensions ([#2851], thanks [@Zamiell]) - [`newline-after-import`]: new option `exactCount` and docs update ([#1933], thanks [@anikethsaha] and [@reosarevok]) @@ -1554,7 +1556,8 @@ for info on changes for earlier releases. [#119]: https://github.com/import-js/eslint-plugin-import/issues/119 [#89]: https://github.com/import-js/eslint-plugin-import/issues/89 -[Unreleased]: https://github.com/import-js/eslint-plugin-import/compare/v2.28.1...HEAD +[Unreleased]: https://github.com/import-js/eslint-plugin-import/compare/v2.29.0...HEAD +[2.29.0]: https://github.com/import-js/eslint-plugin-import/compare/v2.28.1...v2.29.0 [2.28.1]: https://github.com/import-js/eslint-plugin-import/compare/v2.28.0...v2.28.1 [2.28.0]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.5...v2.28.0 [2.27.5]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.4...v2.27.5 diff --git a/package.json b/package.json index 1d9acd4f2b..bd92f4f692 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-import", - "version": "2.28.1", + "version": "2.29.0", "description": "Import with sanity.", "engines": { "node": ">=4" From 12f0300100b9bb90c6a952d07c133f2d5842ad57 Mon Sep 17 00:00:00 2001 From: Noureldin Shaker <43860275+Pandemic1617@users.noreply.github.com> Date: Tue, 7 Nov 2023 15:37:39 +0000 Subject: [PATCH 12/18] [Fix] `no-extraneous-dependencies`: ignore `export type { ... } from '...'` when `includeTypes` is false --- CHANGELOG.md | 5 +++++ src/rules/no-extraneous-dependencies.js | 1 + tests/src/rules/no-extraneous-dependencies.js | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc3fc1918d..f902dec7f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ## [Unreleased] +### Fixed +- [`no-extraneous-dependencies`]: ignore `export type { ... } from '...'` when `includeTypes` is `false` ([#2919], thanks [@Pandemic1617]) + ## [2.29.0] - 2023-10-22 ### Added @@ -1094,6 +1097,7 @@ for info on changes for earlier releases. [`memo-parser`]: ./memo-parser/README.md +[#2919]: https://github.com/import-js/eslint-plugin-import/pull/2919 [#2884]: https://github.com/import-js/eslint-plugin-import/pull/2884 [#2854]: https://github.com/import-js/eslint-plugin-import/pull/2854 [#2851]: https://github.com/import-js/eslint-plugin-import/pull/2851 @@ -1830,6 +1834,7 @@ for info on changes for earlier releases. [@ntdb]: https://github.com/ntdb [@nwalters512]: https://github.com/nwalters512 [@ombene]: https://github.com/ombene +[@Pandemic1617]: https://github.com/Pandemic1617 [@ota-meshi]: https://github.com/ota-meshi [@OutdatedVersion]: https://github.com/OutdatedVersion [@panrafal]: https://github.com/panrafal diff --git a/src/rules/no-extraneous-dependencies.js b/src/rules/no-extraneous-dependencies.js index 0408e0866d..df97987901 100644 --- a/src/rules/no-extraneous-dependencies.js +++ b/src/rules/no-extraneous-dependencies.js @@ -177,6 +177,7 @@ function reportIfMissing(context, deps, depsOptions, node, name) { && ( node.importKind === 'type' || node.importKind === 'typeof' + || node.exportKind === 'type' || Array.isArray(node.specifiers) && node.specifiers.length && node.specifiers.every((specifier) => specifier.importKind === 'type' || specifier.importKind === 'typeof') ) ) { diff --git a/tests/src/rules/no-extraneous-dependencies.js b/tests/src/rules/no-extraneous-dependencies.js index 21561615c6..cb0398ada2 100644 --- a/tests/src/rules/no-extraneous-dependencies.js +++ b/tests/src/rules/no-extraneous-dependencies.js @@ -427,6 +427,18 @@ describe('TypeScript', () => { options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }], ...parserConfig, }), + + test({ + code: 'import type { T } from "a"; export type { T };', + options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }], + ...parserConfig, + }), + + test({ + code: 'export type { T } from "a";', + options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }], + ...parserConfig, + }), ], invalid: [ test({ From 9fd3c42707d71987e439a847f2e213f55c84f734 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 24 Nov 2023 21:29:58 -0800 Subject: [PATCH 13/18] [Tests] `no-duplicates`: add passing test Closes #2840 --- tests/src/rules/no-duplicates.js | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/src/rules/no-duplicates.js b/tests/src/rules/no-duplicates.js index d61fda86e1..f83221105a 100644 --- a/tests/src/rules/no-duplicates.js +++ b/tests/src/rules/no-duplicates.js @@ -482,6 +482,68 @@ import {x,y} from './foo' errors: ["'../constants' imported multiple times.", "'../constants' imported multiple times."], ...jsxConfig, }), + + test({ + code: ` + import {A1,} from 'foo'; + import {B1,} from 'foo'; + import {C1,} from 'foo'; + + import { + A2, + } from 'bar'; + import { + B2, + } from 'bar'; + import { + C2, + } from 'bar'; + + `, + output: ` + import {A1,B1,C1} from 'foo'; + ${''} + import { + A2, + ${''} + B2, + C2} from 'bar'; + ${''} + `, + errors: [ + { + message: "'foo' imported multiple times.", + line: 2, + column: 27, + }, + { + message: "'foo' imported multiple times.", + line: 3, + column: 27, + }, + { + message: "'foo' imported multiple times.", + line: 4, + column: 27, + }, + { + message: "'bar' imported multiple times.", + line: 8, + column: 16, + }, + { + message: "'bar' imported multiple times.", + line: 11, + column: 16, + }, + { + message: "'bar' imported multiple times.", + line: 14, + column: 16, + }, + ], + ...jsxConfig, + }), ], }); From e67259e4c167d46e9cc5472d3afa32369fbf2eff Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 3 Dec 2023 22:32:42 -0800 Subject: [PATCH 14/18] [Fix] `no-unused-modules`: support export patterns with array destructuring Fixes #2930 --- CHANGELOG.md | 3 +++ src/rules/no-unused-modules.js | 5 +++++ tests/src/rules/no-unused-modules.js | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f902dec7f0..a56216a7a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ### Fixed - [`no-extraneous-dependencies`]: ignore `export type { ... } from '...'` when `includeTypes` is `false` ([#2919], thanks [@Pandemic1617]) +- [`no-unused-modules`]: support export patterns with array destructuring ([#2930], thanks [@ljharb]) ## [2.29.0] - 2023-10-22 @@ -1435,6 +1436,8 @@ for info on changes for earlier releases. [#211]: https://github.com/import-js/eslint-plugin-import/pull/211 [#164]: https://github.com/import-js/eslint-plugin-import/pull/164 [#157]: https://github.com/import-js/eslint-plugin-import/pull/157 + +[#2930]: https://github.com/import-js/eslint-plugin-import/issues/2930 [#2687]: https://github.com/import-js/eslint-plugin-import/issues/2687 [#2684]: https://github.com/import-js/eslint-plugin-import/issues/2684 [#2674]: https://github.com/import-js/eslint-plugin-import/issues/2674 diff --git a/src/rules/no-unused-modules.js b/src/rules/no-unused-modules.js index ecba3a19ce..8229d880ce 100644 --- a/src/rules/no-unused-modules.js +++ b/src/rules/no-unused-modules.js @@ -74,6 +74,7 @@ const FUNCTION_DECLARATION = 'FunctionDeclaration'; const CLASS_DECLARATION = 'ClassDeclaration'; const IDENTIFIER = 'Identifier'; const OBJECT_PATTERN = 'ObjectPattern'; +const ARRAY_PATTERN = 'ArrayPattern'; const TS_INTERFACE_DECLARATION = 'TSInterfaceDeclaration'; const TS_TYPE_ALIAS_DECLARATION = 'TSTypeAliasDeclaration'; const TS_ENUM_DECLARATION = 'TSEnumDeclaration'; @@ -97,6 +98,10 @@ function forEachDeclarationIdentifier(declaration, cb) { cb(pattern.name); } }); + } else if (id.type === ARRAY_PATTERN) { + id.elements.forEach(({ name }) => { + cb(name); + }); } else { cb(id.name); } diff --git a/tests/src/rules/no-unused-modules.js b/tests/src/rules/no-unused-modules.js index 77fb608ccb..9aa5ce53d7 100644 --- a/tests/src/rules/no-unused-modules.js +++ b/tests/src/rules/no-unused-modules.js @@ -160,6 +160,15 @@ ruleTester.run('no-unused-modules', rule, { filename: testFilePath('./no-unused-modules/file-o.js'), parser: parsers.BABEL_OLD, }), + test({ + options: unusedExportsOptions, + code: ` + export const [o0, o2] = createLoadingAndErrorSelectors( + AUTH_USER + ); + `, + filename: testFilePath('./no-unused-modules/file-o.js'), + }), ], invalid: [ test({ From 8c83eafe4a709c0c275279a7bf99d92fa4e034a5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 4 Dec 2023 08:28:05 -0800 Subject: [PATCH 15/18] [Tests] node v21.3 has a broken `fs.writeFile` See https://github.com/nodejs/node/pull/50990 / https://github.com/nodejs/node/issues/50989 --- tests/src/rules/no-unused-modules.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/src/rules/no-unused-modules.js b/tests/src/rules/no-unused-modules.js index 9aa5ce53d7..b09d5d759c 100644 --- a/tests/src/rules/no-unused-modules.js +++ b/tests/src/rules/no-unused-modules.js @@ -732,7 +732,7 @@ describe('renameDefault', () => { describe('test behavior for new file', () => { before(() => { - fs.writeFileSync(testFilePath('./no-unused-modules/file-added-0.js'), '', { encoding: 'utf8' }); + fs.writeFileSync(testFilePath('./no-unused-modules/file-added-0.js'), '', { encoding: 'utf8', flag: 'w' }); }); // add import in newly created file @@ -840,7 +840,7 @@ describe('test behavior for new file', () => { describe('test behavior for new file', () => { before(() => { - fs.writeFileSync(testFilePath('./no-unused-modules/file-added-1.js'), '', { encoding: 'utf8' }); + fs.writeFileSync(testFilePath('./no-unused-modules/file-added-1.js'), '', { encoding: 'utf8', flag: 'w' }); }); ruleTester.run('no-unused-modules', rule, { valid: [ @@ -875,7 +875,7 @@ describe('test behavior for new file', () => { describe('test behavior for new file', () => { before(() => { - fs.writeFileSync(testFilePath('./no-unused-modules/file-added-2.js'), '', { encoding: 'utf8' }); + fs.writeFileSync(testFilePath('./no-unused-modules/file-added-2.js'), '', { encoding: 'utf8', flag: 'w' }); }); ruleTester.run('no-unused-modules', rule, { valid: [ @@ -901,7 +901,7 @@ describe('test behavior for new file', () => { describe('test behavior for new file', () => { before(() => { - fs.writeFileSync(testFilePath('./no-unused-modules/file-added-3.js'), '', { encoding: 'utf8' }); + fs.writeFileSync(testFilePath('./no-unused-modules/file-added-3.js'), '', { encoding: 'utf8', flag: 'w' }); }); ruleTester.run('no-unused-modules', rule, { valid: [ @@ -952,7 +952,7 @@ describe('test behavior for destructured exports', () => { describe('test behavior for new file', () => { before(() => { - fs.writeFileSync(testFilePath('./no-unused-modules/file-added-4.js.js'), '', { encoding: 'utf8' }); + fs.writeFileSync(testFilePath('./no-unused-modules/file-added-4.js.js'), '', { encoding: 'utf8', flag: 'w' }); }); ruleTester.run('no-unused-modules', rule, { valid: [ From 80aee736721397cd073636950fef30aa65e165d3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 14 Dec 2023 10:36:00 -0800 Subject: [PATCH 16/18] [Dev Deps] update `chai`, `eslint-doc-generator`, `markdownlint-cli` --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index bd92f4f692..b899f56919 100644 --- a/package.json +++ b/package.json @@ -69,11 +69,11 @@ "babel-preset-flow": "^6.23.0", "babel-register": "^6.26.0", "babylon": "^6.18.0", - "chai": "^4.3.7", + "chai": "^4.3.10", "cross-env": "^4.0.0", "escope": "^3.6.0", "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8", - "eslint-doc-generator": "^1.4.3", + "eslint-doc-generator": "^1.6.1", "eslint-import-resolver-node": "file:./resolvers/node", "eslint-import-resolver-typescript": "^1.0.2 || ^1.1.1", "eslint-import-resolver-webpack": "file:./resolvers/webpack", @@ -88,7 +88,7 @@ "jackspeak": "=2.1.1", "linklocal": "^2.8.2", "lodash.isarray": "^4.0.0", - "markdownlint-cli": "^0.35.0", + "markdownlint-cli": "^0.38.0", "mocha": "^3.5.3", "npm-which": "^3.0.1", "nyc": "^11.9.0", From 48fec35fbe9d20f5c859a02d0e4acef70759c875 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 14 Dec 2023 10:37:05 -0800 Subject: [PATCH 17/18] [Deps] update `tsconfig-paths` Thanks to https://github.com/dividab/tsconfig-paths/pull/260! Closes #2447. Fixes #2652. Fixes #2890. Fixes #2751. May help with #2617, #2765. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b899f56919..b84f57e8e4 100644 --- a/package.json +++ b/package.json @@ -119,6 +119,6 @@ "object.groupby": "^1.0.1", "object.values": "^1.1.7", "semver": "^6.3.1", - "tsconfig-paths": "^3.14.2" + "tsconfig-paths": "^3.15.0" } } From ee5fadeffff68f2300bed7f67a310496cb969d61 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 14 Dec 2023 10:54:28 -0800 Subject: [PATCH 18/18] Bump to 2.29.1 --- CHANGELOG.md | 8 +++++++- package.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a56216a7a6..b81ad61a61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,12 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ## [Unreleased] +## [2.29.1] - 2023-12-14 + ### Fixed - [`no-extraneous-dependencies`]: ignore `export type { ... } from '...'` when `includeTypes` is `false` ([#2919], thanks [@Pandemic1617]) - [`no-unused-modules`]: support export patterns with array destructuring ([#2930], thanks [@ljharb]) +- [Deps] update `tsconfig-paths` ([#2447], thanks [@domdomegg]) ## [2.29.0] - 2023-10-22 @@ -1445,6 +1448,7 @@ for info on changes for earlier releases. [#2666]: https://github.com/import-js/eslint-plugin-import/issues/2666 [#2665]: https://github.com/import-js/eslint-plugin-import/issues/2665 [#2577]: https://github.com/import-js/eslint-plugin-import/issues/2577 +[#2447]: https://github.com/import-js/eslint-plugin-import/issues/2447 [#2444]: https://github.com/import-js/eslint-plugin-import/issues/2444 [#2412]: https://github.com/import-js/eslint-plugin-import/issues/2412 [#2392]: https://github.com/import-js/eslint-plugin-import/issues/2392 @@ -1563,7 +1567,8 @@ for info on changes for earlier releases. [#119]: https://github.com/import-js/eslint-plugin-import/issues/119 [#89]: https://github.com/import-js/eslint-plugin-import/issues/89 -[Unreleased]: https://github.com/import-js/eslint-plugin-import/compare/v2.29.0...HEAD +[Unreleased]: https://github.com/import-js/eslint-plugin-import/compare/v2.29.1...HEAD +[2.29.1]: https://github.com/import-js/eslint-plugin-import/compare/v2.29.0...v2.29.1 [2.29.0]: https://github.com/import-js/eslint-plugin-import/compare/v2.28.1...v2.29.0 [2.28.1]: https://github.com/import-js/eslint-plugin-import/compare/v2.28.0...v2.28.1 [2.28.0]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.5...v2.28.0 @@ -1715,6 +1720,7 @@ for info on changes for earlier releases. [@devinrhode2]: https://github.com/devinrhode2 [@devongovett]: https://github.com/devongovett [@dmnd]: https://github.com/dmnd +[@domdomegg]: https://github.com/domdomegg [@duncanbeevers]: https://github.com/duncanbeevers [@dwardu]: https://github.com/dwardu [@echenley]: https://github.com/echenley diff --git a/package.json b/package.json index b84f57e8e4..5c0af48543 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-import", - "version": "2.29.0", + "version": "2.29.1", "description": "Import with sanity.", "engines": { "node": ">=4"