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.2.1 to 2.3.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [2.3.0](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/compare/v2.2.1...v2.3.0) (2020-09-01)
### Features
* import with .js and .jsx file extensions ([#56](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/issues/56)) ([5340f96](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/commit/5340f969fad38165f8cfb28025a5e15233d0e6f9))
### [2.2.1](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/compare/v2.2.0...v2.2.1) (2020-08-14)

@@ -7,0 +14,0 @@

71

lib/cjs.js

@@ -14,2 +14,25 @@ 'use strict';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
var IMPORTER_NAME = 'eslint-import-resolver-typescript';

@@ -45,3 +68,3 @@ var log = debug(IMPORTER_NAME);

try {
foundNodePath = resolve$1.sync(mappedPath || source, {
foundNodePath = tsResolve(mappedPath || source, {
extensions: options.extensions || defaultExtensions,

@@ -84,2 +107,22 @@ basedir: path.dirname(path.resolve(file)),

}
/**
* Like `sync` from `resolve` package, but considers that the module id
* could have a .js or .jsx extension.
*/
function tsResolve(id, opts) {
try {
return resolve$1.sync(id, opts);
}
catch (error) {
var idWithoutJsExt = removeJsExtension(id);
if (idWithoutJsExt !== id) {
return resolve$1.sync(idWithoutJsExt, opts);
}
throw error;
}
}
/** Remove .js or .jsx extension from module id. */
function removeJsExtension(id) {
return id.replace(/\.jsx?$/, '');
}
var mappersBuildForOptions;

@@ -101,2 +144,26 @@ var mappers;

}
/**
* Like `createMatchPath` from `tsconfig-paths` package, but considers
* that the module id could have a .js or .jsx extension.
*/
var createExtendedMatchPath = function () {
var createArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
createArgs[_i] = arguments[_i];
}
var matchPath = tsconfigPaths.createMatchPath.apply(void 0, createArgs);
return function (id) {
var otherArgs = [];
for (var _i = 1; _i < arguments.length; _i++) {
otherArgs[_i - 1] = arguments[_i];
}
var match = matchPath.apply(void 0, __spreadArrays([id], otherArgs));
if (match != null)
return match;
var idWithoutJsExt = removeJsExtension(id);
if (idWithoutJsExt !== id) {
return matchPath.apply(void 0, __spreadArrays([idWithoutJsExt], otherArgs));
}
};
};
function initMappers(options) {

@@ -125,3 +192,3 @@ if (mappers && mappersBuildForOptions === options) {

.map(function (configLoaderResult) {
var matchPath = tsconfigPaths.createMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths);
var matchPath = createExtendedMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths);
return function (source, file) {

@@ -128,0 +195,0 @@ // exclude files that are not part of the config base url

@@ -38,3 +38,3 @@ import path from 'path';

try {
foundNodePath = sync(mappedPath || source, {
foundNodePath = tsResolve(mappedPath || source, {
extensions: options.extensions || defaultExtensions,

@@ -77,2 +77,22 @@ basedir: path.dirname(path.resolve(file)),

}
/**
* Like `sync` from `resolve` package, but considers that the module id
* could have a .js or .jsx extension.
*/
function tsResolve(id, opts) {
try {
return sync(id, opts);
}
catch (error) {
const idWithoutJsExt = removeJsExtension(id);
if (idWithoutJsExt !== id) {
return sync(idWithoutJsExt, opts);
}
throw error;
}
}
/** Remove .js or .jsx extension from module id. */
function removeJsExtension(id) {
return id.replace(/\.jsx?$/, '');
}
let mappersBuildForOptions;

@@ -94,2 +114,18 @@ let mappers;

}
/**
* Like `createMatchPath` from `tsconfig-paths` package, but considers
* that the module id could have a .js or .jsx extension.
*/
const createExtendedMatchPath = (...createArgs) => {
const matchPath = createMatchPath(...createArgs);
return (id, ...otherArgs) => {
const match = matchPath(id, ...otherArgs);
if (match != null)
return match;
const idWithoutJsExt = removeJsExtension(id);
if (idWithoutJsExt !== id) {
return matchPath(idWithoutJsExt, ...otherArgs);
}
};
};
function initMappers(options) {

@@ -118,3 +154,3 @@ if (mappers && mappersBuildForOptions === options) {

.map(configLoaderResult => {
const matchPath = createMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths);
const matchPath = createExtendedMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths);
return (source, file) => {

@@ -121,0 +157,0 @@ // exclude files that are not part of the config base url

@@ -8,2 +8,25 @@ import path from 'path';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
var IMPORTER_NAME = 'eslint-import-resolver-typescript';

@@ -39,3 +62,3 @@ var log = debug(IMPORTER_NAME);

try {
foundNodePath = sync(mappedPath || source, {
foundNodePath = tsResolve(mappedPath || source, {
extensions: options.extensions || defaultExtensions,

@@ -78,2 +101,22 @@ basedir: path.dirname(path.resolve(file)),

}
/**
* Like `sync` from `resolve` package, but considers that the module id
* could have a .js or .jsx extension.
*/
function tsResolve(id, opts) {
try {
return sync(id, opts);
}
catch (error) {
var idWithoutJsExt = removeJsExtension(id);
if (idWithoutJsExt !== id) {
return sync(idWithoutJsExt, opts);
}
throw error;
}
}
/** Remove .js or .jsx extension from module id. */
function removeJsExtension(id) {
return id.replace(/\.jsx?$/, '');
}
var mappersBuildForOptions;

@@ -95,2 +138,26 @@ var mappers;

}
/**
* Like `createMatchPath` from `tsconfig-paths` package, but considers
* that the module id could have a .js or .jsx extension.
*/
var createExtendedMatchPath = function () {
var createArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
createArgs[_i] = arguments[_i];
}
var matchPath = createMatchPath.apply(void 0, createArgs);
return function (id) {
var otherArgs = [];
for (var _i = 1; _i < arguments.length; _i++) {
otherArgs[_i - 1] = arguments[_i];
}
var match = matchPath.apply(void 0, __spreadArrays([id], otherArgs));
if (match != null)
return match;
var idWithoutJsExt = removeJsExtension(id);
if (idWithoutJsExt !== id) {
return matchPath.apply(void 0, __spreadArrays([idWithoutJsExt], otherArgs));
}
};
};
function initMappers(options) {

@@ -119,3 +186,3 @@ if (mappers && mappersBuildForOptions === options) {

.map(function (configLoaderResult) {
var matchPath = createMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths);
var matchPath = createExtendedMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths);
return function (source, file) {

@@ -122,0 +189,0 @@ // exclude files that are not part of the config base url

@@ -0,1 +1,2 @@

import { __spreadArrays } from "tslib";
import path from 'path';

@@ -37,3 +38,3 @@ import { createMatchPath, loadConfig, } from 'tsconfig-paths';

try {
foundNodePath = sync(mappedPath || source, {
foundNodePath = tsResolve(mappedPath || source, {
extensions: options.extensions || defaultExtensions,

@@ -76,2 +77,22 @@ basedir: path.dirname(path.resolve(file)),

}
/**
* Like `sync` from `resolve` package, but considers that the module id
* could have a .js or .jsx extension.
*/
function tsResolve(id, opts) {
try {
return sync(id, opts);
}
catch (error) {
var idWithoutJsExt = removeJsExtension(id);
if (idWithoutJsExt !== id) {
return sync(idWithoutJsExt, opts);
}
throw error;
}
}
/** Remove .js or .jsx extension from module id. */
function removeJsExtension(id) {
return id.replace(/\.jsx?$/, '');
}
var mappersBuildForOptions;

@@ -93,2 +114,26 @@ var mappers;

}
/**
* Like `createMatchPath` from `tsconfig-paths` package, but considers
* that the module id could have a .js or .jsx extension.
*/
var createExtendedMatchPath = function () {
var createArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
createArgs[_i] = arguments[_i];
}
var matchPath = createMatchPath.apply(void 0, createArgs);
return function (id) {
var otherArgs = [];
for (var _i = 1; _i < arguments.length; _i++) {
otherArgs[_i - 1] = arguments[_i];
}
var match = matchPath.apply(void 0, __spreadArrays([id], otherArgs));
if (match != null)
return match;
var idWithoutJsExt = removeJsExtension(id);
if (idWithoutJsExt !== id) {
return matchPath.apply(void 0, __spreadArrays([idWithoutJsExt], otherArgs));
}
};
};
function initMappers(options) {

@@ -117,3 +162,3 @@ if (mappers && mappersBuildForOptions === options) {

.map(function (configLoaderResult) {
var matchPath = createMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths);
var matchPath = createExtendedMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths);
return function (source, file) {

@@ -120,0 +165,0 @@ // exclude files that are not part of the config base url

13

package.json
{
"name": "eslint-import-resolver-typescript",
"version": "2.2.1",
"version": "2.3.0",
"description": "TypeScript .ts .tsx module resolver for `eslint-plugin-import`.",

@@ -43,2 +43,3 @@ "repository": "https://github.com/alexgorbatchev/eslint-import-resolver-typescript",

"test:multipleTsconfigs": "eslint --ext ts,tsx tests/multipleTsconfigs",
"test:withJsExtension": "node tests/withJsExtension/test.js && eslint --ext ts,tsx tests/withJsExtension",
"test:withPaths": "eslint --ext ts,tsx tests/withPaths",

@@ -64,3 +65,3 @@ "test:withoutPaths": "eslint --ext ts,tsx tests/withoutPaths",

"@types/is-glob": "^4.0.1",
"@types/node": "^14.0.27",
"@types/node": "^14.6.2",
"@types/resolve": "^1.17.1",

@@ -74,12 +75,12 @@ "@types/unist": "^2.0.3",

"type-coverage": "^2.9.0",
"typescript": "^3.9.7",
"yarn-deduplicate": "^2.1.1"
"typescript": "^4.0.2",
"yarn-deduplicate": "^3.0.0"
},
"resolutions": {
"eslint-import-resolver-typescript": "link:.",
"prettier": "^2.0.5"
"prettier": "^2.1.1"
},
"typeCoverage": {
"atLeast": 98.73
"atLeast": 99.27
}
}

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