Skip to content

Commit 0646e81

Browse files
committed
feat(mutoe): add mutoe preferred rules
(cherry picked from commit e1785c8) (cherry picked from commit 06b8766)
1 parent 5520117 commit 0646e81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2781
-2682
lines changed

.vscode/settings.json

+17
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,22 @@
4646
"source": "./fixtures/output/**/*.*",
4747
"target": "./fixtures/input/<base>"
4848
}
49+
],
50+
"cSpell.words": [
51+
"antfu",
52+
"astro",
53+
"ependencies",
54+
"esno",
55+
"execa",
56+
"jiti",
57+
"linebreak",
58+
"lockb",
59+
"nonwords",
60+
"picocolors",
61+
"slidev",
62+
"stroustrup",
63+
"typecheck",
64+
"typegen",
65+
"vuejs"
4966
]
5067
}

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,22 @@ Based on the version of @Antfu, the following sections have been modified:
1111

1212
- Update default package name to `defineConfig`
1313
- Supplement more `package.json` properties ordering rules
14-
- (Plan) Reduce the number of default dependencies
15-
- (Plan) Some of my favorite styles
14+
- By default, all recommendation rules from unicorn are enabled
15+
- Grouped `perfectionist/sort-imports` `perfectionist/sort-vue-attributes` rule
16+
- Only allow camelCase in variable names
17+
- JavaScript: allow named function as callback (for error stack trace readability)
18+
- TypeScript: consistent type assertions (use `xxx as T` instead of `<T>xxx`)
19+
- TypeScript: always need to add await before async function call
20+
- Vue: block order change to ['template', 'script', 'style']
21+
- Vue: don't allow attribute more than 3 in one line
22+
- Vue: Allow singleline html element
23+
- JSX: allow multiple element in one line
24+
- YAML: always add space inner brackets (`[]` `{}`)
25+
- Test: ignore some type wares rules for tests
26+
- Test: support optional cypress recommended rules
27+
- Style: turned off [`antfu/if-newline`](https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/if-newline.md), [`antfu/consistent-chaining`](https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/consistent-chaining.md) rules
28+
- Style: set linebreak-style to `unix`
29+
- Style: avoid escape quotes in statement
1630

1731
---
1832

eslint.config.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import styleMigrate from '@stylistic/eslint-plugin-migrate'
2-
31
import { antfu } from '@antfu/eslint-config'
2+
import styleMigrate from '@stylistic/eslint-plugin-migrate'
43

54
export default antfu(
65
{
@@ -13,6 +12,9 @@ export default antfu(
1312
formatters: true,
1413
pnpm: true,
1514
type: 'lib',
15+
rules: {
16+
'pnpm/enforce-catalog': 'off',
17+
},
1618
},
1719
{
1820
ignores: [

fixtures/output/all/javascript.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const people = [
2424
]
2525

2626
// Use the forEach method to iterate over the array
27-
people.forEach((person) => {
27+
for (const person of people) {
2828
person.sayHello()
29-
})
29+
}
3030

3131
// Use a template literal to create a multiline string
3232
const multilineString = `

fixtures/output/all/jsx.jsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ export function HelloWorld({
1010

1111
// TODO: Don't use random in render
1212
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, '')
13+
.floor (Math.random() * 1e+7).toString()
14+
.replaceAll(/\.\d+/g, '')
1615

1716
return (
1817
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>

fixtures/output/all/tsx.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@ export function jsx2() {
1010
{...props}
1111
a={1}
1212
b="2"
13-
>
14-
Inline Text
13+
>Inline Text
1514
</div>
1615
<Component1>
1716
Block Text
1817
</Component1>
1918
<div>
2019
Mixed
2120
<div>Foo</div>
22-
Text
23-
<b> Bar</b>
21+
Text<b> Bar</b>
2422
</div>
2523
<p>
26-
foo
27-
<i>bar</i>
28-
<b>baz</b>
24+
foo<i>bar</i><b>baz</b>
2925
</p>
3026
</a>
3127
)

fixtures/output/all/vue-ts.vue

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<template>
2+
<div>
3+
<h1>{{ greeting }}</h1>
4+
<button @click="incrementCounter">
5+
Click me!
6+
</button>
7+
<p>Counter: {{ counter }}</p>
8+
</div>
9+
</template>
10+
111
<script setup lang="ts">
212
// Define reactive data and props
313
import { ref } from 'vue'
@@ -11,16 +21,6 @@ function incrementCounter() {
1121
}
1222
</script>
1323

14-
<template>
15-
<div>
16-
<h1>{{ greeting }}</h1>
17-
<button @click="incrementCounter">
18-
Click me!
19-
</button>
20-
<p>Counter: {{ counter }}</p>
21-
</div>
22-
</template>
23-
2424
<style>
2525
.a { color: red }
2626
</style>

fixtures/output/all/vue.vue

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<template>
2+
<div>
3+
<h1>
4+
{{ greeting }}
5+
</h1>
6+
<button @click="incrementCounter">Click me!</button>
7+
<p>Counter: {{ counter }}</p>
8+
</div>
9+
</template>
10+
111
<script setup>
212
// Define reactive data and props
313
import { ref } from 'vue'
@@ -13,15 +23,3 @@ function incrementCounter() {
1323
1424
const _zero = doubled.value + counter.value
1525
</script>
16-
17-
<template>
18-
<div>
19-
<h1>
20-
{{ greeting }}
21-
</h1>
22-
<button @click="incrementCounter">
23-
Click me!
24-
</button>
25-
<p>Counter: {{ counter }}</p>
26-
</div>
27-
</template>

fixtures/output/js/javascript.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const people = [
2424
]
2525

2626
// Use the forEach method to iterate over the array
27-
people.forEach((person) => {
27+
for (const person of people) {
2828
person.sayHello()
29-
})
29+
}
3030

3131
// Use a template literal to create a multiline string
3232
const multilineString = `

fixtures/output/js/jsx.jsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ export function HelloWorld({
1010

1111
// TODO: Don't use random in render
1212
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, '')
13+
.floor (Math.random() * 1e+7).toString()
14+
.replaceAll(/\.\d+/g, '')
1615

1716
return (
1817
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>

fixtures/output/js/tsx.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@ export function jsx2() {
1010
{...props}
1111
a={1}
1212
b="2"
13-
>
14-
Inline Text
13+
>Inline Text
1514
</div>
1615
<Component1>
1716
Block Text
1817
</Component1>
1918
<div>
2019
Mixed
2120
<div>Foo</div>
22-
Text
23-
<b> Bar</b>
21+
Text<b> Bar</b>
2422
</div>
2523
<p>
26-
foo
27-
<i>bar</i>
28-
<b>baz</b>
24+
foo<i>bar</i><b>baz</b>
2925
</p>
3026
</a>
3127
)

fixtures/output/no-markdown-with-formatters/javascript.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const people = [
2424
]
2525

2626
// Use the forEach method to iterate over the array
27-
people.forEach((person) => {
27+
for (const person of people) {
2828
person.sayHello()
29-
})
29+
}
3030

3131
// Use a template literal to create a multiline string
3232
const multilineString = `

fixtures/output/no-style/javascript.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const people = [
2424
];
2525

2626
// Use the forEach method to iterate over the array
27-
people.forEach(person => {
27+
for (const person of people) {
2828
person.sayHello();
29-
});
29+
}
3030

3131
// Use a template literal to create a multiline string
3232
const multilineString = `

fixtures/output/no-style/jsx.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function HelloWorld({
77
// TODO: Don't use random in render
88
const num = Math
99
.floor (Math.random() * 1e+7).toString()
10-
.replace(/\.\d+/g, "")
10+
.replaceAll(/\.\d+/g, "")
1111

1212
return <div className='HelloWorld' title={`You are visitor number ${ num }`} onMouseOver={onMouseOver}>
1313
<strong>{ greeting.slice( 0, 1 ).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>

fixtures/output/no-style/vue-ts.vue

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<template>
2+
<div>
3+
<h1>{{ greeting }}</h1>
4+
<button @click="incrementCounter">
5+
Click me!
6+
</button>
7+
<p>Counter: {{ counter }}</p>
8+
</div>
9+
</template>
10+
111
<script setup lang="ts">
212
// Define reactive data and props
313
import { ref } from 'vue';
@@ -11,16 +21,6 @@ const incrementCounter = () => {
1121
};
1222
</script>
1323

14-
<template>
15-
<div>
16-
<h1>{{ greeting }}</h1>
17-
<button @click="incrementCounter">
18-
Click me!
19-
</button>
20-
<p>Counter: {{ counter }}</p>
21-
</div>
22-
</template>
23-
2424
<style>
2525
.a { color: red }
2626
</style>

fixtures/output/no-style/vue.vue

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<template>
2+
<div>
3+
<h1>
4+
{{ greeting }}
5+
</h1>
6+
<button @click="incrementCounter">Click me!</button>
7+
<p>Counter: {{ counter }}</p>
8+
</div>
9+
</template>
10+
111
<script setup>
212
// Define reactive data and props
313
import { ref } from 'vue';
@@ -13,15 +23,3 @@ const incrementCounter = () => {
1323
1424
const _zero = doubled.value + counter.value
1525
</script>
16-
17-
<template>
18-
<div>
19-
<h1>
20-
{{ greeting }}
21-
</h1>
22-
<button @click="incrementCounter">
23-
Click me!
24-
</button>
25-
<p>Counter: {{ counter }}</p>
26-
</div>
27-
</template>

fixtures/output/tab-double-quotes/javascript.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const people = [
2424
]
2525

2626
// Use the forEach method to iterate over the array
27-
people.forEach((person) => {
27+
for (const person of people) {
2828
person.sayHello()
29-
})
29+
}
3030

3131
// Use a template literal to create a multiline string
3232
const multilineString = `

fixtures/output/tab-double-quotes/jsx.jsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export function HelloWorld({
22
greeting = "hello",
3-
greeted = "\"World\"",
3+
greeted = '"World"',
44
silent = false,
55
onMouseOver,
66
}) {
@@ -10,9 +10,8 @@ export function HelloWorld({
1010

1111
// TODO: Don't use random in render
1212
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, "")
13+
.floor (Math.random() * 1e+7).toString()
14+
.replaceAll(/\.\d+/g, "")
1615

1716
return (
1817
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>

fixtures/output/tab-double-quotes/tsx.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@ export function jsx2() {
1010
{...props}
1111
a={1}
1212
b="2"
13-
>
14-
Inline Text
13+
>Inline Text
1514
</div>
1615
<Component1>
1716
Block Text
1817
</Component1>
1918
<div>
2019
Mixed
2120
<div>Foo</div>
22-
Text
23-
<b> Bar</b>
21+
Text<b> Bar</b>
2422
</div>
2523
<p>
26-
foo
27-
<i>bar</i>
28-
<b>baz</b>
24+
foo<i>bar</i><b>baz</b>
2925
</p>
3026
</a>
3127
)

0 commit comments

Comments
 (0)