Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-import-resolver-typescript

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-import-resolver-typescript - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

CHANGELOG.md

28

lib/cjs.js

@@ -9,3 +9,3 @@ 'use strict';

var tsconfigPaths = require('tsconfig-paths');
var globSync = _interopDefault(require('tiny-glob/sync'));
var glob = require('glob');
var isGlob = _interopDefault(require('is-glob'));

@@ -15,4 +15,4 @@ var resolve$1 = require('resolve');

var log = debug('eslint-import-resolver-ts');
var extensions = ['.ts', '.tsx', '.d.ts'].concat(
var log = debug('eslint-import-resolver-typescript');
var defaultExtensions = ['.ts', '.tsx', '.d.ts'].concat(
// eslint-disable-next-line node/no-deprecated-api

@@ -26,3 +26,3 @@ Object.keys(require.extensions), '.jsx');

function resolve(source, file, options) {
if (options === void 0) { options = {}; }
options = options || {};
log('looking for:', source);

@@ -46,8 +46,8 @@ // don't worry about core node modules

foundNodePath = resolve$1.sync(mappedPath || source, {
extensions: extensions,
extensions: options.extensions || defaultExtensions,
basedir: path.dirname(path.resolve(file)),
packageFilter: packageFilter,
packageFilter: options.packageFilter || packageFilterDefault,
});
}
catch (err) {
catch (_a) {
foundNodePath = null;

@@ -79,3 +79,3 @@ }

}
function packageFilter(pkg) {
function packageFilterDefault(pkg) {
pkg.main =

@@ -85,2 +85,3 @@ pkg.types || pkg.typings || pkg.module || pkg['jsnext:main'] || pkg.main;

}
var mappersBuildForOptions;
var mappers;

@@ -102,3 +103,3 @@ /**

function initMappers(options) {
if (mappers) {
if (mappers && mappersBuildForOptions === options) {
return;

@@ -116,4 +117,6 @@ }

// turn glob patterns into paths
.reduce(function (paths, path) { return paths.concat(isGlob(path) ? globSync(path) : path); }, [])
.reduce(function (paths, path) { return paths.concat(isGlob(path) ? glob.sync(path) : path); }, [])
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
.map(tsconfigPaths.loadConfig)
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
.filter(isConfigLoaderSuccessResult)

@@ -125,8 +128,9 @@ .map(function (configLoaderResult) {

if (!file.includes(configLoaderResult.absoluteBaseUrl)) {
return undefined;
return;
}
// look for files based on setup tsconfig "paths"
return matchPath(source, undefined, undefined, extensions);
return matchPath(source, undefined, undefined, options.extensions || defaultExtensions);
};
});
mappersBuildForOptions = options;
}

@@ -133,0 +137,0 @@ function isConfigLoaderSuccessResult(configLoaderResult) {

import path from 'path';
import { loadConfig, createMatchPath } from 'tsconfig-paths';
import globSync from 'tiny-glob/sync';
import { sync as sync$1 } from 'glob';
import isGlob from 'is-glob';

@@ -8,4 +8,4 @@ import { isCore, sync } from 'resolve';

const log = debug('eslint-import-resolver-ts');
const extensions = ['.ts', '.tsx', '.d.ts'].concat(
const log = debug('eslint-import-resolver-typescript');
const defaultExtensions = ['.ts', '.tsx', '.d.ts'].concat(
// eslint-disable-next-line node/no-deprecated-api

@@ -18,3 +18,4 @@ Object.keys(require.extensions), '.jsx');

*/
function resolve(source, file, options = {}) {
function resolve(source, file, options) {
options = options || {};
log('looking for:', source);

@@ -38,8 +39,8 @@ // don't worry about core node modules

foundNodePath = sync(mappedPath || source, {
extensions,
extensions: options.extensions || defaultExtensions,
basedir: path.dirname(path.resolve(file)),
packageFilter,
packageFilter: options.packageFilter || packageFilterDefault,
});
}
catch (err) {
catch (_a) {
foundNodePath = null;

@@ -71,3 +72,3 @@ }

}
function packageFilter(pkg) {
function packageFilterDefault(pkg) {
pkg.main =

@@ -77,2 +78,3 @@ pkg.types || pkg.typings || pkg.module || pkg['jsnext:main'] || pkg.main;

}
let mappersBuildForOptions;
let mappers;

@@ -94,3 +96,3 @@ /**

function initMappers(options) {
if (mappers) {
if (mappers && mappersBuildForOptions === options) {
return;

@@ -106,4 +108,6 @@ }

// turn glob patterns into paths
.reduce((paths, path) => paths.concat(isGlob(path) ? globSync(path) : path), [])
.reduce((paths, path) => paths.concat(isGlob(path) ? sync$1(path) : path), [])
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
.map(loadConfig)
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
.filter(isConfigLoaderSuccessResult)

@@ -115,8 +119,9 @@ .map(configLoaderResult => {

if (!file.includes(configLoaderResult.absoluteBaseUrl)) {
return undefined;
return;
}
// look for files based on setup tsconfig "paths"
return matchPath(source, undefined, undefined, extensions);
return matchPath(source, undefined, undefined, options.extensions || defaultExtensions);
};
});
mappersBuildForOptions = options;
}

@@ -123,0 +128,0 @@ function isConfigLoaderSuccessResult(configLoaderResult) {

import path from 'path';
import { loadConfig, createMatchPath } from 'tsconfig-paths';
import globSync from 'tiny-glob/sync';
import { sync as sync$1 } from 'glob';
import isGlob from 'is-glob';

@@ -8,4 +8,4 @@ import { isCore, sync } from 'resolve';

var log = debug('eslint-import-resolver-ts');
var extensions = ['.ts', '.tsx', '.d.ts'].concat(
var log = debug('eslint-import-resolver-typescript');
var defaultExtensions = ['.ts', '.tsx', '.d.ts'].concat(
// eslint-disable-next-line node/no-deprecated-api

@@ -19,3 +19,3 @@ Object.keys(require.extensions), '.jsx');

function resolve(source, file, options) {
if (options === void 0) { options = {}; }
options = options || {};
log('looking for:', source);

@@ -39,8 +39,8 @@ // don't worry about core node modules

foundNodePath = sync(mappedPath || source, {
extensions: extensions,
extensions: options.extensions || defaultExtensions,
basedir: path.dirname(path.resolve(file)),
packageFilter: packageFilter,
packageFilter: options.packageFilter || packageFilterDefault,
});
}
catch (err) {
catch (_a) {
foundNodePath = null;

@@ -72,3 +72,3 @@ }

}
function packageFilter(pkg) {
function packageFilterDefault(pkg) {
pkg.main =

@@ -78,2 +78,3 @@ pkg.types || pkg.typings || pkg.module || pkg['jsnext:main'] || pkg.main;

}
var mappersBuildForOptions;
var mappers;

@@ -95,3 +96,3 @@ /**

function initMappers(options) {
if (mappers) {
if (mappers && mappersBuildForOptions === options) {
return;

@@ -109,4 +110,6 @@ }

// turn glob patterns into paths
.reduce(function (paths, path) { return paths.concat(isGlob(path) ? globSync(path) : path); }, [])
.reduce(function (paths, path) { return paths.concat(isGlob(path) ? sync$1(path) : path); }, [])
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
.map(loadConfig)
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
.filter(isConfigLoaderSuccessResult)

@@ -118,8 +121,9 @@ .map(function (configLoaderResult) {

if (!file.includes(configLoaderResult.absoluteBaseUrl)) {
return undefined;
return;
}
// look for files based on setup tsconfig "paths"
return matchPath(source, undefined, undefined, extensions);
return matchPath(source, undefined, undefined, options.extensions || defaultExtensions);
};
});
mappersBuildForOptions = options;
}

@@ -126,0 +130,0 @@ function isConfigLoaderSuccessResult(configLoaderResult) {

@@ -5,2 +5,4 @@ export declare const interfaceVersion = 2;

directory?: string | string[];
extensions?: string[];
packageFilter?: (pkg: Record<string, string>) => Record<string, string>;
}

@@ -11,3 +13,3 @@ /**

*/
export declare function resolve(source: string, file: string, options?: TsResolverOptions): {
export declare function resolve(source: string, file: string, options: TsResolverOptions | null): {
found: boolean;

@@ -14,0 +16,0 @@ path?: string | null;

import path from 'path';
import { createMatchPath, loadConfig, } from 'tsconfig-paths';
import globSync from 'tiny-glob/sync';
import { sync as globSync } from 'glob';
import isGlob from 'is-glob';
import { isCore, sync } from 'resolve';
import debug from 'debug';
var log = debug('eslint-import-resolver-ts');
var extensions = ['.ts', '.tsx', '.d.ts'].concat(
var log = debug('eslint-import-resolver-typescript');
var defaultExtensions = ['.ts', '.tsx', '.d.ts'].concat(
// eslint-disable-next-line node/no-deprecated-api

@@ -17,3 +17,3 @@ Object.keys(require.extensions), '.jsx');

export function resolve(source, file, options) {
if (options === void 0) { options = {}; }
options = options || {};
log('looking for:', source);

@@ -37,8 +37,8 @@ // don't worry about core node modules

foundNodePath = sync(mappedPath || source, {
extensions: extensions,
extensions: options.extensions || defaultExtensions,
basedir: path.dirname(path.resolve(file)),
packageFilter: packageFilter,
packageFilter: options.packageFilter || packageFilterDefault,
});
}
catch (err) {
catch (_a) {
foundNodePath = null;

@@ -70,3 +70,3 @@ }

}
function packageFilter(pkg) {
function packageFilterDefault(pkg) {
pkg.main =

@@ -76,2 +76,3 @@ pkg.types || pkg.typings || pkg.module || pkg['jsnext:main'] || pkg.main;

}
var mappersBuildForOptions;
var mappers;

@@ -93,3 +94,3 @@ /**

function initMappers(options) {
if (mappers) {
if (mappers && mappersBuildForOptions === options) {
return;

@@ -108,3 +109,5 @@ }

.reduce(function (paths, path) { return paths.concat(isGlob(path) ? globSync(path) : path); }, [])
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
.map(loadConfig)
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
.filter(isConfigLoaderSuccessResult)

@@ -116,8 +119,9 @@ .map(function (configLoaderResult) {

if (!file.includes(configLoaderResult.absoluteBaseUrl)) {
return undefined;
return;
}
// look for files based on setup tsconfig "paths"
return matchPath(source, undefined, undefined, extensions);
return matchPath(source, undefined, undefined, options.extensions || defaultExtensions);
};
});
mappersBuildForOptions = options;
}

@@ -124,0 +128,0 @@ function isConfigLoaderSuccessResult(configLoaderResult) {

{
"name": "eslint-import-resolver-typescript",
"version": "2.0.0",
"version": "2.1.0",
"description": "TypeScript .ts .tsx module resolver for `eslint-plugin-import`.",
"repository": "https://github.com/alexgorbatchev/eslint-import-resolver-typescript",
"author": "Alex Gorbatchev <alex.gorbatchev@gmail.com>",
"contributors": [
"JounQin <admin@1stg.me>"
],
"license": "ISC",

@@ -31,7 +34,14 @@ "engines": {

"lint": "run-p lint:*",
"lint:es": "eslint src --ext md,js,ts -f friendly",
"lint:tsc": "tsc --noEmit",
"lint:es": "cross-env PARSER_NO_WATCH=true eslint src --cache --ext md,js,ts -f friendly",
"lint:tsc": "tsc --incremental false --noEmit",
"postinstall": "yarn-deduplicate || exit 0",
"prepublishOnly": "yarn build",
"pretest": "r",
"test": "eslint tests/**/*.{ts,tsx} -f friendly",
"type-coverage": "type-coverage --cache --detail --ignore-catch --strict"
"release": "sh scripts/release.sh",
"test": "run-p test:*",
"test:multipleEslintrcs": "eslint --ext ts,tsx tests/multipleEslintrcs",
"test:multipleTsconfigs": "eslint --ext ts,tsx tests/multipleTsconfigs",
"test:withPaths": "eslint --ext ts,tsx tests/withPaths",
"test:withoutPaths": "eslint --ext ts,tsx tests/withoutPaths",
"type-coverage": "type-coverage --cache --detail --ignore-catch --strict --update"
},

@@ -44,42 +54,31 @@ "peerDependencies": {

"debug": "^4.1.1",
"glob": "^7.1.6",
"is-glob": "^4.0.1",
"resolve": "^1.12.0",
"tiny-glob": "^0.2.6",
"resolve": "^1.17.0",
"tsconfig-paths": "^3.9.0"
},
"devDependencies": {
"@1stg/babel-preset": "^0.7.4",
"@1stg/commitlint-config": "^0.1.0",
"@1stg/eslint-config": "^0.12.20",
"@1stg/husky-config": "^0.3.1",
"@1stg/lint-staged": "^0.8.6",
"@1stg/prettier-config": "^0.4.2",
"@1stg/remark-config": "^0.2.2",
"@1stg/tsconfig": "^0.6.0",
"@babel/core": "^7.6.2",
"@commitlint/cli": "^8.2.0",
"@pkgr/rollup": "^0.2.4",
"@1stg/lib-config": "^0.5.5",
"@types/debug": "^4.1.5",
"@types/glob": "^7.1.3",
"@types/is-glob": "^4.0.1",
"@types/node": "^12.7.11",
"@types/resolve": "^0.0.8",
"@types/node": "^14.0.27",
"@types/resolve": "^1.17.1",
"@types/unist": "^2.0.3",
"dummy.js": "link:dummy.js",
"eslint": "^6.5.1",
"eslint-import-resolver-typescript": "link:.",
"husky": "^3.0.8",
"lint-staged": "^9.4.1",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"react": "^16.10.2",
"rollup": "^1.23.1",
"type-coverage": "^2.3.0",
"typescript": "^3.6.3"
"react": "^16.13.1",
"standard-version": "^8.0.2",
"type-coverage": "^2.9.0",
"typescript": "^3.9.7",
"yarn-deduplicate": "^2.1.1"
},
"resolutions": {
"eslint-import-resolver-typescript": "link:."
"eslint-import-resolver-typescript": "link:.",
"prettier": "^2.0.5"
},
"typeCoverage": {
"atLeast": 100
"atLeast": 98.73
}
}

@@ -28,2 +28,3 @@ # eslint-import-resolver-typescript

- [Notice](#notice)
- [Installation](#installation)

@@ -33,2 +34,8 @@ - [Configuration](#configuration)

## Notice
After version 2.0.0, `.d.ts` will take higher priority then normal `.js` files on resolving `node_modules` packages in favor of `@types/*` definitions.
If you're facing some problems on rules `import/default` or `import/named` from [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import), do not post any issue here, because they are just working exactly as [expected](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/issues/31#issuecomment-539751607) on our sides, take <https://github.com/benmosher/eslint-plugin-import/issues/1525> as reference or post a new issue to [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) instead.
## Installation

@@ -62,3 +69,3 @@

"typescript": {
"alwaysTryTypes": true // always try to resolve types under `<roo/>@types` directory even it doesn't contain any source code, like `@types/unist`
"alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
},

@@ -68,3 +75,3 @@

"typescript": {
"directory": "./path/to/folder"
"directory": "path/to/folder"
},

@@ -76,3 +83,3 @@

"typescript": {
"directory": "./packages/*/tsconfig.json"
"directory": "packages/*/tsconfig.json"
},

@@ -83,4 +90,4 @@

"directory": [
"./packages/module-a/tsconfig.json",
"./packages/module-b/tsconfig.json"
"packages/module-a/tsconfig.json",
"packages/module-b/tsconfig.json"
]

@@ -92,4 +99,4 @@ },

"directory": [
"./packages/*/tsconfig.json",
"./other-packages/*/tsconfig.json"
"packages/*/tsconfig.json",
"other-packages/*/tsconfig.json"
]

@@ -96,0 +103,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc