Skip to content

fix: do not consider resolved path in extensions rule #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/rules/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@

const resolvedPath = resolve(importPath, context)

// get extension from resolved path, if possible.
// for unresolved, use source value.
const extension = path.extname(resolvedPath || importPath).slice(1)
Copy link
Member

@JounQin JounQin Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is incorrect for resolving .xyz but ./abc.js or ./abc is imported.

const extension =
path.extname(importPath)?.slice?.(1) ||
path.extname(resolvedPath).slice(1)

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / publish

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 22 and ESLint 8 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 22 and ESLint 9 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js lts/* and ESLint 9 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 9 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js lts/* and ESLint 9 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8.56 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 24 and ESLint 8.56 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 22 and ESLint 8.56 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 24 and ESLint 8 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 18 and ESLint 8 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 18 and ESLint 9 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 18 and ESLint 9 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 22 and ESLint 8.56 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 22 and ESLint 9 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8.56 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 24 and ESLint 9 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 24 and ESLint 9 on ubuntu-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 9 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 22 and ESLint 9 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 22 and ESLint 8 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 22 and ESLint 8 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 18 and ESLint 8.56 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 18 and ESLint 8 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 24 and ESLint 8.56 on macos-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 9 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 22 and ESLint 8.56 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 24 and ESLint 8 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

Check failure on line 333 in src/rules/extensions.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 24 and ESLint 9 on windows-latest

Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'.

// determine if this is a module
const isPackage =
Expand Down
Loading