Skip to content
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

Oxlint reports incorrect errors when it receives a relative path starting with .. #1887

Closed
ah-yu opened this issue Jan 4, 2024 · 6 comments · Fixed by #2125
Closed

Oxlint reports incorrect errors when it receives a relative path starting with .. #1887

ah-yu opened this issue Jan 4, 2024 · 6 comments · Fixed by #2125
Assignees

Comments

@ah-yu
Copy link

ah-yu commented Jan 4, 2024

test_repo % npx oxlint@latest --import-plugin ../test_repo 
× Failed to open file "test_repo/foo/bar/index.js" with error "No such file or directory (os error 2)"
help: Failed to open file "test_repo/foo/bar/index.js" with error "No such file or directory (os error 2)"

The error reported by oxlint appears to be incorrect. In fact, the file test_repo/foo/bar/index.js exists. It seems to be an issue related to oxc_resolver.

// enhanced resolver
resolve.sync("../test_repo/foo/bar", "../main") // returns "../test_repo/foo/main.js"

// oxc_resolver
resolver.resolve("../test_repo/foo/bar", "../main").unwrap() // returns "test_repo/foo/main.js"
@IWANABETHATGUY
Copy link
Contributor

@IWANABETHATGUY
Copy link
Contributor

the implementation of oxc_resolver does not looks wrong, call site could canonicalize the path before resolving, here is a example https://github.com/oxc-project/oxc_resolver/blob/4585b370614fdfc8cd8c473e94c0aa35770f82ef/examples/resolver.rs#L10-L10.

@IWANABETHATGUY
Copy link
Contributor

I can replicate the issue with a relative path, could you provide a reproduce repo?

@ah-yu
Copy link
Author

ah-yu commented Jan 4, 2024

could you provide a reproduce repo?

https://github.com/ah-yu/resolver-test

@IWANABETHATGUY
Copy link
Contributor

  ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
   ╭─[../test_repo/foo/bar/index.js:1:1]
   ╰────
  help: Delete this file or add some code to it.

  × Failed to open file "test_repo/foo/bar/index.js" with error "No such file or directory (os error 2)"
  help: Failed to open file "test_repo/foo/bar/index.js" with error "No such file or directory (os error 2)"

looks like we read the same file twice when enabling import-plugin ? @Boshen

@IWANABETHATGUY IWANABETHATGUY self-assigned this Jan 7, 2024
Boshen added a commit that referenced this issue Jan 22, 2024
Linting parent directories introduces undefined behavior because
the intention is not clear. This is a future proof precaution.

closes #1887
@Boshen
Copy link
Member

Boshen commented Jan 22, 2024

I decided to disallow supplying paths pointing to parent directories, the intention is not clear and it will introduce undefined behaviour.

@Boshen Boshen closed this as completed Jan 22, 2024
Boshen added a commit that referenced this issue Jan 22, 2024
Linting parent directories introduces undefined behavior because
the intention is not clear. This is a future proof precaution.

closes #1887
IWANABETHATGUY pushed a commit to IWANABETHATGUY/oxc that referenced this issue May 29, 2024
…2125)

Linting parent directories introduces undefined behavior because
the intention is not clear. This is a future proof precaution.

closes oxc-project#1887
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants