From c273af363378f4172df6ea467b846559754c25a0 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 2 Jul 2023 18:53:21 +0800 Subject: [PATCH 01/12] Targets Node.js 12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 422b2ba70..ce0189081 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A fork of `eslint-plugin-import` using `get-tsconfig` to replace `tsconfig-paths` and heavy `typescript` under the hood.", "funding": "https://opencollective.com/unts", "engines": { - "node": ">=4" + "node": ">=12" }, "main": "lib/index.js", "directories": { From 59e3ba3865b1faa462eea96ba41bd061a12fcb29 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 2 Jul 2023 20:33:16 +0800 Subject: [PATCH 02/12] Update GitHub Actions Node.js matrix --- .github/workflows/node-4+.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node-4+.yml b/.github/workflows/node-4+.yml index 2925adda8..357f9089a 100644 --- a/.github/workflows/node-4+.yml +++ b/.github/workflows/node-4+.yml @@ -17,7 +17,7 @@ jobs: with: versionsAsRoot: true type: majors - preset: '>= 6' # preset: '>=4' # see https://github.com/import-js/eslint-plugin-import/issues/2053 + preset: '>= 12' latest: needs: [matrix] From b44c241e343c6ecdf9cda829045861f0d3870dde Mon Sep 17 00:00:00 2001 From: SukkaW Date: Mon, 3 Jul 2023 10:48:47 +0800 Subject: [PATCH 03/12] Drop `object.values` --- package.json | 1 - src/rules/group-exports.js | 3 ++- src/rules/no-unused-modules.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ce0189081..42d5c91f5 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,6 @@ "is-core-module": "^2.12.1", "is-glob": "^4.0.3", "minimatch": "^3.1.2", - "object.values": "^1.1.6", "resolve": "^1.22.3", "semver": "^6.3.0" } diff --git a/src/rules/group-exports.js b/src/rules/group-exports.js index 7978130d3..c293c1cbd 100644 --- a/src/rules/group-exports.js +++ b/src/rules/group-exports.js @@ -1,7 +1,8 @@ import docsUrl from '../docsUrl'; -import values from 'object.values'; import flat from 'array.prototype.flat'; +const { values } = Object; + const meta = { type: 'suggestion', docs: { diff --git a/src/rules/no-unused-modules.js b/src/rules/no-unused-modules.js index 4b09128a1..6d77bb21a 100644 --- a/src/rules/no-unused-modules.js +++ b/src/rules/no-unused-modules.js @@ -11,9 +11,10 @@ import visit from 'eslint-module-utils/visit'; import docsUrl from '../docsUrl'; import { dirname, join } from 'path'; import readPkgUp from 'eslint-module-utils/readPkgUp'; -import values from 'object.values'; import includes from 'array-includes'; +const { values } = Object; + let FileEnumerator; let listFilesToProcess; From 50492fe0ed40b50147b77f7d075eacb7e806d668 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Mon, 3 Jul 2023 10:53:15 +0800 Subject: [PATCH 04/12] Drop `array-includes` --- package.json | 1 - src/ExportMap.js | 2 +- src/rules/export.js | 3 ++- src/rules/no-unused-modules.js | 2 +- src/rules/order.js | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 42d5c91f5..077998c37 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,6 @@ "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" }, "dependencies": { - "array-includes": "^3.1.6", "array.prototype.flat": "^1.3.1", "array.prototype.flatmap": "^1.3.1", "debug": "^3.2.7", diff --git a/src/ExportMap.js b/src/ExportMap.js index 1b1de70ae..f41615d13 100644 --- a/src/ExportMap.js +++ b/src/ExportMap.js @@ -17,7 +17,7 @@ import * as unambiguous from 'eslint-module-utils/unambiguous'; import { getTsconfig } from 'get-tsconfig'; -import includes from 'array-includes'; +const includes = Function.bind.bind(Function.prototype.call)(Array.prototype.includes); const log = debug('eslint-plugin-import:ExportMap'); diff --git a/src/rules/export.js b/src/rules/export.js index c540f1e3c..75424333a 100644 --- a/src/rules/export.js +++ b/src/rules/export.js @@ -1,8 +1,9 @@ import ExportMap, { recursivePatternCapture } from '../ExportMap'; import docsUrl from '../docsUrl'; -import includes from 'array-includes'; import flatMap from 'array.prototype.flatmap'; +const includes = Function.bind.bind(Function.prototype.call)(Array.prototype.includes); + /* Notes on TypeScript namespaces aka TSModuleDeclaration: diff --git a/src/rules/no-unused-modules.js b/src/rules/no-unused-modules.js index 6d77bb21a..9f28bb612 100644 --- a/src/rules/no-unused-modules.js +++ b/src/rules/no-unused-modules.js @@ -11,9 +11,9 @@ import visit from 'eslint-module-utils/visit'; import docsUrl from '../docsUrl'; import { dirname, join } from 'path'; import readPkgUp from 'eslint-module-utils/readPkgUp'; -import includes from 'array-includes'; const { values } = Object; +const includes = Function.bind.bind(Function.prototype.call)(Array.prototype.includes); let FileEnumerator; let listFilesToProcess; diff --git a/src/rules/order.js b/src/rules/order.js index 27c3f4b0f..c2548e66b 100644 --- a/src/rules/order.js +++ b/src/rules/order.js @@ -1,12 +1,13 @@ 'use strict'; import minimatch from 'minimatch'; -import includes from 'array-includes'; import importType from '../core/importType'; import isStaticRequire from '../core/staticRequire'; import docsUrl from '../docsUrl'; +const includes = Function.bind.bind(Function.prototype.call)(Array.prototype.includes); + const defaultGroups = ['builtin', 'external', 'parent', 'sibling', 'index']; // REPORTING AND FIXING From 7d71310fec0f90162cf1569e5a2ec58e0d5b0c4e Mon Sep 17 00:00:00 2001 From: SukkaW Date: Mon, 3 Jul 2023 10:55:53 +0800 Subject: [PATCH 05/12] Drop `array.prototype.flatmap` --- package.json | 1 - src/rules/export.js | 2 +- tests/src/rules/namespace.js | 3 ++- tests/src/rules/newline-after-import.js | 3 ++- tests/src/rules/no-cycle.js | 3 ++- tests/src/rules/no-duplicates.js | 3 ++- tests/src/rules/no-dynamic-require.js | 3 ++- tests/src/rules/no-extraneous-dependencies.js | 3 ++- tests/src/rules/no-internal-modules.js | 3 ++- tests/src/rules/order.js | 3 ++- 10 files changed, 17 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 077998c37..bfaefdcf2 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,6 @@ }, "dependencies": { "array.prototype.flat": "^1.3.1", - "array.prototype.flatmap": "^1.3.1", "debug": "^3.2.7", "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.7", diff --git a/src/rules/export.js b/src/rules/export.js index 75424333a..d1db11997 100644 --- a/src/rules/export.js +++ b/src/rules/export.js @@ -1,8 +1,8 @@ import ExportMap, { recursivePatternCapture } from '../ExportMap'; import docsUrl from '../docsUrl'; -import flatMap from 'array.prototype.flatmap'; const includes = Function.bind.bind(Function.prototype.call)(Array.prototype.includes); +const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap); /* Notes on TypeScript namespaces aka TSModuleDeclaration: diff --git a/tests/src/rules/namespace.js b/tests/src/rules/namespace.js index d368fd3fe..07f207883 100644 --- a/tests/src/rules/namespace.js +++ b/tests/src/rules/namespace.js @@ -1,6 +1,7 @@ import { test, SYNTAX_CASES, getTSParsers, testVersion, testFilePath, parsers } from '../utils'; import { RuleTester } from 'eslint'; -import flatMap from 'array.prototype.flatmap'; + +const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap); const ruleTester = new RuleTester({ env: { es6: true } }); const rule = require('rules/namespace'); diff --git a/tests/src/rules/newline-after-import.js b/tests/src/rules/newline-after-import.js index 5e14b570e..d7c997cb2 100644 --- a/tests/src/rules/newline-after-import.js +++ b/tests/src/rules/newline-after-import.js @@ -1,10 +1,11 @@ import { RuleTester } from 'eslint'; -import flatMap from 'array.prototype.flatmap'; import semver from 'semver'; import { version as tsEslintVersion } from 'typescript-eslint-parser/package.json'; import { getTSParsers, parsers, testVersion } from '../utils'; +const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap); + const IMPORT_ERROR_MESSAGE = 'Expected 1 empty line after import statement not followed by another import.'; const IMPORT_ERROR_MESSAGE_MULTIPLE = (count) => `Expected ${count} empty lines after import statement not followed by another import.`; const REQUIRE_ERROR_MESSAGE = 'Expected 1 empty line after require statement not followed by another require.'; diff --git a/tests/src/rules/no-cycle.js b/tests/src/rules/no-cycle.js index d2adbf61f..d1c184919 100644 --- a/tests/src/rules/no-cycle.js +++ b/tests/src/rules/no-cycle.js @@ -1,7 +1,8 @@ import { parsers, test as _test, testFilePath, testVersion as _testVersion } from '../utils'; import { RuleTester } from 'eslint'; -import flatMap from 'array.prototype.flatmap'; + +const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap); const ruleTester = new RuleTester(); const rule = require('rules/no-cycle'); diff --git a/tests/src/rules/no-duplicates.js b/tests/src/rules/no-duplicates.js index 33e1e632e..4a0a86373 100644 --- a/tests/src/rules/no-duplicates.js +++ b/tests/src/rules/no-duplicates.js @@ -5,7 +5,8 @@ import jsxConfig from '../../../config/react'; import { RuleTester } from 'eslint'; import eslintPkg from 'eslint/package.json'; import semver from 'semver'; -import flatMap from 'array.prototype.flatmap'; + +const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap); const ruleTester = new RuleTester(); const rule = require('rules/no-duplicates'); diff --git a/tests/src/rules/no-dynamic-require.js b/tests/src/rules/no-dynamic-require.js index e316470ec..3ecc4275d 100644 --- a/tests/src/rules/no-dynamic-require.js +++ b/tests/src/rules/no-dynamic-require.js @@ -1,7 +1,8 @@ import { parsers, test, testVersion } from '../utils'; import { RuleTester } from 'eslint'; -import flatMap from 'array.prototype.flatmap'; + +const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap); const ruleTester = new RuleTester(); const rule = require('rules/no-dynamic-require'); diff --git a/tests/src/rules/no-extraneous-dependencies.js b/tests/src/rules/no-extraneous-dependencies.js index 6f4e710f9..7314869b2 100644 --- a/tests/src/rules/no-extraneous-dependencies.js +++ b/tests/src/rules/no-extraneous-dependencies.js @@ -4,7 +4,8 @@ import path from 'path'; import fs from 'fs'; import { RuleTester } from 'eslint'; -import flatMap from 'array.prototype.flatmap'; + +const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap); const ruleTester = new RuleTester(); const typescriptRuleTester = new RuleTester(typescriptConfig); diff --git a/tests/src/rules/no-internal-modules.js b/tests/src/rules/no-internal-modules.js index 4a733d142..e81282d70 100644 --- a/tests/src/rules/no-internal-modules.js +++ b/tests/src/rules/no-internal-modules.js @@ -1,9 +1,10 @@ import { RuleTester } from 'eslint'; -import flatMap from 'array.prototype.flatmap'; import rule from 'rules/no-internal-modules'; import { test, testFilePath, getTSParsers } from '../utils'; +const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap); + const ruleTester = new RuleTester(); ruleTester.run('no-internal-modules', rule, { diff --git a/tests/src/rules/order.js b/tests/src/rules/order.js index 84b341e1b..4ba7424a5 100644 --- a/tests/src/rules/order.js +++ b/tests/src/rules/order.js @@ -3,11 +3,12 @@ import { test, getTSParsers, getNonDefaultParsers, testFilePath, parsers } from import { RuleTester } from 'eslint'; import eslintPkg from 'eslint/package.json'; import semver from 'semver'; -import flatMap from 'array.prototype.flatmap'; import { resolve } from 'path'; import isCoreModule from 'is-core-module'; import { default as babelPresetFlow } from 'babel-preset-flow'; +const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap); + const ruleTester = new RuleTester(); const flowRuleTester = new RuleTester({ parser: resolve(__dirname, '../../../node_modules/babel-eslint'), From 300cd7fb30ef80aa55f3ebfe1ab153752440659b Mon Sep 17 00:00:00 2001 From: SukkaW Date: Mon, 3 Jul 2023 10:59:11 +0800 Subject: [PATCH 06/12] Drop `array.prototype.flat` --- package.json | 1 - src/rules/group-exports.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index bfaefdcf2..538f5cb7d 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,6 @@ "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" }, "dependencies": { - "array.prototype.flat": "^1.3.1", "debug": "^3.2.7", "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.7", diff --git a/src/rules/group-exports.js b/src/rules/group-exports.js index c293c1cbd..0c35ee154 100644 --- a/src/rules/group-exports.js +++ b/src/rules/group-exports.js @@ -1,7 +1,7 @@ import docsUrl from '../docsUrl'; -import flat from 'array.prototype.flat'; const { values } = Object; +const flat = Function.bind.bind(Function.prototype.call)(Array.prototype.flat); const meta = { type: 'suggestion', From 8ca0ae5825d380fee14e8579874a0f0d7c90a238 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Mon, 3 Jul 2023 11:26:46 +0800 Subject: [PATCH 07/12] Move `is-core-module` to devDeps --- package.json | 2 +- src/core/importType.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 538f5cb7d..17e7795da 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "fs-copy-file-sync": "^1.1.1", "glob": "^7.2.3", "in-publish": "^2.0.1", + "is-core-module": "^2.12.1", "linklocal": "^2.8.2", "lodash.isarray": "^4.0.0", "mocha": "^3.5.3", @@ -106,7 +107,6 @@ "eslint-module-utils": "^2.8.0", "get-tsconfig": "^4.6.0", "has": "^1.0.3", - "is-core-module": "^2.12.1", "is-glob": "^4.0.3", "minimatch": "^3.1.2", "resolve": "^1.22.3", diff --git a/src/core/importType.js b/src/core/importType.js index 6a37d1bb1..61530cdef 100644 --- a/src/core/importType.js +++ b/src/core/importType.js @@ -1,8 +1,14 @@ import { isAbsolute as nodeIsAbsolute, relative, resolve as nodeResolve } from 'path'; -import isCoreModule from 'is-core-module'; import resolve from 'eslint-module-utils/resolve'; import { getContextPackagePath } from './packagePath'; +import { Module } from 'module'; + +const isCoreModule = (pkg) => Module.builtinModules.includes( + pkg.startsWith('node:') + ? pkg.slice(5) + : pkg, +); function baseModule(name) { if (isScoped(name)) { From ae6e28fe5297135fc7bd478ce578007344bf6070 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Mon, 3 Jul 2023 11:44:41 +0800 Subject: [PATCH 08/12] Drop `has` --- package.json | 1 - resolvers/webpack/index.js | 3 ++- src/rules/no-anonymous-default-export.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 17e7795da..a114a0001 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,6 @@ "eslint-import-resolver-node": "^0.3.7", "eslint-module-utils": "^2.8.0", "get-tsconfig": "^4.6.0", - "has": "^1.0.3", "is-glob": "^4.0.3", "minimatch": "^3.1.2", "resolve": "^1.22.3", diff --git a/resolvers/webpack/index.js b/resolvers/webpack/index.js index 8eb2db5ad..dd1ccb371 100644 --- a/resolvers/webpack/index.js +++ b/resolvers/webpack/index.js @@ -10,9 +10,10 @@ const fs = require('fs'); const isCore = require('is-core-module'); const resolve = require('resolve'); const semver = require('semver'); -const has = require('has'); const isRegex = require('is-regex'); +const has = Function.bind.bind(Function.prototype.call)(Object.prototype.hasOwnProperty); + const log = require('debug')('eslint-plugin-import:resolver:webpack'); exports.interfaceVersion = 2; diff --git a/src/rules/no-anonymous-default-export.js b/src/rules/no-anonymous-default-export.js index 80950d550..eaab27653 100644 --- a/src/rules/no-anonymous-default-export.js +++ b/src/rules/no-anonymous-default-export.js @@ -4,7 +4,8 @@ */ import docsUrl from '../docsUrl'; -import has from 'has'; + +const has = Function.bind.bind(Function.prototype.call)(Object.prototype.hasOwnProperty); const defs = { ArrayExpression: { From 20a0858ea7c6a71b931547d1f4e72441bc8596a0 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Tue, 4 Jul 2023 15:31:50 +0800 Subject: [PATCH 09/12] Bump `semver` to the latest version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a114a0001..118885a17 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,6 @@ "is-glob": "^4.0.3", "minimatch": "^3.1.2", "resolve": "^1.22.3", - "semver": "^6.3.0" + "semver": "^7.5.3" } } From 963b028bff920a88f9ffe9e2a4494b41b6dacdeb Mon Sep 17 00:00:00 2001 From: SukkaW Date: Tue, 4 Jul 2023 22:20:43 +0800 Subject: [PATCH 10/12] Drop ESLint <=6 in peerDeps --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 118885a17..533b90405 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "typescript-eslint-parser": "^15 || ^20 || ^22" }, "peerDependencies": { - "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" + "eslint": "^7.2.0 || ^8" }, "dependencies": { "debug": "^3.2.7", From 5481192623e2ba8bc7d32561b6d69fac6184fe03 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Tue, 4 Jul 2023 22:42:44 +0800 Subject: [PATCH 11/12] Chore: reflect change history --- .github/workflows/node-4+.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/node-4+.yml b/.github/workflows/node-4+.yml index 357f9089a..84e163183 100644 --- a/.github/workflows/node-4+.yml +++ b/.github/workflows/node-4+.yml @@ -17,6 +17,8 @@ jobs: with: versionsAsRoot: true type: majors + # preset: '>= 6' # preset: '>=4' # see https://github.com/import-js/eslint-plugin-import/issues/2053 + # target Node.js 12 now, see https://github.com/un-es/eslint-plugin-i/issues/10 & https://github.com/un-es/eslint-plugin-i/pull/11 preset: '>= 12' latest: From efb9326d0a9d03c24c38629cd7d8f078708be472 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 4 Jul 2023 22:54:13 +0800 Subject: [PATCH 12/12] ci: remove eslint 7- tests --- .github/workflows/node-4+.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/node-4+.yml b/.github/workflows/node-4+.yml index 84e163183..c1e46e31a 100644 --- a/.github/workflows/node-4+.yml +++ b/.github/workflows/node-4+.yml @@ -33,11 +33,6 @@ jobs: eslint: - 8 - 7 - - 6 - - 5 - - 4 - - 3 - - 2 include: - node-version: 'lts/*' eslint: 7