Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 9, 2025

Add an option to RuleTester to ignore non-fatal parsing errors.

const tester = new RuleTester({
  languageOptions: {
    sourceType: "module",
    parserOptions: {
      ignoreNonFatalErrors: true,
    },
  },
});

tester.run("my-rule", rule, {
  valid: [
    // This is invalid code, but it gets a pass
    "function f(x, x) {}",
  ],
  invalid: [],
});

This will be useful in conformance tests, because ESLint's tests contain invalid syntax in many of their test cases!

@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 Dec 9, 2025
Copy link
Member Author

overlookmotel commented Dec 9, 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.

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

@overlookmotel overlookmotel marked this pull request as ready for review December 9, 2025 23:51
Copilot AI review requested due to automatic review settings December 9, 2025 23:51
@overlookmotel overlookmotel self-assigned this Dec 9, 2025
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Dec 9, 2025
Copy link
Member Author

overlookmotel commented Dec 9, 2025

Merge activity

  • Dec 9, 11:54 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Dec 9, 11:54 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Dec 9, 11:57 PM UTC: overlookmotel added this pull request to the Graphite merge queue.
  • Dec 10, 12:08 AM UTC: Merged by the Graphite merge queue.

@graphite-app graphite-app bot changed the base branch from 12-09-test_linter_plugins_add_1_more_test_case_for_sourcetype_in_ruletester_ to graphite-base/16672 December 9, 2025 23:54
@graphite-app graphite-app bot changed the base branch from graphite-base/16672 to main December 10, 2025 00:01
…r` (#16672)

Add an option to `RuleTester` to ignore non-fatal parsing errors.

```js
const tester = new RuleTester({
  languageOptions: {
    sourceType: "module",
    parserOptions: {
      ignoreNonFatalErrors: true,
    },
  },
});

tester.run("my-rule", rule, {
  valid: [
    // This is invalid code, but it gets a pass
    "function f(x, x) {}",
  ],
  invalid: [],
});
```

This will be useful in conformance tests, because ESLint's tests contain invalid syntax in many of their test cases!
@graphite-app graphite-app bot force-pushed the 12-09-feat_linter_plugins_add_ignorenonfatalerrors_option_to_ruletester_ branch from 227caf0 to e39f487 Compare December 10, 2025 00:02
Copy link
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

This PR adds an ignoreNonFatalErrors option to RuleTester to allow parsing to continue despite non-fatal parsing errors. This feature is designed to support ESLint conformance tests, which often contain intentionally invalid syntax in test cases. When enabled, the parser will ignore parsing and semantic errors (but not panics), allowing the linter to still run on the partially-valid AST.

Key changes:

  • Added ignoreNonFatalErrors boolean option to parser options, configurable at global, RuleTester instance, or individual test case level
  • Implemented proper option merging with right-to-left precedence (local overrides base)
  • Optimized to skip semantic analysis when errors are being ignored

Reviewed changes

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

File Description
apps/oxlint/src/js_plugins/parse.rs Adds Rust-side handling of ignore_non_fatal_errors option, modifying parsing failure detection logic and skipping semantic analysis when errors are ignored
apps/oxlint/src-js/package/rule_tester.ts Adds TypeScript interface for ignoreNonFatalErrors, implements option extraction in getParseOptions, and adds mergeParserOptions helper for proper config merging
apps/oxlint/src-js/bindings.d.ts Auto-generated NAPI bindings with new ignoreNonFatalErrors field in ParserOptions interface
apps/oxlint/test/rule_tester.test.ts Comprehensive test suite covering default behavior, global/instance/test-case level configuration, overriding behavior, and mixed scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@graphite-app graphite-app bot merged commit e39f487 into main Dec 10, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 12-09-feat_linter_plugins_add_ignorenonfatalerrors_option_to_ruletester_ branch December 10, 2025 00:08
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 10, 2025
Copilot AI pushed a commit that referenced this pull request Dec 10, 2025
…r` (#16672)

Add an option to `RuleTester` to ignore non-fatal parsing errors.

```js
const tester = new RuleTester({
  languageOptions: {
    sourceType: "module",
    parserOptions: {
      ignoreNonFatalErrors: true,
    },
  },
});

tester.run("my-rule", rule, {
  valid: [
    // This is invalid code, but it gets a pass
    "function f(x, x) {}",
  ],
  invalid: [],
});
```

This will be useful in conformance tests, because ESLint's tests contain invalid syntax in many of their test cases!
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.

2 participants