Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a28c8f

Browse files
Preview/Oxlint
1 parentef04b8d commit6a28c8f

File tree

5 files changed

+271
-0
lines changed

5 files changed

+271
-0
lines changed

‎.oxlintrc.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"all":"error"
4+
}
5+
}

‎oxc1.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Redeclared variable (error)
2+
letvalue=1;
3+
letvalue=2;
4+
5+
// Duplicate function parameters (error)
6+
functionduplicateParams(a,a){
7+
console.log(a);
8+
}
9+
10+
// Constant reassignment (error)
11+
constconstVar=123;
12+
constVar=456;
13+
14+
// Invalid left-hand assignment (error)
15+
functioninvalidAssignment(){
16+
42=x;
17+
}
18+
19+
// Reserved keyword as identifier (error)
20+
letfor='reserved keyword';
21+
22+
// Using 'await' outside async function (error)
23+
awaitfetch('https://example.com');
24+
25+
// Duplicate key in object literal (error)
26+
constobj={
27+
key:1,
28+
key:2
29+
};
30+
31+
// Illegal break statement (error)
32+
break;
33+
34+
// Illegal return statement outside function (error)
35+
return42;

‎oxc1.test‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Unused variable
2+
function unusedVariableDemo() {
3+
let unusedVar = 'this is never used';
4+
}
5+
6+
// Unreachable code after return
7+
function unreachableCode() {
8+
return true;
9+
console.log('This is unreachable');
10+
}
11+
12+
// Missing semicolon
13+
function missingSemicolon() {
14+
console.log('Missing semicolon here')
15+
}
16+
17+
// Redeclared variable
18+
function redeclareVariable() {
19+
let value = 1;
20+
let value = 2; // Redeclaration error
21+
}
22+
23+
// Incorrect equality comparison (use strict equality)
24+
function incorrectEquality(a) {
25+
if (a == null) {
26+
console.log('Use strict equality instead.');
27+
}
28+
}
29+
30+
// Empty block
31+
if (true) {}
32+
33+
// Console statement (assuming no-console rule active)
34+
console.log('Console logging should be flagged.');
35+
36+
// Shadowed variable names
37+
let shadowVar = 'outer';
38+
function shadowVariable() {
39+
let shadowVar = 'inner'; // shadows outer variable
40+
console.log(shadowVar);
41+
}
42+
43+
// Use of var instead of let/const
44+
function varUsage() {
45+
var legacyVar = 123;
46+
return legacyVar;
47+
}
48+
49+
// Improper indentation
50+
function indentation() {
51+
console.log('Improper indentation');
52+
}
53+
54+
// Trailing spaces
55+
function trailingSpace() {
56+
return 42;
57+
}
58+
59+
// Mixed spaces and tabs
60+
function mixedSpacesTabs() {
61+
console.log('Mixed indentation with tabs and spaces');
62+
}
63+
64+
// Undefined variable
65+
function undefinedVariable() {
66+
console.log(nonExistentVar);
67+
}
68+
69+
// unused variable
70+
function unusedVarExample() {
71+
const unusedVariable = "unused";
72+
}
73+
74+
// unreachable code
75+
function unreachableExample() {
76+
return;
77+
console.log("unreachable");
78+
}
79+
80+
// missing semicolon
81+
console.log("semicolon missing")
82+
83+
// redeclared variable
84+
let duplicateVar

‎oxc3.test‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Explicit any type
2+
function explicitAny(a: any): any {
3+
return a;
4+
}
5+
6+
// Redeclared variable
7+
let foo = 123;
8+
let foo = 456;
9+
10+
// Duplicate parameters
11+
function duplicateParams(a: number, a: number) {
12+
return a;
13+
}
14+
15+
// Constant reassignment
16+
const MY_CONST = 'value';
17+
MY_CONST = 'newValue';
18+
19+
// Invalid assignment
20+
function invalidAssignment() {
21+
true = false;
22+
}
23+
24+
// Reserved keywords as identifiers
25+
const class = 'illegal';
26+
27+
// Unreachable code
28+
function unreachable(): number {
29+
return 1;
30+
console.log("never reached");
31+
}
32+
33+
// Misuse of async/await
34+
await Promise.resolve();
35+
36+
// Invalid usage of enum
37+
enum Colors {
38+
Red,
39+
Green,
40+
Red
41+
}
42+
43+
// Empty interface
44+
interface EmptyInterface {}
45+
46+
// Empty function body
47+
function emptyFunction() {}
48+
49+
// Illegal use of break
50+
break;
51+
52+
// Illegal use of continue
53+
continue;
54+
55+
// Illegal return outside function
56+
return 123;
57+
58+
// Unused variable
59+
let unusedVar: number = 5;
60+
61+
// Use before definition
62+
console.log(undeclaredVar);
63+
64+
// Duplicate object literal keys
65+
const myObject = {
66+
name: 'John',
67+
name: 'Doe'
68+
};
69+
70+
// Function overload conflict
71+
function overloadConflict(a: string): void;
72+
function overloadConflict(a: number): number;
73+
function overloadConflict(a: string | number) {
74+
return a;
75+
}
76+
function overloadConflict(a: boolean) {
77+
return a;
78+
}
79+
80+
// Type assertion with no effect
81+
let someNum = 123 as number;
82+
83+
// Useless cast
84+
let uselessCast = "hello" as any as string;
85+
86+
// Shadowed variable
87+
let shadow = 1;
88+
function shadowVar() {
89+
let shadow = 2;
90+
return shadow;
91+
}
92+
93+
// Illegal trailing commas
94+
const illegalTrailingComma = {
95+
foo: "bar",
96+
};
97+
98+
// Promise without await or catch
99+
async function promiseIssue() {
100+
Promise.resolve();
101+
}
102+
103+
// Misuse of generics
104+
function genericMisuse<T>(x: T) {
105+
return x.invalidProperty;
106+
}

‎oxc5.js‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// unused variable
2+
constunusedVar=42
3+
4+
// equality without type checking
5+
if(unusedVar=="42"){
6+
console.log("Bad equality!")
7+
}
8+
9+
// explicit any usage (TypeScript)
10+
functiondoSomethingBad(param){
11+
console.log(param)
12+
}
13+
14+
// using debugger statement
15+
debugger;
16+
17+
// deeply nested and complex function
18+
functioncomplexFunction(a,b,c,d,e){
19+
if(a){
20+
if(b){
21+
if(c){
22+
if(d){
23+
if(e){
24+
console.log("Nested madness!");
25+
}
26+
}
27+
}
28+
}
29+
}
30+
}
31+
32+
// console logging directly (not allowed)
33+
console.log("Direct logging")
34+
35+
// function declared but never used
36+
functionunusedFunction(){
37+
return"Never called!"
38+
}
39+
40+
// badly named variables
41+
letX="badly named"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp