Skip to content

test(linter/plugins): remove directives when parsing as ES3#18636

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/01-21-test_linter_plugins_remove_directives_when_parsing_as_es3
Jan 27, 2026
Merged

test(linter/plugins): remove directives when parsing as ES3#18636
graphite-app[bot] merged 1 commit intomainfrom
om/01-21-test_linter_plugins_remove_directives_when_parsing_as_es3

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Jan 27, 2026

In ES3, directives didn't exist yet, and therefore "use strict" is treated as a standard string literal, rather than a directive.

In conformance tests, when test case specifies ES3, walk the AST and set directive property of all ExpressionStatements to null. This transforms any directives in AST into plain string literals.

Combined with #18632 which fixed "use strict" processing in TS-ESLint, this means there are 8 ESLint test cases we no longer have to skip. More importantly, we're less likely to run into erroneous test failures when testing other plugins, which are laborious to diagnose.

Copy link
Member Author

overlookmotel commented Jan 27, 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 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.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins C-test Category - Testing. Code is missing test cases, or a PR is adding them labels Jan 27, 2026
@overlookmotel overlookmotel marked this pull request as ready for review January 27, 2026 18:36
Copilot AI review requested due to automatic review settings January 27, 2026 18:36
@overlookmotel overlookmotel self-assigned this Jan 27, 2026
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 enables parsing ES3-compliant test cases by converting directives to plain string literals when ecmaVersion: 3 is specified in conformance tests. In ES3, directives like "use strict" didn't exist, so they should be treated as regular string literals rather than directives.

Changes:

  • Added ES3 AST transformation logic that traverses the AST and sets directive property to null for all ExpressionStatement nodes when parsing as ES3
  • Exported ecmaVersion variable from context.ts to enable ES3 detection in the AST transformation
  • Removed workarounds that were skipping 8 ESLint test cases for no-eval, no-invalid-this, and no-unused-expressions rules

Reviewed changes

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

File Description
apps/oxlint/src-js/plugins/source_code.ts Added fixES3Ast(), fixES3NodesArray(), and fixES3Node() functions to traverse AST and convert directives to string literals when ecmaVersion === 3; integrated transformation into initAst()
apps/oxlint/src-js/plugins/context.ts Exported ecmaVersion variable to allow ES3 detection in source_code.ts
apps/oxlint/conformance/src/groups/eslint.ts Removed workaround that was skipping ES3 test cases for no-eval, no-invalid-this, and no-unused-expressions rules
apps/oxlint/conformance/snapshots/eslint.md Updated test statistics showing 8 additional tests now passing (from 32873 to 32881) and 8 fewer skipped (from 286 to 278)

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

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Jan 27, 2026
Copy link
Member Author

overlookmotel commented Jan 27, 2026

Merge activity

In ES3, directives didn't exist yet, and therefore `"use strict"` is treated as a standard string literal, rather than a directive.

In conformance tests, when test case specifies ES3, walk the AST and set `directive` property of all `ExpressionStatement`s to `null`. This transforms any directives in AST into plain string literals.

Combined with #18632 which fixed `"use strict"` processing in TS-ESLint, this means there are 8 ESLint test cases we no longer have to skip. More importantly, we're less likely to run into erroneous test failures when testing other plugins, which are laborious to diagnose.
@graphite-app graphite-app bot force-pushed the om/01-27-test_linter_plugins_fix_impliedstrict_in_es3 branch from c2f4cc5 to 4e08b91 Compare January 27, 2026 18:42
@graphite-app graphite-app bot force-pushed the om/01-21-test_linter_plugins_remove_directives_when_parsing_as_es3 branch from 602e15b to 1363943 Compare January 27, 2026 18:43
Base automatically changed from om/01-27-test_linter_plugins_fix_impliedstrict_in_es3 to main January 27, 2026 18:49
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 27, 2026
@graphite-app graphite-app bot merged commit 1363943 into main Jan 27, 2026
20 checks passed
@graphite-app graphite-app bot deleted the om/01-21-test_linter_plugins_remove_directives_when_parsing_as_es3 branch January 27, 2026 18:49
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-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants