A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/antfu/eslint-config/commit/6a72bf5 below:

install plugins globally for easy overrides · antfu/eslint-config@6a72bf5 · GitHub

File tree Expand file treeCollapse file tree 12 files changed

+199

-27

lines changed

Filter options

Expand file treeCollapse file tree 12 files changed

+199

-27

lines changed Original file line number Diff line number Diff line change

@@ -0,0 +1,63 @@

1 +

// This file is generated by ChatGPT

2 + 3 +

// eslint-disable-next-line no-console

4 +

const log = console.log

5 + 6 +

// Define a class using ES6 class syntax

7 +

class Person {

8 +

constructor(name, age) {

9 +

this.name = name

10 +

this.age = age

11 +

}

12 + 13 +

// Define a method within the class

14 +

sayHello() {

15 +

log(`Hello, my name is ${this.name} and I am ${this.age} years old.`)

16 +

}

17 +

}

18 + 19 +

// Create an array of objects

20 +

const people = [

21 +

new Person('Alice', 30),

22 +

new Person('Bob', 25),

23 +

new Person('Charlie', 35),

24 +

]

25 + 26 +

// Use the forEach method to iterate over the array

27 +

people.forEach((person) => {

28 +

person.sayHello()

29 +

})

30 + 31 +

// Use a template literal to create a multiline string

32 +

const multilineString = `

33 +

This is a multiline string

34 +

that spans multiple lines.

35 +

`

36 + 37 +

// Use destructuring assignment to extract values from an object

38 +

const { name, age } = people[0]

39 +

log(`First person in the array is ${name} and they are ${age} years old.`, multilineString)

40 + 41 +

// Use the spread operator to create a new array

42 +

const numbers = [1, 2, 3]

43 +

const newNumbers = [...numbers, 4, 5]

44 +

log(newNumbers)

45 + 46 +

// Use a try-catch block for error handling

47 +

try {

48 +

// Attempt to parse an invalid JSON string

49 +

JSON.parse('invalid JSON')

50 +

}

51 +

catch (error) {

52 +

console.error('Error parsing JSON:', error.message)

53 +

}

54 + 55 +

// Use a ternary conditional operator

56 +

const isEven = num => num % 2 === 0

57 +

const number = 7

58 +

log(`${number} is ${isEven(number) ? 'even' : 'odd'}.`)

59 + 60 +

// Use a callback function with setTimeout for asynchronous code

61 +

setTimeout(() => {

62 +

log('This code runs after a delay of 2 seconds.')

63 +

}, 2000)

Original file line number Diff line number Diff line change

@@ -0,0 +1,83 @@

1 +

// Define a TypeScript interface

2 +

type Person = {

3 +

name: string

4 +

age: number

5 +

}

6 + 7 +

// Create an array of objects with the defined interface

8 +

const people: Person[] = [

9 +

{ name: 'Alice', age: 30 },

10 +

{ name: 'Bob', age: 25 },

11 +

{ name: 'Charlie', age: 35 },

12 +

]

13 + 14 +

// eslint-disable-next-line no-console

15 +

const log = console.log

16 + 17 +

// Use a for...of loop to iterate over the array

18 +

for (const person of people)

19 +

log(`Hello, my name is ${person.name} and I am ${person.age} years old.`)

20 + 21 +

// Define a generic function

22 +

function identity< T >(arg: T): T {

23 +

return arg

24 +

}

25 + 26 +

// Use the generic function with type inference

27 +

const result = identity(

28 +

'TypeScript is awesome',

29 +

)

30 +

log(result)

31 + 32 +

// Use optional properties in an interface

33 +

type Car = {

34 +

make: string

35 +

model?: string

36 +

}

37 + 38 +

// Create objects using the interface

39 +

const car1: Car = { make: 'Toyota' }

40 +

const car2: Car = {

41 +

make: 'Ford',

42 +

model: 'Focus',

43 +

}

44 + 45 +

// Use union types

46 +

type Fruit = 'apple' | 'banana' | 'orange'

47 +

const favoriteFruit: Fruit = 'apple'

48 + 49 +

// Use a type assertion to tell TypeScript about the type

50 +

const inputValue: any = '42'

51 +

const numericValue = inputValue as number

52 + 53 +

// Define a class with access modifiers

54 +

class Animal {

55 +

private name: string

56 +

constructor(name: string) {

57 +

this.name = name

58 +

}

59 + 60 +

protected makeSound(sound: string) {

61 +

log(`${this.name} says ${sound}`)

62 +

}

63 +

}

64 + 65 +

// Extend a class

66 +

class Dog extends Animal {

67 +

constructor(private alias: string) {

68 +

super(alias)

69 +

}

70 + 71 +

bark() {

72 +

this.makeSound('Woof!')

73 +

}

74 +

}

75 + 76 +

const dog = new Dog('Buddy')

77 +

dog.bark()

78 + 79 +

function fn(): string {

80 +

return `hello${1}`

81 +

}

82 + 83 +

log(car1, car2, favoriteFruit, numericValue, fn())

Original file line number Diff line number Diff line change

@@ -0,0 +1 @@

1 +

// unchanged

Original file line number Diff line number Diff line change

@@ -0,0 +1 @@

1 +

// unchanged

Original file line number Diff line number Diff line change

@@ -3,14 +3,16 @@ import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from '../globs'

3 3

import { parserJsonc, pluginJsonc } from '../plugins'

4 4 5 5

export const jsonc: FlatESLintConfigItem[] = [

6 +

{

7 +

plugins: {

8 +

jsonc: pluginJsonc as any,

9 +

},

10 +

},

6 11

{

7 12

files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],

8 13

languageOptions: {

9 14

parser: parserJsonc,

10 15

},

11 -

plugins: {

12 -

jsonc: pluginJsonc as any,

13 -

},

14 16

rules: {

15 17

'jsonc/array-bracket-spacing': ['error', 'never'],

16 18

'jsonc/comma-dangle': ['error', 'never'],

Original file line number Diff line number Diff line change

@@ -1,6 +1,6 @@

1 1

import type { FlatESLintConfigItem } from 'eslint-define-config'

2 2

import { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE } from '../globs'

3 -

import { pluginMarkdown, pluginTs } from '../plugins'

3 +

import { pluginMarkdown } from '../plugins'

4 4

import { OFF } from '../flags'

5 5

import type { OptionsComponentExts } from '../types'

6 6

@@ -11,10 +11,12 @@ export function markdown(options: OptionsComponentExts = {}): FlatESLintConfigIt

11 11 12 12

return [

13 13

{

14 -

files: [GLOB_MARKDOWN],

15 14

plugins: {

16 15

markdown: pluginMarkdown,

17 16

},

17 +

},

18 +

{

19 +

files: [GLOB_MARKDOWN],

18 20

processor: 'markdown/markdown',

19 21

},

20 22

{

@@ -29,9 +31,6 @@ export function markdown(options: OptionsComponentExts = {}): FlatESLintConfigIt

29 31

},

30 32

},

31 33

},

32 -

plugins: {

33 -

ts: pluginTs as any,

34 -

},

35 34

rules: {

36 35

'antfu/no-cjs-exports': OFF,

37 36

'antfu/no-ts-export-equal': OFF,

@@ -56,7 +55,6 @@ export function markdown(options: OptionsComponentExts = {}): FlatESLintConfigIt

56 55

'ts/no-var-requires': OFF,

57 56 58 57

'unicode-bom': 'off',

59 - 60 58

'unused-imports/no-unused-imports': OFF,

61 59

'unused-imports/no-unused-vars': OFF,

62 60

},

Original file line number Diff line number Diff line change

@@ -1,9 +1,10 @@

1 1

import type { FlatESLintConfigItem } from 'eslint-define-config'

2 -

import { pluginStylistic } from '../plugins'

2 +

import { pluginAntfu, pluginStylistic } from '../plugins'

3 3 4 4

export const stylistic: FlatESLintConfigItem[] = [

5 5

{

6 6

plugins: {

7 +

antfu: pluginAntfu,

7 8

style: pluginStylistic,

8 9

},

9 10

rules: {

Original file line number Diff line number Diff line change

@@ -7,10 +7,12 @@ import type { OptionsIsInEditor } from '../types'

7 7

export function test(options: OptionsIsInEditor = {}): FlatESLintConfigItem[] {

8 8

return [

9 9

{

10 -

files: GLOB_TESTS,

11 10

plugins: {

12 11

'no-only-tests': pluginNoOnlyTests,

13 12

},

13 +

},

14 +

{

15 +

files: GLOB_TESTS,

14 16

rules: {

15 17

'no-only-tests/no-only-tests': options.isInEditor ? OFF : 'error',

16 18

},

Original file line number Diff line number Diff line change

@@ -12,6 +12,14 @@ export function typescript(options?: OptionsComponentExts): FlatESLintConfigItem

12 12

} = options ?? {}

13 13 14 14

return [

15 +

{

16 +

// Install the plugins without globs, so they can be configured separately.

17 +

plugins: {

18 +

antfu: pluginAntfu,

19 +

import: pluginImport,

20 +

ts: pluginTs as any,

21 +

},

22 +

},

15 23

{

16 24

files: [

17 25

GLOB_TS,

@@ -24,11 +32,6 @@ export function typescript(options?: OptionsComponentExts): FlatESLintConfigItem

24 32

sourceType: 'module',

25 33

},

26 34

},

27 -

plugins: {

28 -

antfu: pluginAntfu,

29 -

import: pluginImport,

30 -

ts: pluginTs as any,

31 -

},

32 35

rules: {

33 36

...renameRules(

34 37

pluginTs.configs['eslint-recommended'].overrides![0].rules!,

@@ -119,9 +122,6 @@ export function typescriptWithLanguageServer(options: OptionsTypeScriptWithLangu

119 122

tsconfigRootDir,

120 123

},

121 124

},

122 -

plugins: {

123 -

ts: pluginTs as any,

124 -

},

125 125

rules: {

126 126

'dot-notation': OFF,

127 127

'no-implied-eval': OFF,

Original file line number Diff line number Diff line change

@@ -6,6 +6,11 @@ import type { OptionsHasTypeScript } from '../types'

6 6 7 7

export function vue(options: OptionsHasTypeScript = {}): FlatESLintConfigItem[] {

8 8

return [

9 +

{

10 +

plugins: {

11 +

vue: pluginVue,

12 +

},

13 +

},

9 14

{

10 15

files: [GLOB_VUE],

11 16

languageOptions: {

@@ -19,9 +24,6 @@ export function vue(options: OptionsHasTypeScript = {}): FlatESLintConfigItem[]

19 24

sourceType: 'module',

20 25

},

21 26

},

22 -

plugins: {

23 -

vue: pluginVue,

24 -

},

25 27

processor: pluginVue.processors['.vue'],

26 28

rules: {

27 29

...pluginVue.configs.base.rules as any,

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4