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

Addresses #10 / Update semver to the latest to fix CVE / Remove unnecessary dependencies #11

Merged
merged 12 commits into from
Jul 4, 2023
2 changes: 1 addition & 1 deletion .github/workflows/node-4+.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
JounQin marked this conversation as resolved.
Show resolved Hide resolved

latest:
needs: [matrix]
Expand Down
13 changes: 4 additions & 9 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 @@ -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",
Expand All @@ -97,23 +98,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.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",
"is-glob": "^4.0.3",
"minimatch": "^3.1.2",
"object.values": "^1.1.6",
"resolve": "^1.22.3",
"semver": "^6.3.0"
"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);
JounQin marked this conversation as resolved.
Show resolved Hide resolved
const flatMap = Function.bind.bind(Function.prototype.call)(Array.prototype.flatMap);

/*
Notes on TypeScript namespaces aka TSModuleDeclaration:
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
3 changes: 2 additions & 1 deletion src/rules/no-anonymous-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
5 changes: 3 additions & 2 deletions src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +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 values from 'object.values';
import includes from 'array-includes';

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

let FileEnumerator;
let listFilesToProcess;
Expand Down
3 changes: 2 additions & 1 deletion src/rules/order.js
Original file line number Diff line number Diff line change
@@ -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
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