Skip to content

Conversation

@simonbuchan
Copy link
Contributor

@simonbuchan simonbuchan commented Jul 14, 2025

Fixes #12258

Not super sure about the config path normalization, but it Works On My Machine™️! Only other example of <cwd> in linter snapshots is the tsconfig error, which explicitly formats the error at that location.

Might be nicer to regex the snapshot for any paths to handle Windows, the current cwd detection in there seems a bit hacky anyway.

@simonbuchan simonbuchan requested a review from camc314 as a code owner July 14, 2025 07:29
@graphite-app
Copy link
Contributor

graphite-app bot commented Jul 14, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-cli Area - CLI C-bug Category - Bug labels Jul 14, 2025
@simonbuchan
Copy link
Contributor Author

Dang it. absolute() doesn't actually validate the file exists...

@simonbuchan
Copy link
Contributor Author

I've tried a few options, but they're all pretty messy - the simplest I can think of is to introduce Oxlintrc::try_from_file() that returns a richer error that can be introspected or Oxlintrc::from_file_if_exists(path: &Path) -> Result<Option<Self>, OxcDiagnostics>?

@camc314
Copy link
Contributor

camc314 commented Jul 14, 2025

oh thatnks for this, i've seen this error before, let me fix it

@simonbuchan
Copy link
Contributor Author

Yeah, plenty of ways to fix this but I'm not sure what the conventions are well enough to start hacking on something this core.

@camc314
Copy link
Contributor

camc314 commented Jul 14, 2025

basically we need to use

        let handler = if cfg!(any(test, feature = "force_test_reporter")) {
            GraphicalReportHandler::new_themed(miette::GraphicalTheme::none())
        } else {
            GraphicalReportHandler::new()
        };

to report the error else you get diff snapshots in CI vs locally

@simonbuchan
Copy link
Contributor Author

If you're picking this up, seems my issue is a duplicate of #12073, which also points out the nested override config files have the same issue.

@simonbuchan
Copy link
Contributor Author

I'll take another stab tomorrow otherwise!

@simonbuchan
Copy link
Contributor Author

Note the actual test failures are because absolute() isn't checking the file exists, despite the existing logic implying that it does. The from_file() method buries the distinction in an OxcDiagnostic which prevents the caller from treating them separately. Switching to from_string() does work somewhat but breaks the error messages. Fixing that basically impacts the whole CLI though, which is a bit too scary for me right now!

@camc314
Copy link
Contributor

camc314 commented Jul 14, 2025

touch wood, this update should work now 🤞

@camc314
Copy link
Contributor

camc314 commented Jul 14, 2025

oxc/apps/oxlint/src/lint.rs

Lines 508 to 513 in 42d6bd7

Oxlintrc::from_file(&possible_config_path).map_err(|e| {
let handler = GraphicalReportHandler::new();
let mut err = String::new();
handler.render_report(&mut err, &e).unwrap();
err
})

we should also remove use of GraphicalReportHandler::new() here and instead propogate the OxcDiagnostic

@camc314 camc314 merged commit 9720774 into oxc-project:main Jul 14, 2025
15 checks passed
@simonbuchan
Copy link
Contributor Author

Simple enough in the end, thanks for cleaning my mess up!

@camc314
Copy link
Contributor

camc314 commented Jul 14, 2025

thanks for contributing!

camc314 added a commit that referenced this pull request Jul 16, 2025
## [1.7.0] - 2025-07-16

### 🚀 Features

- 5e428a4 linter/eslint-plugin-next: No-html-link-for-pages rule
addition (#12194) (Gabriel Díaz Aguilera)
- 9b14fbc ast: Add `ThisExpression` to `TSTypeName` (#12156) (Boshen)
- c551b8f linter: Report diagnostics from custom plugins (#12219)
(camc314)
- d387729 linter: JS custom rules config (#12160) (camc314)
- 152e59d napi/oxlint: Read source text into start of allocator (#12122)
(overlookmotel)
- bde1ef1 linter: Load custom JS plugins (#11980) (camc314)
- d4ebd14 linter: Add `oxlint2`/`disable_oxlint2` feature flags (#12130)
(camc314)
- a4dae73 linter: Introduce `LintPlugins` to store builtin + custom
plugins (#12117) (camc314)

### 🐛 Bug Fixes

- 3f9a1f0 linter/no-unused-private-class-members: Fix false positive
with nullish coalescing assignments (#12317) (camc314)
- 47fad0e linter/no-empty-file: False positive with empty file with
triple slash directive (#12293) (camc314)
- 633ba30 linter: False positive with unknown plugins when unmatched
eslint rule (#12285) (camc314)
- 9720774 linter: Report implicit config parse errors (#12260) (Simon
Buchan)
- 1920c6b language_server: Respect the root `.oxlintrc.json` file for
`ignorePatterns` (#12171) (Sysix)
- 98708eb linter: Fix inconsistent behavior in `no-duplicate-imports`
rule (#12192) (yefan)
- 853d2bc linter, language_server: Correctly identify usage of `import`
plugin (#12157) (overlookmotel)

### 🚜 Refactor

- ee761de ast: Remove `AstKind` for `AssignmentTarget` (#12252) (Tyler
Earls)
- c68b607 ast: Rename `TemplateLiteral::quasi` to
`TemplateLiteral::single_quasi` (#12266) (Dunqing)
- 32c32af ast: Check whether there is a single `quasi` in
`TemplateLiteral::quasi` (#12265) (Dunqing)
- 8f6a1da linter/js-plugins: Use `u32` for IDs (#12243) (overlookmotel)
- 36cd364 linter/js-plugins: Clean up code (#12242) (overlookmotel)
- 8c02ebd linter/js-plugins: Rename `specifiers` to `paths` (#12241)
(overlookmotel)
- 3adaf98 linter: Simplify getting nodes count (#12239) (overlookmotel)
- 6e54645 language_server: Store `LintService` instead of `Linter`
(#12016) (Sysix)
- 113cf8c linter: Move `LintServiceOptions.paths` to
`LintService.with_paths` (#12015) (Sysix)
- acfac68 oxlint: Adjust ignore patterns by counting bytes instead of
chars (#12209) (Sysix)
- 729b82b linter: Rename `plugin_name` to `plugin_specifier` (#12148)
(overlookmotel)
- 532b816 linter: Use `to_string` instead of `into` (#12147)
(overlookmotel)
- 89f2a69 linter: TODO comment (#12146) (overlookmotel)
- f90d3e1 linter: Feature gate `load_external_plugin` by both `oxlint2`
and `disable_oxlint2` features (#12141) (overlookmotel)
- 12e4ec7 linter: Make `tokio` dependency optional (#12140)
(overlookmotel)
- 1d2eaca oxlint2: Introduce `force_test_reporter` feature for
consistent graphical outputs (#12133) (camc314)
- 8814c53 ast: Remove `AstKind` for `PropertyKey` (#12108) (camchenry)
- 228cff5 semantic,linter: Assert that Program is always the first node
(#12123) (Ulrich Stark)
- e8e2a25 ast: Remove `AstKind` for `AssignmentTargetPattern` (#12105)
(camchenry)
- f7c675d linter: Rename `LintPlugins` to `BuiltinLintPlugins` (#12116)
(camc314)
- a9e5ec0 linter: Access plugins through config instead of storing
directly (#12115) (camc314)
- 9736a7f linter: Simplify `unicorn/require-post-message-target-origin`
(#12110) (shulaoda)

### 📚 Documentation

- 2e3db46 linter: Add missing backtick preventing website from building
(#12113) (camc314)

### ⚡ Performance

- d0f8b88 linter/js-plugins: Do not copy `Vec` (#12248) (overlookmotel)
- 4284d19 linter/js-plugins: Use hashmap `Entry` API + remove temp `Vec`
(#12247) (overlookmotel)
- c7889c3 semantic,linter: Simplify implementation and uses of ancestors
iterators (#12164) (Ulrich Stark)
- f99959c linter: Move work out of loop (#12145) (overlookmotel)
- 514d40c linter: Do not create `Resolver` unless required (#12142)
(overlookmotel)
- 7103527 linter/no-constructor-return: Optimize loop (#12138)
(overlookmotel)

### 🧪 Testing

- d1194e8 oxlint: Ignore test on windows (#12262) (camc314)

Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: implicit .oxlintrc.json parse error uses default lint rules

2 participants