-
-
Notifications
You must be signed in to change notification settings - Fork 721
feat(language_server): respect disable directives for type-aware rules #15170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
graphite-app
merged 1 commit into
main
from
10-30-feat_language_server_respect_disable_directives_for_type-aware_rules
Nov 5, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...es/oxc_language_server/fixtures/linter/tsgolint/unused_disabled_directives/.oxlintrc.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "rules": { | ||
| "no-unused-expressions": "off", | ||
| "@typescript-eslint/no-floating-promises": "error" | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
crates/oxc_language_server/fixtures/linter/tsgolint/unused_disabled_directives/test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Test file for disable directives with type-aware rules | ||
| const myPromise = new Promise(() => {}) | ||
|
|
||
| // Test oxlint-disable-next-line | ||
| // oxlint-disable-next-line typescript/no-floating-promises | ||
| myPromise | ||
|
|
||
| // Test eslint-disable-next-line with @typescript-eslint prefix | ||
| // eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
| myPromise | ||
Sysix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Test oxlint-disable/enable block | ||
| /* oxlint-disable typescript/no-floating-promises */ | ||
| myPromise | ||
Sysix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| myPromise | ||
Sysix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /* oxlint-enable typescript/no-floating-promises */ | ||
|
|
||
| // This should still report an error (no disable directive) | ||
| myPromise | ||
Sysix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Test with different rule name formats | ||
| // oxlint-disable-next-line no-floating-promises | ||
| myPromise | ||
Sysix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // eslint-disable-next-line typescript-eslint/no-floating-promises | ||
| myPromise | ||
Sysix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Test disable-line variant | ||
| myPromise // oxlint-disable-line typescript/no-floating-promises | ||
Sysix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Multiple promises in one block | ||
| /* eslint-disable @typescript-eslint/no-floating-promises */ | ||
| Promise.resolve(1) | ||
| Promise.resolve(2) | ||
| Promise.resolve(3) | ||
| /* eslint-enable @typescript-eslint/no-floating-promises */ | ||
|
|
||
| // Should report error | ||
| Promise.resolve(4) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...age_server/src/snapshots/fixtures_linter_tsgolint_unused_disabled_directives@test.ts.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| --- | ||
| source: crates/oxc_language_server/src/tester.rs | ||
| --- | ||
| ########## | ||
| file: fixtures/linter/tsgolint/unused_disabled_directives/test.ts | ||
| ---------- | ||
|
|
||
| code: "typescript-eslint(no-floating-promises)" | ||
| code_description.href: "None" | ||
| message: "Promises must be awaited.\nhelp: The promise must end with a call to .catch, or end with a call to .then with a rejection handler, or be explicitly marked as ignored with the `void` operator." | ||
| range: Range { start: Position { line: 18, character: 0 }, end: Position { line: 18, character: 9 } } | ||
| related_information[0].message: "" | ||
| related_information[0].location.uri: "file://<variable>/fixtures/linter/tsgolint/unused_disabled_directives/test.ts" | ||
| related_information[0].location.range: Range { start: Position { line: 18, character: 0 }, end: Position { line: 18, character: 9 } } | ||
| severity: Some(Error) | ||
| source: Some("oxc") | ||
| tags: None | ||
| fixed: Multiple( | ||
| [ | ||
| FixedContent { | ||
| message: Some( | ||
| "Disable no-floating-promises for this line", | ||
| ), | ||
| code: "// oxlint-disable-next-line no-floating-promises\n", | ||
| range: Range { | ||
| start: Position { | ||
| line: 18, | ||
| character: 0, | ||
| }, | ||
| end: Position { | ||
| line: 18, | ||
| character: 0, | ||
| }, | ||
| }, | ||
| }, | ||
| FixedContent { | ||
| message: Some( | ||
| "Disable no-floating-promises for this file", | ||
| ), | ||
| code: "// oxlint-disable no-floating-promises\n", | ||
| range: Range { | ||
| start: Position { | ||
| line: 0, | ||
| character: 0, | ||
| }, | ||
| end: Position { | ||
| line: 0, | ||
| character: 0, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| code: "typescript-eslint(no-floating-promises)" | ||
| code_description.href: "None" | ||
| message: "Promises must be awaited.\nhelp: The promise must end with a call to .catch, or end with a call to .then with a rejection handler, or be explicitly marked as ignored with the `void` operator." | ||
| range: Range { start: Position { line: 38, character: 0 }, end: Position { line: 38, character: 18 } } | ||
| related_information[0].message: "" | ||
| related_information[0].location.uri: "file://<variable>/fixtures/linter/tsgolint/unused_disabled_directives/test.ts" | ||
| related_information[0].location.range: Range { start: Position { line: 38, character: 0 }, end: Position { line: 38, character: 18 } } | ||
| severity: Some(Error) | ||
| source: Some("oxc") | ||
| tags: None | ||
| fixed: Multiple( | ||
| [ | ||
| FixedContent { | ||
| message: Some( | ||
| "Disable no-floating-promises for this line", | ||
| ), | ||
| code: "// oxlint-disable-next-line no-floating-promises\n", | ||
| range: Range { | ||
| start: Position { | ||
| line: 38, | ||
| character: 0, | ||
| }, | ||
| end: Position { | ||
| line: 38, | ||
| character: 0, | ||
| }, | ||
| }, | ||
| }, | ||
| FixedContent { | ||
| message: Some( | ||
| "Disable no-floating-promises for this file", | ||
| ), | ||
| code: "// oxlint-disable no-floating-promises\n", | ||
| range: Range { | ||
| start: Position { | ||
| line: 0, | ||
| character: 0, | ||
| }, | ||
| end: Position { | ||
| line: 0, | ||
| character: 0, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.