-
-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linter): allow
env
and globals
in overrides
configuration
- Loading branch information
Showing
18 changed files
with
691 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,50 @@ | ||
{ | ||
"globals": { | ||
"DefaultFoo": "readonly" | ||
}, | ||
"rules": { | ||
"no-var": "error", | ||
"no-console": "error" | ||
"no-console": "error", | ||
"no-global-assign": "error" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.js"], | ||
"files": [ | ||
"*.js" | ||
], | ||
"rules": { | ||
"no-console": "warn" | ||
} | ||
}, | ||
{ | ||
"files": ["*.{js,jsx}"], | ||
"files": [ | ||
"*.{js,jsx}" | ||
], | ||
"env": { | ||
"es2024": true | ||
}, | ||
"globals": { | ||
"ReadFoo": "readonly", | ||
"WriteBar": "writeable", | ||
"NonBaz": "off" | ||
}, | ||
"rules": { | ||
"no-console": "off" | ||
} | ||
}, | ||
{ | ||
"files": ["*.ts"], | ||
"files": [ | ||
"*.ts" | ||
], | ||
"env": { | ||
"es2024": false | ||
}, | ||
"globals": { | ||
"DefaultFoo": "off" | ||
}, | ||
"rules": { | ||
"no-console": "warn" | ||
} | ||
} | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -1,19 +1,42 @@ | ||
{ | ||
"globals": { | ||
"DefaultFoo": "readonly" | ||
}, | ||
"rules": { | ||
"no-debugger": "off" | ||
"no-debugger": "off", | ||
"no-global-assign": "error" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["lib/*.{js,ts}", "src/*"], | ||
"files": [ | ||
"lib/*.{js,ts}", | ||
"src/*" | ||
], | ||
"env": { | ||
"es2024": true | ||
}, | ||
"globals": { | ||
"ReadFoo": "readonly", | ||
"WriteBar": "writeable", | ||
"NonBaz": "off" | ||
}, | ||
"rules": { | ||
"no-debugger": "error" | ||
} | ||
}, | ||
{ | ||
"files": ["**/tests/*"], | ||
"files": [ | ||
"**/tests/*" | ||
], | ||
"env": { | ||
"es2024": false | ||
}, | ||
"globals": { | ||
"DefaultFoo": "off" | ||
}, | ||
"rules": { | ||
"no-debugger": "warn" | ||
} | ||
} | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,12 @@ | ||
var msg = "hello"; | ||
console.log(msg); | ||
|
||
// for env detection | ||
globalThis = 'abc'; | ||
|
||
// for globals detection | ||
DefaultFoo = 'defaultReadable'; | ||
ReadFoo = 'readable'; | ||
console.log(ReadFoo); | ||
WriteBar = 'writeable'; | ||
NonBaz = 'always-off'; |
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 |
---|---|---|
@@ -1 +1,12 @@ | ||
// for rules detection | ||
debugger; | ||
|
||
// for env detection | ||
globalThis = 'abc'; | ||
|
||
// for globals detection | ||
DefaultFoo = 'defaultReadable'; | ||
ReadFoo = 'readable'; | ||
console.log(ReadFoo); | ||
WriteBar = 'writeable'; | ||
NonBaz = 'always-off'; |
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 |
---|---|---|
@@ -1 +1,12 @@ | ||
// for rules detection | ||
debugger; | ||
|
||
// for env detection | ||
globalThis = 'abc'; | ||
|
||
// for globals detection | ||
DefaultFoo = 'defaultReadable'; | ||
ReadFoo = 'readable'; | ||
console.log(ReadFoo); | ||
WriteBar = 'writeable'; | ||
NonBaz = 'always-off'; |
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 |
---|---|---|
@@ -1,2 +1,12 @@ | ||
var msg = "hello"; | ||
console.log(msg); | ||
|
||
// for env detection | ||
globalThis = 'abc'; | ||
|
||
// for globals detection | ||
DefaultFoo = 'defaultReadable'; | ||
ReadFoo = 'readable'; | ||
console.log(ReadFoo); | ||
WriteBar = 'writeable'; | ||
NonBaz = 'always-off'; |
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 |
---|---|---|
@@ -1,2 +1,12 @@ | ||
var msg = "hello"; | ||
console.log(msg); | ||
|
||
// for env detection | ||
globalThis = 'abc'; | ||
|
||
// for globals detection | ||
DefaultFoo = 'defaultReadable'; | ||
ReadFoo = 'readable'; | ||
console.log(ReadFoo); | ||
WriteBar = 'writeable'; | ||
NonBaz = 'always-off'; |
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
105 changes: 105 additions & 0 deletions
105
....ts -c fixtures__overrides__.oxlintrc.json [email protected]
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,105 @@ | ||
--- | ||
source: apps/oxlint/src/tester.rs | ||
assertion_line: 95 | ||
--- | ||
########## | ||
arguments: -c fixtures/overrides/.oxlintrc.json fixtures/overrides/test.js | ||
working directory: | ||
---------- | ||
|
||
x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-var.html\eslint(no-var)]8;;\: Unexpected var, use let or const instead. | ||
,-[fixtures/overrides/test.js:1:1] | ||
1 | var msg = "hello"; | ||
: ^^^ | ||
2 | console.log(msg); | ||
`---- | ||
help: Replace var with let or const | ||
|
||
x ]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. | ||
,-[fixtures/overrides/test.js:5:1] | ||
4 | // for env detection | ||
5 | globalThis = 'abc'; | ||
: ^^^^^|^^^^ | ||
: `-- Read-only global 'globalThis' should not be modified. | ||
6 | | ||
`---- | ||
|
||
Found 0 warnings and 2 errors. | ||
Finished in <variable>ms on 1 file with 99 rules using 1 threads. | ||
---------- | ||
CLI result: LintFoundErrors | ||
---------- | ||
|
||
########## | ||
arguments: -c fixtures/overrides/.oxlintrc.json fixtures/overrides/test.ts | ||
working directory: | ||
---------- | ||
|
||
x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-var.html\eslint(no-var)]8;;\: Unexpected var, use let or const instead. | ||
,-[fixtures/overrides/test.ts:1:1] | ||
1 | var msg = "hello"; | ||
: ^^^ | ||
2 | console.log(msg); | ||
`---- | ||
help: Replace var with let or const | ||
|
||
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-console.html\eslint(no-console)]8;;\: eslint(no-console): Unexpected console statement. | ||
,-[fixtures/overrides/test.ts:2:1] | ||
1 | var msg = "hello"; | ||
2 | console.log(msg); | ||
: ^^^^^^^^^^^ | ||
3 | | ||
`---- | ||
help: Delete this console statement. | ||
|
||
x ]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. | ||
,-[fixtures/overrides/test.ts:5:1] | ||
4 | // for env detection | ||
5 | globalThis = 'abc'; | ||
: ^^^^^|^^^^ | ||
: `-- Read-only global 'globalThis' should not be modified. | ||
6 | | ||
`---- | ||
|
||
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-console.html\eslint(no-console)]8;;\: eslint(no-console): Unexpected console statement. | ||
,-[fixtures/overrides/test.ts:10:1] | ||
9 | ReadFoo = 'readable'; | ||
10 | console.log(ReadFoo); | ||
: ^^^^^^^^^^^ | ||
11 | WriteBar = 'writeable'; | ||
`---- | ||
help: Delete this console statement. | ||
|
||
Found 2 warnings and 2 errors. | ||
Finished in <variable>ms on 1 file with 99 rules using 1 threads. | ||
---------- | ||
CLI result: LintFoundErrors | ||
---------- | ||
|
||
########## | ||
arguments: -c fixtures/overrides/.oxlintrc.json fixtures/overrides/other.jsx | ||
working directory: | ||
---------- | ||
|
||
x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-var.html\eslint(no-var)]8;;\: Unexpected var, use let or const instead. | ||
,-[fixtures/overrides/other.jsx:1:1] | ||
1 | var msg = "hello"; | ||
: ^^^ | ||
2 | console.log(msg); | ||
`---- | ||
help: Replace var with let or const | ||
|
||
x ]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. | ||
,-[fixtures/overrides/other.jsx:5:1] | ||
4 | // for env detection | ||
5 | globalThis = 'abc'; | ||
: ^^^^^|^^^^ | ||
: `-- Read-only global 'globalThis' should not be modified. | ||
6 | | ||
`---- | ||
|
||
Found 0 warnings and 2 errors. | ||
Finished in <variable>ms on 1 file with 99 rules using 1 threads. | ||
---------- | ||
CLI result: LintFoundErrors | ||
---------- |
Oops, something went wrong.