Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Nov 20, 2025

Contents of this test snapshot depends on the constructor names of scope class instances. This is a little fragile, as they can change depending on how the code is bundled (see #15861 (comment)).

At some point, we'll full minify the bundle, at which point class names will be come random gibberish like e, t, aZ, etc.

Avoid this problem by outputting type field of scope objects instead.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI C-test Category - Testing. Code is missing test cases, or a PR is adding them labels Nov 20, 2025
Copy link
Member Author


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 November 20, 2025 11:00
Copilot AI review requested due to automatic review settings November 20, 2025 11:00
@overlookmotel overlookmotel self-assigned this Nov 20, 2025
Copilot finished reviewing on behalf of overlookmotel November 20, 2025 11:01
@overlookmotel
Copy link
Member Author

@lilnasy Would you mind reviewing? I'm not sure if you did it this way because you specifically wanted to check what class the scopes are?

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 refactors the scope manager test snapshot to use the type field of scope objects instead of constructor names, making the test more robust against code bundling variations.

  • Replaces s.constructor.name with s.type for scope identification
  • Updates output format to use newline-separated list with - prefix for better readability
  • Changes scope naming format from angle brackets to parentheses for named scopes (e.g., function(topLevelFunction))

Reviewed Changes

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

File Description
apps/oxlint/test/fixtures/scope_manager/plugin.ts Refactored message generation to use s.type field and improved formatting with newline separation
apps/oxlint/test/fixtures/scope_manager/output.snap.md Updated snapshot to reflect new scope output format with type-based naming

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

Copy link
Contributor

@lilnasy lilnasy left a comment

Choose a reason for hiding this comment

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

This is great!

@overlookmotel overlookmotel added A-linter-plugins Area - Linter JS plugins 0-merge Merge with Graphite Merge Queue labels Nov 20, 2025
Copy link
Member Author

overlookmotel commented Nov 20, 2025

Merge activity

…pshot (#15906)

Contents of this test snapshot depends on the constructor names of scope class instances. This is a little fragile, as they can change depending on how the code is bundled (see #15861 (comment)).

At some point, we'll full minify the bundle, at which point class names will be come random gibberish like `e`, `t`, `aZ`, etc.

Avoid this problem by outputting `type` field of scope objects instead.
@graphite-app graphite-app bot force-pushed the 11-20-test_linter_plugins_avoid_using_scope_constructor_names_in_test_snapshot branch from a690858 to 15d367a Compare November 20, 2025 14:00
@graphite-app graphite-app bot merged commit 15d367a into main Nov 20, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 11-20-test_linter_plugins_avoid_using_scope_constructor_names_in_test_snapshot branch November 20, 2025 14:06
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 20, 2025
Copilot AI pushed a commit that referenced this pull request Nov 21, 2025
…pshot (#15906)

Contents of this test snapshot depends on the constructor names of scope class instances. This is a little fragile, as they can change depending on how the code is bundled (see #15861 (comment)).

At some point, we'll full minify the bundle, at which point class names will be come random gibberish like `e`, `t`, `aZ`, etc.

Avoid this problem by outputting `type` field of scope objects instead.
overlookmotel added a commit that referenced this pull request Nov 21, 2025
…ementation) (#15861)

- "Slow but working" implementation for
#14829 (comment)
- Uses the parser from `@typescript-eslint/typescript-estree` for
tokens. The source code is fully parsed and everything but the tokens
and comments is discarded.
- Tests are directly adapted from `eslint`.
- Direct commits from maintainers welcome.

### Tasks
- [x] `getTokens`
- [x] Move token types to `src-js/plugins/tokens.ts`
- [x] Bundle typescript, handling `_filename` usage in ES modules.
- [x] ~[Prevent class name mangling by
`tsdown`](#15861 (comment)).
Could be deferred.~
#15906 (review)
- [x] [Test regex-divide ambiguous
syntax](#15861 (comment)).
- [x] Test for conformance directly against `eslint` tests.
- [ ] [Parse as JSX only if source text is
JSX](#15861 (comment)).
Could be deferred.
- [ ] Lazy load the parser on demand. Could be deferred.

### Future work
- [ ] `getFirstToken`
- [ ] `getFirstTokens`
- [ ] `getLastToken`
- [ ] `getLastTokens`
- [ ] `getTokenBefore`
- [ ] `getTokenOrCommentBefore`
- [ ] `getTokensBefore`
- [ ] `getTokenAfter`
- [ ] `getTokenOrCommentAfter`
- [ ] `getTokensAfter`
- [ ] `getTokensBetween`
- [ ] `getFirstTokenBetween`
- [ ] `getFirstTokensBetween`
- [ ] `getLastTokenBetween`
- [ ] `getLastTokensBetween`
- [ ] `getTokenByRangeStart`
- [ ] `isSpaceBetween`
- [ ] `isSpaceBetweenTokens`

### Decisions
- [x] `@typescript-eslint/typescript-estree` peer-depends on
`typescript`. How should we package it? Currently, `typescript` is being
made an optional dependency.
- **overlookmotel (on discord): ideally bundled, direct runtime
dependency otherwise.**
- [x] Deprecated methods are being removed altogether in ESLint 10:
`getTokenOrCommentBefore`, `getTokenOrCommentAfter`, and
`isSpaceBetweenTokens`. These are surface level deprecations: the
functionality was merged with other methods (the `includeComments: true`
option) and plugins can migrate with a one line change. I'm guessing we
are targeting fairly modern, actively developed projects. Should we
expose them?
- **[overlookmotel and
camc314](#15861 (comment)):
yes.**
- [x] `Program` range is different between ESLint and TS-ESLint. Which
one should we follow?
-
**[overlookmotel](#15861 (comment)):
they are going to both change and align soon, we should update our range
calculation to match when they do.**

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
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.

3 participants