-
-
Notifications
You must be signed in to change notification settings - Fork 841
feat(linter): support disable directives for type aware rules #14052
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
c/09-23-feat_linter_support_disable_directives_for_type_aware_rules
Oct 6, 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
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 | ||
|
|
||
| // Test oxlint-disable/enable block | ||
| /* oxlint-disable typescript/no-floating-promises */ | ||
| myPromise | ||
| myPromise | ||
| /* oxlint-enable typescript/no-floating-promises */ | ||
|
|
||
| // This should still report an error (no disable directive) | ||
| myPromise | ||
|
|
||
| // Test with different rule name formats | ||
| // oxlint-disable-next-line no-floating-promises | ||
| myPromise | ||
|
|
||
| // eslint-disable-next-line typescript-eslint/no-floating-promises | ||
| myPromise | ||
|
|
||
| // Test disable-line variant | ||
| myPromise // oxlint-disable-line typescript/no-floating-promises | ||
|
|
||
| // 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) |
10 changes: 10 additions & 0 deletions
10
apps/oxlint/fixtures/tsgolint_disable_directives/tsconfig.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,10 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "es2020", | ||
| "module": "esnext", | ||
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "skipLibCheck": true, | ||
| "forceConsistentCasingInFileNames": true | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
apps/oxlint/fixtures/tsgolint_disable_directives/unused.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,24 @@ | ||
| // Test unused disable directives with type-aware rules | ||
| const myPromise = new Promise(() => {}) | ||
|
|
||
| // This disable directive is USED (suppresses the error below) | ||
| // oxlint-disable-next-line typescript/no-floating-promises | ||
| myPromise | ||
|
|
||
| // This disable directive is UNUSED (no error to suppress) | ||
| // oxlint-disable-next-line typescript/no-floating-promises | ||
| console.log("hello") | ||
|
|
||
| // This disable directive is UNUSED (wrong rule name) | ||
| // oxlint-disable-next-line typescript/no-unsafe-assignment | ||
| myPromise | ||
|
|
||
| // This disable directive is USED | ||
| /* eslint-disable @typescript-eslint/no-floating-promises */ | ||
| myPromise | ||
| /* eslint-enable @typescript-eslint/no-floating-promises */ | ||
|
|
||
| // This disable directive is UNUSED (no floating promise here) | ||
| /* eslint-disable @typescript-eslint/no-floating-promises */ | ||
| const x = 1 + 2 | ||
| /* eslint-enable @typescript-eslint/no-floating-promises */ |
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
82 changes: 82 additions & 0 deletions
82
..._disable_directives_--type-aware --report-unused-disable-directives unused.ts@oxlint.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,82 @@ | ||
| --- | ||
| source: apps/oxlint/src/tester.rs | ||
| --- | ||
| ########## | ||
| arguments: --type-aware --report-unused-disable-directives unused.ts | ||
| working directory: fixtures/tsgolint_disable_directives | ||
| ---------- | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[unused.ts:6:1] | ||
| 5 | // oxlint-disable-next-line typescript/no-floating-promises | ||
| 6 | myPromise | ||
| : ^^^^^^^^^ | ||
| 7 | | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! Unused eslint-disable directive (no problems were reported). | ||
| ,-[unused.ts:9:3] | ||
| 8 | // This disable directive is UNUSED (no error to suppress) | ||
| 9 | // oxlint-disable-next-line typescript/no-floating-promises | ||
| : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| 10 | console.log("hello") | ||
| `---- | ||
|
|
||
| ! Unused eslint-disable directive (no problems were reported). | ||
| ,-[unused.ts:13:3] | ||
| 12 | // This disable directive is UNUSED (wrong rule name) | ||
| 13 | // oxlint-disable-next-line typescript/no-unsafe-assignment | ||
| : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| 14 | myPromise | ||
| `---- | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[unused.ts:14:1] | ||
| 13 | // oxlint-disable-next-line typescript/no-unsafe-assignment | ||
| 14 | myPromise | ||
| : ^^^^^^^^^ | ||
| 15 | | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! typescript-eslint(no-floating-promises): Promises must be awaited. | ||
| ,-[unused.ts:14:1] | ||
| 13 | // oxlint-disable-next-line typescript/no-unsafe-assignment | ||
| 14 | myPromise | ||
| : ^^^^^^^^^ | ||
| 15 | | ||
| `---- | ||
| help: 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. | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[unused.ts:18:1] | ||
| 17 | /* eslint-disable @typescript-eslint/no-floating-promises */ | ||
| 18 | myPromise | ||
| : ^^^^^^^^^ | ||
| 19 | /* eslint-enable @typescript-eslint/no-floating-promises */ | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-vars.html\eslint(no-unused-vars)]8;;\: Variable 'x' is declared but never used. Unused variables should start with a '_'. | ||
| ,-[unused.ts:23:7] | ||
| 22 | /* eslint-disable @typescript-eslint/no-floating-promises */ | ||
| 23 | const x = 1 + 2 | ||
| : | | ||
| : `-- 'x' is declared here | ||
| 24 | /* eslint-enable @typescript-eslint/no-floating-promises */ | ||
| `---- | ||
| help: Consider removing this declaration. | ||
|
|
||
| ! Unused eslint-disable directive (no problems were reported). | ||
| ,-[unused.ts:24:3] | ||
| 23 | const x = 1 + 2 | ||
| 24 | /* eslint-enable @typescript-eslint/no-floating-promises */ | ||
| : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| `---- | ||
|
|
||
| Found 8 warnings and 0 errors. | ||
| Finished in <variable>ms on 1 file with 103 rules using 1 threads. | ||
| ---------- | ||
| CLI result: LintSucceeded | ||
| ---------- |
102 changes: 102 additions & 0 deletions
102
...lint/src/snapshots/fixtures__tsgolint_disable_directives_--type-aware test.ts@oxlint.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,102 @@ | ||
| --- | ||
| source: apps/oxlint/src/tester.rs | ||
| --- | ||
| ########## | ||
| arguments: --type-aware test.ts | ||
| working directory: fixtures/tsgolint_disable_directives | ||
| ---------- | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[test.ts:6:1] | ||
| 5 | // oxlint-disable-next-line typescript/no-floating-promises | ||
| 6 | myPromise | ||
| : ^^^^^^^^^ | ||
| 7 | | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[test.ts:10:1] | ||
| 9 | // eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
| 10 | myPromise | ||
| : ^^^^^^^^^ | ||
| 11 | | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[test.ts:14:1] | ||
| 13 | /* oxlint-disable typescript/no-floating-promises */ | ||
| 14 | myPromise | ||
| : ^^^^^^^^^ | ||
| 15 | myPromise | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[test.ts:15:1] | ||
| 14 | myPromise | ||
| 15 | myPromise | ||
| : ^^^^^^^^^ | ||
| 16 | /* oxlint-enable typescript/no-floating-promises */ | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[test.ts:19:1] | ||
| 18 | // This should still report an error (no disable directive) | ||
| 19 | myPromise | ||
| : ^^^^^^^^^ | ||
| 20 | | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! typescript-eslint(no-floating-promises): Promises must be awaited. | ||
| ,-[test.ts:19:1] | ||
| 18 | // This should still report an error (no disable directive) | ||
| 19 | myPromise | ||
| : ^^^^^^^^^ | ||
| 20 | | ||
| `---- | ||
| help: 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. | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[test.ts:23:1] | ||
| 22 | // oxlint-disable-next-line no-floating-promises | ||
| 23 | myPromise | ||
| : ^^^^^^^^^ | ||
| 24 | | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[test.ts:26:1] | ||
| 25 | // eslint-disable-next-line typescript-eslint/no-floating-promises | ||
| 26 | myPromise | ||
| : ^^^^^^^^^ | ||
| 27 | | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html\eslint(no-unused-expressions)]8;;\: Expected expression to be used | ||
| ,-[test.ts:29:1] | ||
| 28 | // Test disable-line variant | ||
| 29 | myPromise // oxlint-disable-line typescript/no-floating-promises | ||
| : ^^^^^^^^^ | ||
| 30 | | ||
| `---- | ||
| help: Consider using this expression or removing it | ||
|
|
||
| ! typescript-eslint(no-floating-promises): Promises must be awaited. | ||
| ,-[test.ts:39:1] | ||
| 38 | // Should report error | ||
| 39 | Promise.resolve(4) | ||
| : ^^^^^^^^^^^^^^^^^^ | ||
| `---- | ||
| help: 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. | ||
|
|
||
| Found 10 warnings and 0 errors. | ||
| Finished in <variable>ms on 1 file with 103 rules using 1 threads. | ||
| ---------- | ||
| CLI result: LintSucceeded | ||
| ---------- |
Oops, something went wrong.
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.