-
-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linter): support
env
and globals
in overrides
configuration (
#8915) This PR supports `env` and `globals` keys in `overrides[x]`. I added tests where I could. Snapshot CLI tests are working 🥳
- Loading branch information
Showing
14 changed files
with
413 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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 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 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,32 @@ | ||
{ | ||
"env": { | ||
"jquery": true | ||
}, | ||
"globals": { | ||
"Foo": "readonly" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"*.ts" | ||
], | ||
"env": { | ||
"jquery": false | ||
}, | ||
"globals": { | ||
"Foo": "writeable" | ||
} | ||
}, | ||
{ | ||
"files": [ | ||
"src/*" | ||
], | ||
"env": { | ||
"jquery": false | ||
}, | ||
"globals": { | ||
"Foo": "writeable" | ||
} | ||
} | ||
] | ||
} |
This file contains 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 @@ | ||
// for env detection | ||
globalThis = 'abc'; | ||
$ = 'abc'; | ||
|
||
// for globals detection | ||
Foo = 'readable'; |
This file contains 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 @@ | ||
// for env detection | ||
globalThis = 'abc'; | ||
$ = 'abc'; | ||
|
||
// for globals detection | ||
Foo = 'readable'; |
This file contains 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 @@ | ||
// for env detection | ||
globalThis = 'abc'; | ||
$ = 'abc'; | ||
|
||
// for globals detection | ||
Foo = 'readable'; |
This file contains 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
57 changes: 57 additions & 0 deletions
57
apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap
This file contains 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,57 @@ | ||
--- | ||
source: apps/oxlint/src/tester.rs | ||
--- | ||
########## | ||
arguments: -c .oxlintrc.json . | ||
working directory: fixtures/overrides_env_globals | ||
---------- | ||
|
||
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-global-assign.html\eslint(no-global-assign)]8;;\: Read-only global 'globalThis' should not be modified. | ||
,-[src/test.js:2:1] | ||
1 | // for env detection | ||
2 | globalThis = 'abc'; | ||
: ^^^^^|^^^^ | ||
: `-- Read-only global 'globalThis' should not be modified. | ||
3 | $ = 'abc'; | ||
`---- | ||
|
||
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-global-assign.html\eslint(no-global-assign)]8;;\: Read-only global 'globalThis' should not be modified. | ||
,-[test.js:2:1] | ||
1 | // for env detection | ||
2 | globalThis = 'abc'; | ||
: ^^^^^|^^^^ | ||
: `-- Read-only global 'globalThis' should not be modified. | ||
3 | $ = 'abc'; | ||
`---- | ||
|
||
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-global-assign.html\eslint(no-global-assign)]8;;\: Read-only global 'globalThis' should not be modified. | ||
,-[test.ts:2:1] | ||
1 | // for env detection | ||
2 | globalThis = 'abc'; | ||
: ^^^^^|^^^^ | ||
: `-- Read-only global 'globalThis' should not be modified. | ||
3 | $ = 'abc'; | ||
`---- | ||
|
||
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-global-assign.html\eslint(no-global-assign)]8;;\: Read-only global '$' should not be modified. | ||
,-[test.js:3:1] | ||
2 | globalThis = 'abc'; | ||
3 | $ = 'abc'; | ||
: | | ||
: `-- Read-only global '$' should not be modified. | ||
4 | | ||
`---- | ||
|
||
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-global-assign.html\eslint(no-global-assign)]8;;\: Read-only global 'Foo' should not be modified. | ||
,-[test.js:6:1] | ||
5 | // for globals detection | ||
6 | Foo = 'readable'; | ||
: ^|^ | ||
: `-- Read-only global 'Foo' should not be modified. | ||
`---- | ||
|
||
Found 5 warnings and 0 errors. | ||
Finished in <variable>ms on 3 files with 97 rules using 1 threads. | ||
---------- | ||
CLI result: LintSucceeded | ||
---------- |
This file contains 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.