diff --git a/.github/workflows/pkg-pr-new.yml b/.github/workflows/pkg-pr-new.yml index bf184a3..ee2cdc1 100644 --- a/.github/workflows/pkg-pr-new.yml +++ b/.github/workflows/pkg-pr-new.yml @@ -1,4 +1,5 @@ name: Publish Any Commit + on: - push - pull_request diff --git a/CHANGELOG.md b/CHANGELOG.md index 08d2425..d2a5362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 4.4.2 + +### Patch Changes + +- [#459](https://github.com/import-js/eslint-import-resolver-typescript/pull/459) [`f16150b`](https://github.com/import-js/eslint-import-resolver-typescript/commit/f16150b5e10ec24a3f1f107d6322816338c50dc8) Thanks [@carlocorradini](https://github.com/carlocorradini)! - fix: always sort projects by affinity before iterating + ## 4.4.1 ### Patch Changes diff --git a/README.md b/README.md index 5d1a96e..4405eee 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # eslint-import-resolver-typescript [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/import-js/eslint-import-resolver-typescript/ci.yml?branch=master)](https://github.com/import-js/eslint-import-resolver-typescript/actions/workflows/ci.yml?query=branch%3Amaster) +[![Codecov](https://img.shields.io/codecov/c/github/import-js/eslint-import-resolver-typescript.svg)](https://codecov.io/gh/import-js/eslint-import-resolver-typescript) [![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%2Fimport-js%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/import-js/eslint-import-resolver-typescript)](https://github.com/import-js/eslint-import-resolver-typescript/releases) @@ -45,6 +46,7 @@ This means you can: - [Backers](#backers) - [Changelog](#changelog) - [License](#license) +- [Star History](#star-history) ## Notice @@ -363,6 +365,16 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m [ISC][] +## Star History + + + + + + Star History Chart + + + [`eslint-plugin-import`]: https://github.com/import-js/eslint-plugin-import [`eslint-plugin-import-x`]: https://github.com/un-ts/eslint-plugin-import-x [`unrs-resolver`]: https://github.com/unrs/unrs-resolver diff --git a/package.json b/package.json index 33c94bf..0c2683c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-import-resolver-typescript", - "version": "4.4.1", + "version": "4.4.2", "type": "module", "description": "This plugin adds `TypeScript` support to `eslint-plugin-import`", "repository": "https://github.com/import-js/eslint-import-resolver-typescript", diff --git a/src/index.ts b/src/index.ts index 60db5ec..fb16fb1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -95,9 +95,9 @@ export const resolve = ( // eslint-disable-next-line sonarjs/label-position, sonarjs/no-labels createResolver: if (!resolver) { - // must be a array with 2+ items here already ensured by `normalizeOptions` - const project = options.project as string[] - for (const tsconfigPath of project) { + // must be an array with 2+ items here already ensured by `normalizeOptions` + const projects = sortProjectsByAffinity(options.project as string[], file) + for (const tsconfigPath of projects) { const resolverCached = resolverCache.get(tsconfigPath) if (resolverCached) { resolver = resolverCached @@ -135,24 +135,23 @@ export const resolve = ( }, } resolver = new ResolverFactory(options) - resolverCache.set(tsconfigPath, resolver) - break createResolver + const resolved = resolve(source, file, options, resolver) + if (resolved.found) { + resolverCache.set(tsconfigPath, resolver) + return resolved + } } log( 'no tsconfig matched', file, 'with', - ...project, - ', trying from the the nearest one', + ...projects, + ', trying from the the nearest one instead', ) - for (const p of sortProjectsByAffinity(project, file)) { - const resolved = resolve( - source, - file, - { ...options, project: p }, - resolver, - ) + + for (const project of projects) { + const resolved = resolve(source, file, { ...options, project }, resolver) if (resolved.found) { return resolved }