forked from antfu/eslint-config
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e8b6c9
commit 7343205
Showing
32 changed files
with
3,208 additions
and
2,085 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
20 |
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
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 |
---|---|---|
@@ -1 +1,31 @@ | ||
// unchanged | ||
import type { Person } from './typescript'; | ||
|
||
export function Component1({ children }: { children: React.ReactNode }) { | ||
return <div>{children}</div>; | ||
} | ||
|
||
export function jsx2({ name, age }: Person) { | ||
const props = { a: name, b: age }; | ||
return ( | ||
<a aria-label="bar" title={`foo`}> | ||
<div | ||
{...props} | ||
className="2" | ||
> | ||
Inline Text | ||
</div> | ||
<Component1> | ||
Block Text | ||
</Component1> | ||
<div> | ||
Mixed | ||
<div>Foo</div> | ||
Text | ||
<b> Bar</b> | ||
</div> | ||
<p> | ||
foo<i>bar</i><b>baz</b> | ||
</p> | ||
</a> | ||
); | ||
} |
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,84 @@ | ||
// unchanged | ||
// Define a TypeScript interface | ||
export interface Person { | ||
name: string; | ||
age: number; | ||
} | ||
|
||
// Create an array of objects with the defined interface | ||
const people: Person[] = [ | ||
{ name: 'Alice', age: 30 }, | ||
{ name: 'Bob', age: 25 }, | ||
{ name: 'Charlie', age: 35 }, | ||
]; | ||
|
||
// eslint-disable-next-line no-console | ||
const log = console.log; | ||
|
||
// Use a for...of loop to iterate over the array | ||
for (const person of people) { | ||
log(`Hello, my name is ${person.name} and I am ${person.age} years old.`); | ||
} | ||
|
||
// Define a generic function | ||
function identity< T >(arg: T): T { | ||
return arg; | ||
} | ||
|
||
// Use the generic function with type inference | ||
const result = identity( | ||
'TypeScript is awesome', | ||
); | ||
log(result); | ||
|
||
// Use optional properties in an interface | ||
interface Car { | ||
make: string; | ||
model?: string; | ||
} | ||
|
||
// Create objects using the interface | ||
const car1: Car = { make: 'Toyota' }; | ||
const car2: Car = { | ||
make: 'Ford', | ||
model: 'Focus', | ||
}; | ||
|
||
// Use union types | ||
type Fruit = 'apple' | 'banana' | 'orange'; | ||
const favoriteFruit: Fruit = 'apple'; | ||
|
||
// Use a type assertion to tell TypeScript about the type | ||
const inputValue: any = '42'; | ||
const numericValue = inputValue as number; | ||
|
||
// Define a class with access modifiers | ||
class Animal { | ||
private name: string; | ||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
protected makeSound(sound: string) { | ||
log(`${this.name} says ${sound}`); | ||
} | ||
} | ||
|
||
// Extend a class | ||
class Dog extends Animal { | ||
constructor(private alias: string) { | ||
super(alias); | ||
} | ||
|
||
bark() { | ||
this.makeSound('Woof!'); | ||
} | ||
} | ||
|
||
const dog = new Dog('Buddy'); | ||
dog.bark(); | ||
|
||
function fn(): string { | ||
return `hello${1}`; | ||
} | ||
|
||
log(car1, car2, favoriteFruit, numericValue, fn()); |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.