Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge upstream #6

Open
wants to merge 100 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
4d3c813
chore: update deps
antfu Aug 15, 2024
9feacfc
chore: release v2.25.2
antfu Aug 15, 2024
e5ca299
fix: `ignoresTypeAware` reslove, fix #578
antfu Aug 16, 2024
12fd868
fix: check packages existence in local scope (#583)
paescuj Aug 16, 2024
700c473
chore: update deps
antfu Aug 16, 2024
172f903
chore: release v2.26.0
antfu Aug 16, 2024
ad4e1d4
chore: upgrade install-pkg (#588)
benmccann Aug 21, 2024
a29427c
chore: update deps
antfu Aug 21, 2024
91c8cd6
chore: use eslint v9.9
antfu Aug 21, 2024
a50f787
chore: release v2.26.1
antfu Aug 21, 2024
c62102b
feat: print hint message when running in editor
antfu Aug 21, 2024
b60bfd3
fix: `isInEditorEnv` should be false when in git hooks, close #589
antfu Aug 21, 2024
e638315
chore: release v2.27.0
antfu Aug 21, 2024
35f6763
fix: override type-aware rules properly (#585)
ryoppippi Aug 22, 2024
bba1172
chore: update deps
antfu Aug 22, 2024
8f08fb5
chore: release v2.27.1
antfu Aug 22, 2024
12718a4
feat: formatters support SVG (#591)
yunsii Aug 24, 2024
78d5234
fix: use fork of `eslint-plugin-import-x`
antfu Aug 26, 2024
ed23ea0
chore: release v2.27.2
antfu Aug 26, 2024
6a22489
fix: upgrade `eslint-plugin-import-x`
antfu Aug 27, 2024
1d62059
chore: release v2.27.3
antfu Aug 27, 2024
6e7cfe9
fix: remove redundant statements from `no-restricted-syntax` (#596)
Dimava Aug 27, 2024
b7c7a01
fix!: make the first `ignores` always global, disallow `files` in the…
antfu Aug 29, 2024
a4625b2
feat: add more unicorn rules, allow to configure using `recommanded` …
antfu Aug 29, 2024
4f733e3
feat: upgrade `eslint-config-flat-gitignore`, close #600
antfu Aug 29, 2024
91cc1bf
chore: update deps
antfu Aug 29, 2024
b2fb1b3
feat!: require ESLint v9.5+
antfu Aug 29, 2024
d2f6c0b
chore: release v3.0.0
antfu Aug 29, 2024
237cb5e
chore: upgrade eslint-plugin-solid (#601)
subframe7536 Sep 1, 2024
d6dfc4e
feat: update deps, enable `antfu/consistent-chaining`
antfu Sep 4, 2024
402435f
chore: release v3.1.0
antfu Sep 4, 2024
c3e2d2a
feat: move disable rules to the end, remove deprecated rules
antfu Sep 4, 2024
23ce79b
chore: release v3.2.0
antfu Sep 4, 2024
46aac08
chore: update deps
antfu Sep 5, 2024
715479d
chore: release v3.2.1
antfu Sep 5, 2024
362ab81
fix: disable `unicorn/consistent-function-scoping` for arrow functions
antfu Sep 5, 2024
2427b1b
chore: release v3.2.2
antfu Sep 5, 2024
a6efa09
feat: enable `perfectionist/sort-imports` et al, close #456
antfu Sep 6, 2024
39a1b66
chore: release v3.3.0
antfu Sep 6, 2024
0969748
fix: do not force newline in `perfectionist/sort-imports`
antfu Sep 6, 2024
4a5855d
chore: release v3.3.1
antfu Sep 6, 2024
298f3aa
fix: add `side-effect` in `perfectionist/sort-imports`
antfu Sep 6, 2024
43e0228
chore: release v3.3.2
antfu Sep 6, 2024
21e9c7b
feat: upgrade eslint, remove `@types/eslint`
antfu Sep 7, 2024
5d4fdf0
chore: release v3.4.0
antfu Sep 7, 2024
3ff43f1
chore: update deps
antfu Sep 7, 2024
c8ac6da
chore: release v3.4.1
antfu Sep 7, 2024
597846c
docs: mention about personal config
antfu Sep 9, 2024
d123165
docs: improve layout
antfu Sep 9, 2024
b9052f8
feat: update @eslint/markdown to v6 (#606)
ocavue Sep 9, 2024
5363d53
fix: disable `unicorn/consistent-function-scoping`
antfu Sep 9, 2024
c27745c
chore: update deps
antfu Sep 9, 2024
b8db928
chore: release v3.5.0
antfu Sep 9, 2024
51385c2
chore: update deps
antfu Sep 10, 2024
574523f
chore: release v3.5.1
antfu Sep 10, 2024
e283983
fix: `perfectionist/sort-imports` sort types always on top
antfu Sep 12, 2024
90fae1d
chore: release v3.6.0
antfu Sep 12, 2024
f025c1e
fix: add Next.js router segment config (#608)
zhangyu1818 Sep 13, 2024
207634c
fix: sync js rule options to ts, close #609 (#610)
lvjiaxuan Sep 15, 2024
3d04429
chore: update deps
antfu Sep 15, 2024
5427307
chore: release v3.6.1
antfu Sep 15, 2024
8ba8e8c
fix: glob for disables
antfu Sep 15, 2024
595600d
chore: release v3.6.2
antfu Sep 15, 2024
60ffdbe
fix: disable `explicit-function-return-type` in markdown code
antfu Sep 15, 2024
1788d23
fix: disable `ts/explicit-function-return-type` in vue files
antfu Sep 16, 2024
a08aa0b
feat: enable `antfu/no-top-level-await`
antfu Sep 20, 2024
fcaf7d8
chore: release v3.7.0
antfu Sep 20, 2024
a434edf
feat: disable rules for config files
antfu Sep 20, 2024
2862e4c
chore: release v3.7.1
antfu Sep 20, 2024
04e576c
feat: merge prettier plugins with options (#614)
suppayami Sep 26, 2024
a984c89
fix: disable `antfu/no-top-level-await` for markdown snippets
antfu Sep 26, 2024
73a8dd0
chore: update deps
antfu Sep 26, 2024
582ade4
chore: release v3.7.2
antfu Sep 26, 2024
e914ae4
fix: properly disable top-level-await rule for tests
antfu Sep 26, 2024
7482694
chore: update deps
antfu Sep 26, 2024
a6646c1
chore: release v3.7.3
antfu Sep 26, 2024
f11ab09
feat: support json5 in vscode (#623)
zzxming Oct 16, 2024
d76facc
chore: update react-hooks to v5 (#624)
w3cj Oct 16, 2024
e5e79c5
feat: update deps
antfu Oct 16, 2024
b06dbdb
chore: release v3.8.0
antfu Oct 16, 2024
e24c24c
fix: seperate the type aware rules for react (#622)
PranavSK Nov 14, 2024
8708d3c
chore(deps): update eslint-plugin-vue version (#629)
ZaneL1u Nov 14, 2024
f7e0f1d
feat: update deps
antfu Nov 14, 2024
23af2a9
chore: release v3.9.0
antfu Nov 14, 2024
31610b2
fix: update quotes config
antfu Nov 14, 2024
4d17bf2
chore: release v3.9.1
antfu Nov 14, 2024
e33dc72
feat: update deps
antfu Nov 19, 2024
b2e6bc2
chore: release v3.9.2
antfu Nov 19, 2024
5d0c2a5
docs: add install command to cli outro (#630)
runyasak Nov 19, 2024
750ea8e
chore: update
antfu Nov 19, 2024
667c448
feat: upgrade `perfectionist` to v4
antfu Nov 26, 2024
be26a54
chore: release v3.10.0
antfu Nov 26, 2024
3f32478
chore(deps): update prettier-plugin-astro version (#637)
tysian Nov 27, 2024
40ee74a
fix: disable `antfu/no-top-level-await` for Astro (#638)
kidonng Nov 27, 2024
acd349e
chore: update deps
antfu Nov 27, 2024
f0eecc5
chore: release v3.11.0
antfu Nov 27, 2024
d9b10e1
fix: recover typegen for builtin rules, close #639
antfu Nov 28, 2024
a02e566
chore: release v3.11.1
antfu Nov 28, 2024
00c4194
fix(perfectionist): revert bahaviour change on import sorting since v…
antfu Nov 28, 2024
20dd434
chore: release v3.11.2
antfu Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"source.organizeImports": "never"
},

"eslint.options": {
"flags": ["unstable_ts_config"]
},

"eslint.runtime": "node",

// Silent the stylistic rules in you IDE, but still auto fix them
Expand All @@ -34,6 +38,7 @@
"html",
"markdown",
"json",
"json5",
"jsonc",
"yaml",
"toml",
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@
- Single quotes, no semi
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
- Respects `.gitignore` by default
- Supports ESLint v9 or v8.50.0+
- Requires ESLint v9.5.0+

> [!IMPORTANT]
> [!NOTE]
> Since v1.0.0, this config is rewritten to the new [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), check the [release note](https://github.com/antfu/eslint-config/releases/tag/v1.0.0) for more details.
>
> Since v3.0.0, ESLint v9.5.0+ is now required.

> [!WARNING]
> I am super appreciated and even a bit flatted that so many of you are fond of using this config. For that, I tried to make it as flexible and customizable as possible to fit more use cases.
>
> However, please keep in mind that this is still **_a personal config_** with a lot opinions. Changes might not always be pleased by everyone and every use cases.
>
> If you are using this config directly, I'd suggest you **review the changes everytime you update**. Or if you want more control over the rules, always feel free to fork it. Thanks!

## Usage

Expand Down
1 change: 1 addition & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-expect-error missing types
import styleMigrate from '@stylistic/eslint-plugin-migrate'

import { antfu } from './src'

export default antfu(
Expand Down
5 changes: 3 additions & 2 deletions fixtures/input/jsx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export function HelloWorld({
return null};

// TODO: Don't use random in render
let num = Math.floor (Math.random() * 1E+7).toString()
.replace(/\.\d+/ig, "")
let num = Math
.floor (Math.random() * 1E+7).toString()
.replace(/\.\d+/ig, "")

return <div className='HelloWorld' title={`You are visitor number ${ num }`} onMouseOver={onMouseOver}>
<strong>{ greeting.slice( 0, 1 ).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>
Expand Down
8 changes: 8 additions & 0 deletions fixtures/input/svg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion fixtures/output/all/jsx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export function HelloWorld({
};

// TODO: Don't use random in render
const num = Math.floor (Math.random() * 1e+7).toString()
const num = Math
.floor (Math.random() * 1e+7)
.toString()
.replace(/\.\d+/g, '')

return (
Expand Down
4 changes: 3 additions & 1 deletion fixtures/output/js/jsx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export function HelloWorld({
};

// TODO: Don't use random in render
const num = Math.floor (Math.random() * 1e+7).toString()
const num = Math
.floor (Math.random() * 1e+7)
.toString()
.replace(/\.\d+/g, '')

return (
Expand Down
5 changes: 3 additions & 2 deletions fixtures/output/no-style/jsx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export function HelloWorld({
return null};

// TODO: Don't use random in render
const num = Math.floor (Math.random() * 1e+7).toString()
.replace(/\.\d+/g, "")
const num = Math
.floor (Math.random() * 1e+7).toString()
.replace(/\.\d+/g, "")

return <div className='HelloWorld' title={`You are visitor number ${ num }`} onMouseOver={onMouseOver}>
<strong>{ greeting.slice( 0, 1 ).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>
Expand Down
4 changes: 3 additions & 1 deletion fixtures/output/tab-double-quotes/jsx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export function HelloWorld({
};

// TODO: Don't use random in render
const num = Math.floor (Math.random() * 1e+7).toString()
const num = Math
.floor (Math.random() * 1e+7)
.toString()
.replace(/\.\d+/g, "")

return (
Expand Down
4 changes: 3 additions & 1 deletion fixtures/output/ts-override/jsx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export function HelloWorld({
};

// TODO: Don't use random in render
const num = Math.floor (Math.random() * 1e+7).toString()
const num = Math
.floor (Math.random() * 1e+7)
.toString()
.replace(/\.\d+/g, '')

return (
Expand Down
73 changes: 73 additions & 0 deletions fixtures/output/ts-strict-with-react/javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// This file is generated by ChatGPT

// eslint-disable-next-line no-console
const log = console.log

// Define a class using ES6 class syntax
class Person {
constructor(name, age) {
this.name = name
this.age = age
}

// Define a method within the class
sayHello() {
log(`Hello, my name is ${this.name} and I am ${this.age} years old.`)
}
}

// Create an array of objects
const people = [
new Person('Alice', 30),
new Person('Bob', 25),
new Person('Charlie', 35),
]

// Use the forEach method to iterate over the array
people.forEach((person) => {
person.sayHello()
})

// Use a template literal to create a multiline string
const multilineString = `
This is a multiline string
that spans multiple lines.
`

// Use destructuring assignment to extract values from an object
const { name, age } = people[0]
log(`First person in the array is ${name} and they are ${age} years old.`, multilineString)

// Use the spread operator to create a new array
const numbers = [1, 2, 3]
const newNumbers = [...numbers, 4, 5]
log(newNumbers)

// Use a try-catch block for error handling
try {
// Attempt to parse an invalid JSON string
JSON.parse('invalid JSON')
}
catch (error) {
console.error('Error parsing JSON:', error.message)
}

// Use a ternary conditional operator
const isEven = num => num % 2 === 0
const number = 7
log(`${number} is ${isEven(number) ? 'even' : 'odd'}.`)

// Use a callback function with setTimeout for asynchronous code
setTimeout(() => {
log('This code runs after a delay of 2 seconds.')
}, 2000)

let a, b, c, d, foo

if (a
|| b
|| c || d
|| (d && b)
) {
foo()
}
29 changes: 29 additions & 0 deletions fixtures/output/ts-strict-with-react/jsx.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export function HelloWorld({
greeting = 'hello',
greeted = '"World"',
silent = false,
onMouseOver,
}) {
if (!greeting) {
return null
};

// TODO: Don't use random in render
const num = Math
.floor (Math.random() * 1e+7)
.toString()
.replace(/\.\d+/g, '')

return (
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>
{greeting.endsWith(',')
? ' '
: <span style={{ color: '\grey' }}>", "</span> }
<em>
{ greeted }
</em>
{ (silent) ? '.' : '!'}
</div>
)
}
34 changes: 34 additions & 0 deletions fixtures/output/ts-strict-with-react/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Header
======

_Look,_ code blocks are formatted *too!*

```js
// This should be handled by ESLint instead of Prettier
function identity(x) {
if (foo) {
console.log('bar')
}
}
```

```css
/* This should be handled by Prettier */
.foo { color:red;}
```

Pilot|Airport|Hours
--|:--:|--:
John Doe|SKG|1338
Jane Roe|JFK|314

- - - - - - - - - - - - - - -

+ List
+ with a [link] (/to/somewhere)
+ and [another one]

[another one]: http://example.com 'Example title'

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur consectetur maximus risus, sed maximus tellus tincidunt et.
23 changes: 23 additions & 0 deletions fixtures/output/ts-strict-with-react/toml.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
comma = [
1,
2,
3,
]

[foo]
b = 1
c = "hello"
a = { answer = 42 }
indent = [
1,
2
]

[a-table]
apple.type = "fruit"
apple.skin = "thin"
apple.color = "red"

orange.type = "fruit"
orange.skin = "thick"
orange.color = "orange"
32 changes: 32 additions & 0 deletions fixtures/output/ts-strict-with-react/tsx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export function Component1() {
return <div />
}

export function jsx2() {
const props = { a: 1, b: 2 }
return (
<a foo="bar" bar="foo">
<div
{...props}
a={1}
b="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>
)
}
Loading