-
-
Notifications
You must be signed in to change notification settings - Fork 739
feat(linter): Add linterOptions.typeAware
#16583
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
Draft
connorshea
wants to merge
13
commits into
main
Choose a base branch
from
type-aware-config-file-opt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
418a7f7
feat(linter): Add typeAware config option to the oxlint config file.
connorshea e2d67d3
Minor improvements.
connorshea e9296ea
Nest typeAware under the linterOptions key.
connorshea 36fb9ef
Iterating further
connorshea 1bf7608
Updating type_aware to be Option<bool> so we can distinguish between …
connorshea 9452129
Rephrase and regenerate snaps.
connorshea ed34a51
Add tests to ensure the typeAware setting works correctly in regards …
connorshea 5b7b1d3
Add more tests for the behavior of the typeAware config option.
connorshea 02ecaf0
Remove outdated todo.
connorshea 8abaa12
Update the option docs for linterOptions/typeAware.
connorshea 337408f
[autofix.ci] apply automated fixes
autofix-ci[bot] 017c3b0
Fix typo.
connorshea 4e365e9
Update snaps.
connorshea 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
19 changes: 19 additions & 0 deletions
19
apps/oxlint/fixtures/tsgolint/config-type-aware-false-with-overrides.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,19 @@ | ||
| { | ||
| "categories": { | ||
| "correctness": "off" | ||
| }, | ||
| "linterOptions": { | ||
| "typeAware": false | ||
| }, | ||
| "rules": { | ||
| "typescript/no-floating-promises": "off" | ||
| }, | ||
| "overrides": [ | ||
| { | ||
| "files": ["**/*.ts"], | ||
| "rules": { | ||
| "typescript/no-floating-promises": "error" | ||
| } | ||
| } | ||
| ] | ||
| } |
11 changes: 11 additions & 0 deletions
11
apps/oxlint/fixtures/tsgolint/config-type-aware-false.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,11 @@ | ||
| { | ||
| "categories": { | ||
| "correctness": "off" | ||
| }, | ||
| "linterOptions": { | ||
| "typeAware": false | ||
| }, | ||
| "rules": { | ||
| "typescript/no-floating-promises": "error" | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
apps/oxlint/fixtures/tsgolint/config-type-aware-with-overrides.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,19 @@ | ||
| { | ||
| "categories": { | ||
| "correctness": "off" | ||
| }, | ||
| "linterOptions": { | ||
| "typeAware": true | ||
| }, | ||
| "rules": { | ||
| "typescript/no-floating-promises": "off" | ||
| }, | ||
| "overrides": [ | ||
| { | ||
| "files": ["**/*.ts"], | ||
| "rules": { | ||
| "typescript/no-floating-promises": "error" | ||
| } | ||
| } | ||
| ] | ||
| } |
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,4 @@ | ||
| { | ||
| "linterOptions": { "typeAware": true }, | ||
| "extends": ["./extended-config.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
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
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
22 changes: 22 additions & 0 deletions
22
...tsgolint_--type-aware -c config-type-aware-false.json [email protected]
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,22 @@ | ||
| --- | ||
| source: apps/oxlint/src/tester.rs | ||
| --- | ||
| ########## | ||
| arguments: --type-aware -c config-type-aware-false.json no-floating-promises.ts | ||
| working directory: fixtures/tsgolint | ||
| ---------- | ||
|
|
||
| x typescript-eslint(no-floating-promises): Promises must be awaited. | ||
| ,-[no-floating-promises.ts:2:1] | ||
| 1 | const promise = new Promise((resolve, _reject) => resolve("value")); | ||
| 2 | promise; | ||
| : ^^^^^^^^ | ||
| 3 | | ||
| `---- | ||
| 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 0 warnings and 1 error. | ||
| Finished in <variable>ms on 1 file with 1 rules using 1 threads. | ||
| ---------- | ||
| CLI result: LintFoundErrors | ||
| ---------- |
12 changes: 12 additions & 0 deletions
12
...golint_-c config-type-aware-false-with-overrides.json [email protected]
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,12 @@ | ||
| --- | ||
| source: apps/oxlint/src/tester.rs | ||
| --- | ||
| ########## | ||
| arguments: -c config-type-aware-false-with-overrides.json no-floating-promises.ts | ||
| working directory: fixtures/tsgolint | ||
| ---------- | ||
| Found 0 warnings and 0 errors. | ||
| Finished in <variable>ms on 1 file with 0 rules using 1 threads. | ||
| ---------- | ||
| CLI result: LintSucceeded | ||
| ---------- |
12 changes: 12 additions & 0 deletions
12
...ts/fixtures__tsgolint_-c config-type-aware-false.json [email protected]
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,12 @@ | ||
| --- | ||
| source: apps/oxlint/src/tester.rs | ||
| --- | ||
| ########## | ||
| arguments: -c config-type-aware-false.json no-floating-promises.ts | ||
| working directory: fixtures/tsgolint | ||
| ---------- | ||
| Found 0 warnings and 0 errors. | ||
| Finished in <variable>ms on 1 file with 0 rules using 1 threads. | ||
| ---------- | ||
| CLI result: LintSucceeded | ||
| ---------- |
22 changes: 22 additions & 0 deletions
22
...es__tsgolint_-c config-type-aware-with-overrides.json [email protected]
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,22 @@ | ||
| --- | ||
| source: apps/oxlint/src/tester.rs | ||
| --- | ||
| ########## | ||
| arguments: -c config-type-aware-with-overrides.json no-floating-promises.ts | ||
| working directory: fixtures/tsgolint | ||
| ---------- | ||
|
|
||
| x typescript-eslint(no-floating-promises): Promises must be awaited. | ||
| ,-[no-floating-promises.ts:2:1] | ||
| 1 | const promise = new Promise((resolve, _reject) => resolve("value")); | ||
| 2 | promise; | ||
| : ^^^^^^^^ | ||
| 3 | | ||
| `---- | ||
| 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 0 warnings and 1 error. | ||
| Finished in <variable>ms on 1 file with 0 rules using 1 threads. | ||
| ---------- | ||
| CLI result: LintFoundErrors | ||
| ---------- |
46 changes: 46 additions & 0 deletions
46
apps/oxlint/src/snapshots/fixtures__tsgolint_-c [email protected]
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,46 @@ | ||
| --- | ||
| source: apps/oxlint/src/tester.rs | ||
| --- | ||
| ########## | ||
| arguments: -c config-type-aware.json | ||
| working directory: fixtures/tsgolint | ||
| ---------- | ||
|
|
||
| ! typescript-eslint(no-floating-promises): Promises must be awaited. | ||
| ,-[no-floating-promises.ts:2:1] | ||
| 1 | const promise = new Promise((resolve, _reject) => resolve("value")); | ||
| 2 | promise; | ||
| : ^^^^^^^^ | ||
| 3 | | ||
| `---- | ||
| 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. | ||
|
|
||
| x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\eslint(no-debugger)]8;;\: `debugger` statement is not allowed | ||
| ,-[non-tsgolint.ts:1:1] | ||
| 1 | debugger; | ||
| : ^^^^^^^^^ | ||
| 2 | | ||
| `---- | ||
| help: Remove the debugger statement | ||
|
|
||
| ! typescript-eslint(no-floating-promises): Promises must be awaited. | ||
| ,-[prefer-promise-reject-errors.ts:1:1] | ||
| 1 | Promise.reject('error'); | ||
| : ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| `---- | ||
| 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. | ||
|
|
||
| x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\eslint(no-debugger)]8;;\: `debugger` statement is not allowed | ||
| ,-[test.svelte:2:2] | ||
| 1 | <script> | ||
| 2 | debugger; | ||
| : ^^^^^^^^^ | ||
| 3 | | ||
| `---- | ||
| help: Remove the debugger statement | ||
|
|
||
| Found 2 warnings and 2 errors. | ||
| Finished in <variable>ms on 44 files with 1 rules using 1 threads. | ||
| ---------- | ||
| CLI result: LintFoundErrors | ||
| ---------- |
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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested Configs are the default. For me, it would be strange to only support it in the root config.
Example: Team X owns
packages/package-Xand they want to test type aware.Team Y does not want type aware.
The
extendsshould cover project wide configurations.The Language server part should be here:
oxc/crates/oxc_language_server/src/linter/server_linter.rs
Line 126 in 913b1b3