Skip to content

Support declaring internal module regex or respect import/internal-regex setting #227

Open
@harunurhan

Description

@harunurhan

Resolver performs way too slow on a medium to large TS project where every local/internal import is absolute from the project root, since

if (RELATIVE_PATH_PATTERN.test(source)) {
optimization branch is not used.

It would be useful to allow users to specify internalRegex similar to https://github.com/import-js/eslint-plugin-import/tree/a89eadf3247af844da6b0f9e7bca7690777bf665#importinternal-regex.

Worth mentioning that using above import/internal-regex did speed up the linting times, but unexpectedly I have seen more improvements when implemented a custom resolver like below using the same regexp, so perhaps there is a bug (or misunderstanding) there and no new option is needed, just addressing that one.

export function resolve(
    importPath: string,
    importerFileAbsolutePath: string,
    tsResolverOptions: TsResolverOptions
): ResolveResult {
    if (internalModuleRegexp.test(importPath)) {
        const absoluteImportPath = path.resolve(`./${importPath}`);
        return {
            found: true,
            path: absoluteImportPath,
        };
    }

    return eslintImportResolverTypescript.resolve(importPath, importerFileAbsolutePath, tsResolverOptions);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions