Skip to content

Commit

Permalink
feat!: bump semver, remove unnecessary dependencies (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: JounQin <admin@1stg.me>
  • Loading branch information
SukkaW and JounQin committed Jul 31, 2023
1 parent dedec3a commit 7903a85
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 46 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/node-4+.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
with:
versionsAsRoot: true
type: majors
preset: '>= 6' # preset: '>=4' # see https://github.com/import-js/eslint-plugin-import/issues/2053
# 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:
needs: [matrix]
Expand All @@ -31,11 +33,6 @@ jobs:
eslint:
- 8
- 7
- 6
- 5
- 4
- 3
- 2
include:
- node-version: 'lts/*'
eslint: 7
Expand Down
18 changes: 5 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -85,6 +85,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",
Expand All @@ -98,26 +99,17 @@
"typescript-eslint-parser": "^15 || ^20 || ^22"
},
"peerDependencies": {
"eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8"
"eslint": "^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",
"debug": "^3.2.7",
"doctrine": "^2.1.0",
"eslint-import-resolver-node": "^0.3.7",
"eslint-module-utils": "^2.8.0",
"get-tsconfig": "^4.6.0",
"has": "^1.0.3",
"is-core-module": "^2.12.1",
"get-tsconfig": "^4.6.2",
"is-glob": "^4.0.3",
"minimatch": "^3.1.2",
"object.fromentries": "^2.0.6",
"object.groupby": "^1.0.0",
"object.values": "^1.1.6",
"resolve": "^1.22.3",
"semver": "^6.3.1"
"semver": "^7.5.3"
}
}
3 changes: 2 additions & 1 deletion resolvers/webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
8 changes: 7 additions & 1 deletion src/core/importType.js
Original file line number Diff line number Diff line change
@@ -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)) {
Expand Down
5 changes: 3 additions & 2 deletions src/rules/export.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
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);
const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap);

/*
Notes on TypeScript namespaces aka TSModuleDeclaration:
Expand Down
13 changes: 11 additions & 2 deletions src/rules/exports-last.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import findLastIndex from 'array.prototype.findlastindex';

import docsUrl from '../docsUrl';

const findLastIndex = (array, predicate) => {
let i = array.length - 1;
while (i >= 0) {
if (predicate(array[i])) {
return i;
}
i--;
}
return -1;
};

function isNonExportStatement({ type }) {
return type !== 'ExportDefaultDeclaration'
&& type !== 'ExportNamedDeclaration'
Expand Down
5 changes: 3 additions & 2 deletions src/rules/group-exports.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import docsUrl from '../docsUrl';
import values from 'object.values';
import flat from 'array.prototype.flat';

const { values } = Object;
const flat = Function.bind.bind(Function.prototype.call)(Array.prototype.flat);

const meta = {
type: 'suggestion',
Expand Down
7 changes: 3 additions & 4 deletions src/rules/no-anonymous-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* @author Duncan Beevers
*/

import has from 'has';
import values from 'object.values';
import fromEntries from 'object.fromentries';

import docsUrl from '../docsUrl';

const has = Function.bind.bind(Function.prototype.call)(Object.prototype.hasOwnProperty);
const { fromEntries, values } = Object;

const defs = {
ArrayExpression: {
option: 'allowArray',
Expand Down
3 changes: 2 additions & 1 deletion src/rules/no-duplicates.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import resolve from 'eslint-module-utils/resolve';
import semver from 'semver';
import flatMap from 'array.prototype.flatmap';

import docsUrl from '../docsUrl';

const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap);

let typescriptPkg;
try {
typescriptPkg = require('typescript/package.json'); // eslint-disable-line import/no-extraneous-dependencies
Expand Down
7 changes: 4 additions & 3 deletions src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import resolve from 'eslint-module-utils/resolve';
import visit from 'eslint-module-utils/visit';
import { dirname, join } from 'path';
import readPkgUp from 'eslint-module-utils/readPkgUp';
import values from 'object.values';
import includes from 'array-includes';
import flatMap from 'array.prototype.flatmap';

const { values } = Object;
const includes = Function.bind.bind(Function.prototype.call)(Array.prototype.includes);
const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap);

import Exports, { recursivePatternCapture } from '../ExportMap';
import docsUrl from '../docsUrl';
Expand Down
10 changes: 8 additions & 2 deletions src/rules/order.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
'use strict';

import minimatch from 'minimatch';
import includes from 'array-includes';
import groupBy from 'object.groupby';

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);
// This is a **non-spec compliant** but works in practice replacement of `object.groupby` package.
const groupBy = (array, grouper) => array.reduce((acc, curr, index) => {
const key = grouper(curr, index);
(acc[key] = acc[key] || []).push(curr);
return acc;
}, {});

const defaultGroups = ['builtin', 'external', 'parent', 'sibling', 'index'];

// REPORTING AND FIXING
Expand Down
3 changes: 2 additions & 1 deletion tests/src/rules/namespace.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
3 changes: 2 additions & 1 deletion tests/src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
@@ -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.';
Expand Down
3 changes: 2 additions & 1 deletion tests/src/rules/no-cycle.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
3 changes: 2 additions & 1 deletion tests/src/rules/no-duplicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion tests/src/rules/no-dynamic-require.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
3 changes: 2 additions & 1 deletion tests/src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tests/src/rules/no-internal-modules.js
Original file line number Diff line number Diff line change
@@ -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, {
Expand Down
3 changes: 2 additions & 1 deletion tests/src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 7903a85

Please sign in to comment.