- Notifications
You must be signed in to change notification settings - Fork6
Preview/Oxlint#84
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
alexcoderabbitai wants to merge2 commits intomainChoose a base branch frompreview/oxlint
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.
+278 −0
Open
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions.coderabbit.yaml
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,7 @@ | ||
| reviews: | ||
| path_filters: ["**/*","*.*"] | ||
| tools: | ||
| biome: | ||
| enabled: false | ||
| oxc: | ||
| enabled: true |
5 changes: 5 additions & 0 deletions.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,5 @@ | ||
| { | ||
| "rules": { | ||
| "all": "error" | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletionsoxc1.js
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,35 @@ | ||
| // Redeclared variable (error) | ||
| let value = 1; | ||
| let value = 2; | ||
| // Duplicate function parameters (error) | ||
| function duplicateParams(a, a) { | ||
| console.log(a); | ||
| } | ||
| // Constant reassignment (error) | ||
| const constVar = 123; | ||
| constVar = 456; | ||
| // Invalid left-hand assignment (error) | ||
| function invalidAssignment() { | ||
| 42 = x; | ||
| } | ||
| // Reserved keyword as identifier (error) | ||
| let for = 'reserved keyword'; | ||
| // Using 'await' outside async function (error) | ||
| await fetch('https://example.com'); | ||
| // Duplicate key in object literal (error) | ||
| const obj = { | ||
| key: 1, | ||
| key: 2 | ||
| }; | ||
| // Illegal break statement (error) | ||
| break; | ||
| // Illegal return statement outside function (error) | ||
| return 42; |
84 changes: 84 additions & 0 deletionsoxc1.test
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,84 @@ | ||
| // Unused variable | ||
| function unusedVariableDemo() { | ||
| let unusedVar = 'this is never used'; | ||
| } | ||
| // Unreachable code after return | ||
| function unreachableCode() { | ||
| return true; | ||
| console.log('This is unreachable'); | ||
| } | ||
| // Missing semicolon | ||
| function missingSemicolon() { | ||
| console.log('Missing semicolon here') | ||
| } | ||
| // Redeclared variable | ||
| function redeclareVariable() { | ||
| let value = 1; | ||
| let value = 2; // Redeclaration error | ||
| } | ||
| // Incorrect equality comparison (use strict equality) | ||
| function incorrectEquality(a) { | ||
| if (a == null) { | ||
| console.log('Use strict equality instead.'); | ||
| } | ||
| } | ||
| // Empty block | ||
| if (true) {} | ||
| // Console statement (assuming no-console rule active) | ||
| console.log('Console logging should be flagged.'); | ||
| // Shadowed variable names | ||
| let shadowVar = 'outer'; | ||
| function shadowVariable() { | ||
| let shadowVar = 'inner'; // shadows outer variable | ||
| console.log(shadowVar); | ||
| } | ||
| // Use of var instead of let/const | ||
| function varUsage() { | ||
| var legacyVar = 123; | ||
| return legacyVar; | ||
| } | ||
| // Improper indentation | ||
| function indentation() { | ||
| console.log('Improper indentation'); | ||
| } | ||
| // Trailing spaces | ||
| function trailingSpace() { | ||
| return 42; | ||
| } | ||
| // Mixed spaces and tabs | ||
| function mixedSpacesTabs() { | ||
| console.log('Mixed indentation with tabs and spaces'); | ||
| } | ||
| // Undefined variable | ||
| function undefinedVariable() { | ||
| console.log(nonExistentVar); | ||
| } | ||
| // unused variable | ||
| function unusedVarExample() { | ||
| const unusedVariable = "unused"; | ||
| } | ||
| // unreachable code | ||
| function unreachableExample() { | ||
| return; | ||
| console.log("unreachable"); | ||
| } | ||
| // missing semicolon | ||
| console.log("semicolon missing") | ||
| // redeclared variable | ||
| let duplicateVar |
106 changes: 106 additions & 0 deletionsoxc3.test
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,106 @@ | ||
| // Explicit any type | ||
| function explicitAny(a: any): any { | ||
| return a; | ||
| } | ||
| // Redeclared variable | ||
| let foo = 123; | ||
| let foo = 456; | ||
| // Duplicate parameters | ||
| function duplicateParams(a: number, a: number) { | ||
| return a; | ||
| } | ||
| // Constant reassignment | ||
| const MY_CONST = 'value'; | ||
| MY_CONST = 'newValue'; | ||
| // Invalid assignment | ||
| function invalidAssignment() { | ||
| true = false; | ||
| } | ||
| // Reserved keywords as identifiers | ||
| const class = 'illegal'; | ||
| // Unreachable code | ||
| function unreachable(): number { | ||
| return 1; | ||
| console.log("never reached"); | ||
| } | ||
| // Misuse of async/await | ||
| await Promise.resolve(); | ||
| // Invalid usage of enum | ||
| enum Colors { | ||
| Red, | ||
| Green, | ||
| Red | ||
| } | ||
| // Empty interface | ||
| interface EmptyInterface {} | ||
| // Empty function body | ||
| function emptyFunction() {} | ||
| // Illegal use of break | ||
| break; | ||
| // Illegal use of continue | ||
| continue; | ||
| // Illegal return outside function | ||
| return 123; | ||
| // Unused variable | ||
| let unusedVar: number = 5; | ||
| // Use before definition | ||
| console.log(undeclaredVar); | ||
| // Duplicate object literal keys | ||
| const myObject = { | ||
| name: 'John', | ||
| name: 'Doe' | ||
| }; | ||
| // Function overload conflict | ||
| function overloadConflict(a: string): void; | ||
| function overloadConflict(a: number): number; | ||
| function overloadConflict(a: string | number) { | ||
| return a; | ||
| } | ||
| function overloadConflict(a: boolean) { | ||
| return a; | ||
| } | ||
| // Type assertion with no effect | ||
| let someNum = 123 as number; | ||
| // Useless cast | ||
| let uselessCast = "hello" as any as string; | ||
| // Shadowed variable | ||
| let shadow = 1; | ||
| function shadowVar() { | ||
| let shadow = 2; | ||
| return shadow; | ||
| } | ||
| // Illegal trailing commas | ||
| const illegalTrailingComma = { | ||
| foo: "bar", | ||
| }; | ||
| // Promise without await or catch | ||
| async function promiseIssue() { | ||
| Promise.resolve(); | ||
| } | ||
| // Misuse of generics | ||
| function genericMisuse<T>(x: T) { | ||
| return x.invalidProperty; | ||
| } |
41 changes: 41 additions & 0 deletionsoxc5.js
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,41 @@ | ||
| // unused variable | ||
| const unusedVar = 42 | ||
| // equality without type checking | ||
| if (unusedVar == "42") { | ||
| console.log("Bad equality!") | ||
| } | ||
| // explicit any usage (TypeScript) | ||
| function doSomethingBad(param) { | ||
| console.log(param) | ||
| } | ||
| // using debugger statement | ||
| debugger; | ||
| // deeply nested and complex function | ||
| function complexFunction(a, b, c, d, e) { | ||
| if (a) { | ||
| if (b) { | ||
| if (c) { | ||
| if (d) { | ||
| if (e) { | ||
| console.log("Nested madness!"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| // console logging directly (not allowed) | ||
| console.log("Direct logging") | ||
| // function declared but never used | ||
| function unusedFunction() { | ||
| return "Never called!" | ||
| } | ||
| // badly named variables | ||
| let X = "badly named" |
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.