Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: import-js/eslint-import-resolver-typescript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.4.0
Choose a base ref
...
head repository: import-js/eslint-import-resolver-typescript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.5.0
Choose a head ref
  • 5 commits
  • 12 files changed
  • 2 contributors

Commits on Feb 16, 2021

  1. chore: bump (dev)Dependencies

    JounQin committed Feb 16, 2021
    Copy the full SHA
    38dba0b View commit details

Commits on May 29, 2021

  1. Copy the full SHA
    866f32f View commit details

Commits on Jul 30, 2021

  1. Copy the full SHA
    34c94c8 View commit details

Commits on Sep 13, 2021

  1. chore: add LICENSE file

    close #77
    JounQin committed Sep 13, 2021
    Copy the full SHA
    6e18c46 View commit details
  2. chore(release): 2.5.0

    JounQin committed Sep 13, 2021
    Copy the full SHA
    e7edc4f View commit details
Showing with 4,206 additions and 5,636 deletions.
  1. +30 −0 .github/workflows/ci.yml
  2. +0 −28 .github/workflows/nodejs.yml
  3. +0 −1 .huskyrc.js
  4. +3 −1 .renovaterc
  5. +1 −0 .simple-git-hooks.js
  6. +12 −0 CHANGELOG.md
  7. +5 −0 LICENSE
  8. +1 −1 README.md
  9. +28 −21 package.json
  10. +21 −18 src/index.ts
  11. +1 −0 tsconfig.json
  12. +4,104 −5,566 yarn.lock
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on: [push, pull_request]

jobs:
default:
strategy:
matrix:
node:
- 12
- 14
- 16
os: [macOS-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cach: yarn

- name: Install Dependencies
run: yarn --frozen-lockfile

- name: Build, Lint and Test
run: yarn run-s build lint test typecov
env:
EFF_NO_LINK_RULES: true
PARSER_NO_WATCH: true
28 changes: 0 additions & 28 deletions .github/workflows/nodejs.yml

This file was deleted.

1 change: 0 additions & 1 deletion .huskyrc.js

This file was deleted.

4 changes: 3 additions & 1 deletion .renovaterc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"extends": "@1stg"
"extends": [
"@1stg"
]
}
1 change: 1 addition & 0 deletions .simple-git-hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@1stg/simple-git-hooks')
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.5.0](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/compare/v2.4.0...v2.5.0) (2021-09-13)


### Features

* allow passing through custom options to resolve ([#79](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/issues/79)) ([34c94c8](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/commit/34c94c87066ba42fb2b52727b95f3e34259c227f))


### Bug Fixes

* bump (dev)Dependencies, apply stricter rules ([#75](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/issues/75)) ([866f32f](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/commit/866f32f2191dc7fc8df7d973cdacefa48c64a927))

## [2.4.0](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/compare/v2.3.0...v2.4.0) (2021-02-16)


5 changes: 5 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Copyright 2021 Alex Gorbatchev <alex.gorbatchev@gmail.com>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

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.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# eslint-import-resolver-typescript

[![GitHub Actions](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/workflows/Node%20CI/badge.svg)](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/actions)
[![GitHub Actions](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/workflows/CI/badge.svg)](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/actions/workflows/ci.yml)
[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2Falexgorbatchev%2Feslint-import-resolver-typescript%2Fmaster%2Fpackage.json)](https://github.com/plantain-00/type-coverage)
[![npm](https://img.shields.io/npm/v/eslint-import-resolver-typescript.svg)](https://www.npmjs.com/package/eslint-import-resolver-typescript)
[![GitHub Release](https://img.shields.io/github/release/alexgorbatchev/eslint-import-resolver-typescript)](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/releases)
49 changes: 28 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-import-resolver-typescript",
"version": "2.4.0",
"version": "2.5.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>",
@@ -17,7 +17,8 @@
"fesm5": "lib/esm",
"types": "lib",
"files": [
"lib/*.{js,js.map,d.ts}"
"lib",
"!*.tsbuildinfo"
],
"keywords": [
"typescript",
@@ -31,11 +32,10 @@
"build:r": "r",
"build:ts": "tsc -b",
"lint": "run-p lint:*",
"lint:es": "cross-env PARSER_NO_WATCH=true eslint src --cache --ext md,js,ts -f friendly",
"lint:tsc": "tsc --incremental false --noEmit",
"prepare": "yarn-deduplicate || exit 0",
"lint:es": "eslint src --cache -f friendly",
"lint:tsc": "tsc --noEmit",
"prepare": "simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
"prepublishOnly": "yarn build",
"pretest": "r",
"release": "sh scripts/release.sh",
"test": "run-p test:*",
"test:multipleEslintrcs": "eslint --ext ts,tsx tests/multipleEslintrcs",
@@ -45,41 +45,48 @@
"test:withPathsAndNestedBaseUrl": "eslint --ext ts,tsx tests/withPathsAndNestedBaseUrl",
"test:withQuerystring": "eslint --ext ts,tsx tests/withQuerystring",
"test:withoutPaths": "eslint --ext ts,tsx tests/withoutPaths",
"type-coverage": "type-coverage --cache --detail --ignore-catch --strict --update"
"typecov": "type-coverage"
},
"peerDependencies": {
"eslint": "*",
"eslint-plugin-import": "*"
},
"dependencies": {
"debug": "^4.1.1",
"glob": "^7.1.6",
"debug": "^4.3.1",
"glob": "^7.1.7",
"is-glob": "^4.0.1",
"resolve": "^1.17.0",
"resolve": "^1.20.0",
"tsconfig-paths": "^3.9.0"
},
"devDependencies": {
"@1stg/lib-config": "^0.5.5",
"@1stg/lib-config": "^2.1.0",
"@types/debug": "^4.1.5",
"@types/glob": "^7.1.3",
"@types/is-glob": "^4.0.1",
"@types/node": "^14.6.2",
"@types/resolve": "^1.17.1",
"@types/node": "^15.6.1",
"@types/resolve": "^1.20.0",
"@types/unist": "^2.0.3",
"dummy.js": "link:dummy.js",
"eslint-import-resolver-typescript": "link:.",
"npm-run-all": "^4.1.5",
"react": "^16.13.1",
"standard-version": "^8.0.2",
"type-coverage": "^2.9.0",
"typescript": "^4.0.2",
"yarn-deduplicate": "^3.0.0"
"react": "^17.0.2",
"standard-version": "^9.3.0",
"type-coverage": "^2.17.5",
"typescript": "^4.3.2"
},
"resolutions": {
"eslint-import-resolver-typescript": "link:.",
"prettier": "^2.1.1"
"prettier": "^2.3.0"
},
"typeCoverage": {
"atLeast": 99.27
"atLeast": 99.28,
"cache": true,
"detail": true,
"ignoreAsAssertion": true,
"ignoreCatch": true,
"ignoreFiles": [
"**/*.d.ts"
],
"strict": true,
"update": true
}
}
39 changes: 21 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -15,21 +15,24 @@ const IMPORTER_NAME = 'eslint-import-resolver-typescript'

const log = debug(IMPORTER_NAME)

const defaultExtensions = ['.ts', '.tsx', '.d.ts'].concat(
// eslint-disable-next-line node/no-deprecated-api
Object.keys(require.extensions),
const defaultExtensions = [
'.ts',
'.tsx',
'.d.ts',
// eslint-disable-next-line node/no-deprecated-api, sonar/deprecation
...Object.keys(require.extensions),
'.jsx',
)
]

export const interfaceVersion = 2

export interface TsResolverOptions {
export type TsResolverOptions = SyncOpts & {
alwaysTryTypes?: boolean
/**
* @deprecated use `project` instead
*/
directory?: string | string[]
project?: string | string[]
directory?: string[] | string
project?: string[] | string
extensions?: string[]
packageFilter?: (pkg: Record<string, string>) => Record<string, string>
}
@@ -47,7 +50,7 @@ export function resolve(
found: boolean
path?: string | null
} {
options = options || {}
options = options ?? {}

log('looking for:', source)

@@ -72,10 +75,11 @@ export function resolve(
// note that even if we map the path, we still need to do a final resolve
let foundNodePath: string | null | undefined
try {
foundNodePath = tsResolve(mappedPath || source, {
extensions: options.extensions || defaultExtensions,
foundNodePath = tsResolve(mappedPath ?? source, {
...options,
extensions: options.extensions ?? defaultExtensions,
basedir: path.dirname(path.resolve(file)),
packageFilter: options.packageFilter || packageFilterDefault,
packageFilter: options.packageFilter ?? packageFilterDefault,
})
} catch {
foundNodePath = null
@@ -193,12 +197,14 @@ function initMappers(options: TsResolverOptions) {
return
}

// eslint-disable-next-line sonar/deprecation
if (options.directory) {
console.warn(
`[${IMPORTER_NAME}]: option \`directory\` is deprecated, please use \`project\` instead`,
)

if (!options.project) {
// eslint-disable-next-line sonar/deprecation
options.project = options.directory
}
}
@@ -213,28 +219,25 @@ function initMappers(options: TsResolverOptions) {
mappers = configPaths
// turn glob patterns into paths
.reduce<string[]>(
(paths, path) => paths.concat(isGlob(path) ? globSync(path) : path),
(paths, path) => [...paths, ...(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)
.map(configLoaderResult => {
const matchPath = createExtendedMatchPath(
configLoaderResult.absoluteBaseUrl,
configLoaderResult.paths,
)

return (source: string) => {
return (source: string) =>
// look for files based on setup tsconfig "paths"
return matchPath(
matchPath(
source,
undefined,
undefined,
options.extensions || defaultExtensions,
options.extensions ?? defaultExtensions,
)
}
})

mappersBuildForOptions = options
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
"extends": "./node_modules/@1stg/tsconfig/lib.json",
"compilerOptions": {
"baseUrl": ".",
"declarationMap": false,
"outDir": "lib"
},
"include": ["src"]
9,670 changes: 4,104 additions & 5,566 deletions yarn.lock

Large diffs are not rendered by default.