Skip to content

feat(linter): add hint about node version when ts config fail to import#20570

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-20-feat_linter_add_hint_about_node_version_when_ts_config_fail_to_import
Mar 25, 2026
Merged

feat(linter): add hint about node version when ts config fail to import#20570
graphite-app[bot] merged 1 commit intomainfrom
c/03-20-feat_linter_add_hint_about_node_version_when_ts_config_fail_to_import

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Mar 20, 2026

fixes #20467

I tested this locally:

Failed to parse oxlint configuration file.

  x Failed to load config: <fixture>/oxlint.config.ts
  | 
  | TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for <fixture>/oxlint.config.ts
  | 
  | TypeScript config files require Node.js ^20.19.0 || >=22.12.0.
  | Detected Node.js v22.11.0.
  | Please upgrade Node.js or use a JSON config file instead.

@camc314 camc314 marked this pull request as ready for review March 20, 2026 16:27
@camc314 camc314 requested a review from overlookmotel as a code owner March 20, 2026 16:27
Copilot AI review requested due to automatic review settings March 20, 2026 16:27
@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins C-enhancement Category - New feature or request labels Mar 20, 2026
@camc314 camc314 self-assigned this Mar 20, 2026
Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 20, 2026


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 changes, fast-track this PR to the front of the merge queue

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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a more actionable error hint when loading JS/TS config files fails due to Node.js lacking native TypeScript module support, so users get guided toward upgrading Node or using a JSON config instead.

Changes:

  • Introduces a utility to detect “unknown file extension” failures for TS module specifiers and format a Node version upgrade hint.
  • Wires that hint into loadJsConfigs() failure aggregation so it can be surfaced to users.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
apps/oxlint/src-js/utils/node_version.ts New helper for detecting TS module load failures and generating a Node version hint.
apps/oxlint/src-js/js_config.ts Uses the new helper to enrich config-import failure messages.

@camc314 camc314 force-pushed the c/03-20-feat_linter_add_hint_about_node_version_when_ts_config_fail_to_import branch 2 times, most recently from 79fe25d to 04851bb Compare March 20, 2026 16:33
@camc314 camc314 assigned overlookmotel and unassigned camc314 Mar 20, 2026
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

The change looks correct, but a rather convoluted implementation! "is this a TS file" check could be as simple as:

const index = path.lastIndexOf(".");
const isTs = index >= 0 && ["ts", "mts", "cts"].includes(path.slice(index + 1));

And do we support .mts / .cts config files anyway?

But it's all on cold path, so I guess it doesn't really matter. The better error message is definitely desirable.

@overlookmotel
Copy link
Copy Markdown
Member

Oh actually what I said in my last comment was wrong, due to ?cache=... being appended to path. But it sounds like Copilot's point is valid.

It might be simpler to just pass process.version from JS to Rust at process start-up, and handle this on Rust side. If TS is not supported, and they're using a TS config file, no point even calling into JS to try to load the config - we know it'll fail.

@camc314
Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 24, 2026

And do we support .mts / .cts config files anyway?

We support --config foo.mts for example.

It might be simpler to just pass process.version from JS to Rust at process start-up, and handle this on Rust side. If TS is not supported, and they're using a TS config file, no point even calling into JS to try to load the config - we know it'll fail.

this is a little more complex + we would have to handle bun/deno & other runtime versions i guess?

I think it's ok for this to be on the cold path on the JS side

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 24, 2026
@camc314 camc314 assigned camc314 and unassigned overlookmotel Mar 24, 2026
Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 24, 2026

Merge activity

  • Mar 24, 11:47 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 24, 11:47 AM UTC: camc314 added this pull request to the Graphite merge queue.
  • Mar 24, 11:51 AM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Test NAPI Oxlint').
  • Mar 25, 8:58 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 25, 8:58 PM UTC: camc314 added this pull request to the Graphite merge queue.
  • Mar 25, 8:58 PM UTC: Merged by the Graphite merge queue.

graphite-app bot pushed a commit that referenced this pull request Mar 24, 2026
…rt (#20570)

fixes #20467

I tested this locally:

```
Failed to parse oxlint configuration file.

  x Failed to load config: <fixture>/oxlint.config.ts
  |
  | TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for <fixture>/oxlint.config.ts
  |
  | TypeScript config files require Node.js ^20.19.0 || >=22.12.0.
  | Detected Node.js v22.11.0.
  | Please upgrade Node.js or use a JSON config file instead.
```
@graphite-app graphite-app bot force-pushed the c/03-20-feat_linter_add_hint_about_node_version_when_ts_config_fail_to_import branch from 04851bb to 0f2388a Compare March 24, 2026 11:47
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 24, 2026
…rt (#20570)

fixes #20467

I tested this locally:

```
Failed to parse oxlint configuration file.

  x Failed to load config: <fixture>/oxlint.config.ts
  |
  | TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for <fixture>/oxlint.config.ts
  |
  | TypeScript config files require Node.js ^20.19.0 || >=22.12.0.
  | Detected Node.js v22.11.0.
  | Please upgrade Node.js or use a JSON config file instead.
```
@camc314 camc314 force-pushed the c/03-20-feat_linter_add_hint_about_node_version_when_ts_config_fail_to_import branch from 0f2388a to 27374e8 Compare March 25, 2026 20:13
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 25, 2026
@graphite-app graphite-app bot merged commit 27374e8 into main Mar 25, 2026
24 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 25, 2026
@graphite-app graphite-app bot deleted the c/03-20-feat_linter_add_hint_about_node_version_when_ts_config_fail_to_import branch March 25, 2026 20:58
graphite-app bot pushed a commit that referenced this pull request Mar 30, 2026
# Oxlint
### 💥 BREAKING CHANGES

- c0ebbce linter: [**BREAKING**] Report error on unknown builtin rule (#20464) (camc314)

### 🚀 Features

- 04f85e5 linter/no-unused-vars: Add safe-fix option for import fixes (#20839) (Marcell Toth)
- 32a3706 linter/eslint-vitest-plugin: Implements `require-test-timeout` rule (#20806) (Said Atrahouch)
- ae03653 linter: Implement suggestion for `eslint/no-useless-computed-key` rule (#20805) (Mikhail Baev)
- 6624513 linter/prefer-string-starts-ends-with: Move rule from nursery to style (#20797) (camc314)
- 58941f8 linter/prefer-readonly: Move rule from nursery to style (#20796) (camc314)
- 8837ffd linter/prefer-regexp-exec: Move rule from nursery to style (#20795) (camc314)
- 7e88871 linter/prefer-find: Move rule out of nursery (#20794) (camc314)
- ca6e5bc linter/vitest: Implement prefer-called-exactly-once-with (#17562) (Said Atrahouch)
- e80c0bf linter/eslint-plugin-vitest: Implement `require-mock-type-parameters` (#20785) (Said Atrahouch)
- cec8b8f linter/vitest: Implement require-awaited-expect-poll rule (#20702) (Said Atrahouch)
- d8e9d01 linter/eslint-plugin-vitest: Set `prefer-to-have-been-called-times` compatible with jest (#20703) (Said Atrahouch)
- caf8231 linter: Enhance import plugin diagnostics with help messages (#20766) (离谱)
- f44adfa linter: Improve the oxlint config generated by `--init`. (#20632) (connorshea)
- 43f4827 linter: Add help text to jest and promise diagnostics (#20640) (kszongic)
- 16516de linter: Enhance types for `DummyRule` (#20751) (camc314)
- 27374e8 linter: Add hint about node version when ts config fail to import (#20570) (camc314)
- 8e34150 linter/eslint-plugin-vitest: Sync rule with JS implementation (#20679) (Said Atrahouch)

### 🐛 Bug Fixes

- df057d5 linter/no-noninteractive-tabindex: Add missing composite widget … (#20860) (bab)
- bb34073 linter: Mark vitest/valid-title as a compatible jest rules (#20463) (Nicolas Le Cam)
- bd2c76b linter: Handle shadowed locals in no-restricted-globals (#20811) (Ulrich Stark)
- 62e39be linter: Sort nested object keys in fix of `eslint/sort-keys` in one pass (#20838) (Ulrich Stark)
- 3ef37da oxlint/lsp: Error on unknown command (#20841) (Sysix)
- ab1070d oxlint/cli: Skip parsing base config again for nested config search (#20809) (Sysix)
- 2be3728 oxlint/lsp: Skip parsing base config again for nested config search (#20808) (Sysix)
- 6171217 oxlint: Respect `NO_COLOR` env for `format=stylish` (#20804) (Sysix)
- d89ae8f linter/plugins: Patch `WeakMap` to emulate `WeakMap`s keyed by `sourceCode` (#20799) (overlookmotel)
- c610666 linter/no-shadow: Respect env settings when builtinGlobals is enabled (#20429) (vvnikita74)
- 6bb502f linter/no-invalid-void-type: Allow void generic args in heritage clauses (#20780) (camc314)
- 365bb7d linter: Skip typed nested literals in explicit-module-boundary-types (#20776) (camc314)
- 0aa1ff0 linter/plugins: Ensure `after` hook is always called in ESLint compat mode (#20721) (overlookmotel)
- 31145a9 linter/plugins: Fire `after` hook after CFG events in ESLint compat (#20720) (overlookmotel)
- c09a5ab diagnostics: Skip minified fallback for single-line reporters (#20716) (camc314)
- e4dc9a1 linter: Isolate `--init` config writes from parallel tests (#20717) (camc314)
- 7e394ec linter: Clarify empty replacement fixer help text (#20698) (camc314)
- d15a99c linter/jsx-curly-brace-presence: Flag empty string literals (#20690) (camc314)

### 📚 Documentation

- c722495 linter: Update JS Plugins + LS references (#20843) (camc314)
- e1f9748 linter/jsdoc/require-property: Fix typo (#20792) (Benjaming61001)
- be3dcc1 linter: Add note about node version + custom TS plugin (#19381) (camc314)
# Oxfmt
### 🚀 Features

- 6ef440a oxfmt: Support bool for object style options (#20853) (leaysgur)
- 23050fa oxfmt: Support markdown-in-js substitution (#20683) (leaysgur)
- 4087295 oxfmt: Support angular-in-js substitution (#20676) (leaysgur)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: report a hint about node version when using a TS config on an old node version

3 participants