feat(linter/plugins): implement SourceCode#isSpaceBetween#15498
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
Merge activity
|
There was a problem hiding this comment.
Pull Request Overview
This PR implements the isSpaceBetween method for context.sourceCode in oxlint's plugin system, which determines if two nodes or tokens have at least one whitespace character between them.
Key Changes:
- Implemented
isSpaceBetweenfunction intokens.tswith logic to detect whitespace in the gap between two nodes/tokens - Moved the method from a stub implementation in
source_code.tsto the actual implementation and added proper delegation - Added comprehensive test fixtures covering various spacing scenarios (no space, single space, multiple spaces, newlines, nested nodes, and adjacent nodes)
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| apps/oxlint/src-js/plugins/tokens.ts | Implements isSpaceBetween function with gap detection logic and whitespace checking |
| apps/oxlint/src-js/plugins/source_code.ts | Removes stub implementation and delegates to tokenMethods.isSpaceBetween; removes unused NodeOrToken import |
| apps/oxlint/test/fixtures/isSpaceBetween/plugin.ts | Test plugin that exercises isSpaceBetween with various node relationships |
| apps/oxlint/test/fixtures/isSpaceBetween/files/index.js | Test input file with different spacing scenarios |
| apps/oxlint/test/fixtures/isSpaceBetween/output.snap.md | Expected output snapshot for test validation |
| apps/oxlint/test/fixtures/isSpaceBetween/.oxlintrc.json | Configuration file enabling the test plugin |
| apps/oxlint/test/e2e.test.ts | Adds e2e test case for isSpaceBetween functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
de33e30 to
c601d79
Compare
Implement `sourceCode.isSpaceBetween`. Implementation is not quite correct, because we don't have tokens yet. But it's better than no implementation at all. We can correct it once we have tokens. The reason it's not correct is explained in comment on `isSpaceBetween` implementation, and the incorrect behavior is demonstrated in the test fixture.
c601d79 to
222a8f0
Compare
…eenTokens()` using tokens (#16055) - Follow up to #15498 and #15861 - Note: JSX special case (as part of the `isSpaceBetweenTokens()` method) is being removed in ESLint v10 (see [eslint/eslint#20137](https://github.com/eslint/eslint/pull/20137/files#diff-e85eaebdcf6af45c06572019cbd900cff91518c789049c3bd0e8724c18645ab0)) ### Tasks: - [x] Token-based reimplementation of `isSpaceBetween()` - [x] Token-based reimplementation of `isSpaceBetweenTokens()` - [x] Pass existing tests from #15498 - [x] New tests for JS syntax - [x] New tests for JSX syntax --------- Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
…eenTokens()` using tokens (oxc-project#16055) - Follow up to oxc-project#15498 and oxc-project#15861 - Note: JSX special case (as part of the `isSpaceBetweenTokens()` method) is being removed in ESLint v10 (see [eslint/eslint#20137](https://github.com/eslint/eslint/pull/20137/files#diff-e85eaebdcf6af45c06572019cbd900cff91518c789049c3bd0e8724c18645ab0)) ### Tasks: - [x] Token-based reimplementation of `isSpaceBetween()` - [x] Token-based reimplementation of `isSpaceBetweenTokens()` - [x] Pass existing tests from oxc-project#15498 - [x] New tests for JS syntax - [x] New tests for JSX syntax --------- Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>

Implement
sourceCode.isSpaceBetween. Implementation is not quite correct, because we don't have tokens yet. But it's better than no implementation at all. We can correct it once we have tokens.The reason it's not correct is explained in comment on
isSpaceBetweenimplementation, and the incorrect behavior is demonstrated in the test fixture.