Skip to content

Comments

feat(linter/plugins): implement SourceCode#isSpaceBetween#15498

Merged
graphite-app[bot] merged 1 commit intomainfrom
11-08-feat_linter_plugins_implement_sourcecode_isspacebetween_
Nov 8, 2025
Merged

feat(linter/plugins): implement SourceCode#isSpaceBetween#15498
graphite-app[bot] merged 1 commit intomainfrom
11-08-feat_linter_plugins_implement_sourcecode_isspacebetween_

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Nov 8, 2025

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.

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.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI C-enhancement Category - New feature or request labels Nov 8, 2025
@overlookmotel overlookmotel marked this pull request as ready for review November 8, 2025 17:48
Copilot AI review requested due to automatic review settings November 8, 2025 17:48
@overlookmotel overlookmotel self-assigned this Nov 8, 2025
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Nov 8, 2025
Copy link
Member Author

overlookmotel commented Nov 8, 2025

Merge activity

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 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 isSpaceBetween function in tokens.ts with logic to detect whitespace in the gap between two nodes/tokens
  • Moved the method from a stub implementation in source_code.ts to 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.

@overlookmotel overlookmotel force-pushed the 11-08-feat_linter_plugins_implement_sourcecode_isspacebetween_ branch from de33e30 to c601d79 Compare November 8, 2025 19:08
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.
@graphite-app graphite-app bot force-pushed the 11-08-feat_linter_plugins_implement_sourcecode_isspacebetween_ branch from c601d79 to 222a8f0 Compare November 8, 2025 19:14
@graphite-app graphite-app bot merged commit 222a8f0 into main Nov 8, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 11-08-feat_linter_plugins_implement_sourcecode_isspacebetween_ branch November 8, 2025 19:20
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 8, 2025
overlookmotel added a commit that referenced this pull request Nov 27, 2025
…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>
taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
…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>
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 C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant