Skip to content

Commit eef8929

Browse files
authored
chore: enable prettier trailing commas (#37)
1 parent 7899924 commit eef8929

Some content is hidden

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

60 files changed

+448
-443
lines changed

.eslintrc.cjs

+44-39
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ module.exports = defineConfig({
88
'eslint:recommended',
99
'plugin:node/recommended',
1010
'plugin:@typescript-eslint/recommended',
11-
'plugin:regexp/recommended'
11+
'plugin:regexp/recommended',
1212
],
1313
plugins: ['import', 'regexp'],
1414
parser: '@typescript-eslint/parser',
1515
parserOptions: {
1616
sourceType: 'module',
17-
ecmaVersion: 2021
17+
ecmaVersion: 2021,
1818
},
1919
rules: {
2020
eqeqeq: ['warn', 'always', { null: 'never' }],
@@ -25,36 +25,36 @@ module.exports = defineConfig({
2525
'prefer-const': [
2626
'warn',
2727
{
28-
destructuring: 'all'
29-
}
28+
destructuring: 'all',
29+
},
3030
],
3131

3232
'node/no-missing-import': [
3333
'error',
3434
{
3535
allowModules: ['types', 'estree', 'less', 'sass', 'stylus'],
36-
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
37-
}
36+
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
37+
},
3838
],
3939
'node/no-missing-require': [
4040
'error',
4141
{
4242
// for try-catching yarn pnp
4343
allowModules: ['pnpapi', 'vite'],
44-
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
45-
}
44+
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
45+
},
4646
],
4747
'node/no-extraneous-import': [
4848
'error',
4949
{
50-
allowModules: ['vite', 'less', 'sass', 'vitest']
51-
}
50+
allowModules: ['vite', 'less', 'sass', 'vitest'],
51+
},
5252
],
5353
'node/no-extraneous-require': [
5454
'error',
5555
{
56-
allowModules: ['vite']
57-
}
56+
allowModules: ['vite'],
57+
},
5858
],
5959
'node/no-deprecated-api': 'off',
6060
'node/no-unpublished-import': 'off',
@@ -65,11 +65,11 @@ module.exports = defineConfig({
6565
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
6666
'@typescript-eslint/explicit-module-boundary-types': [
6767
'error',
68-
{ allowArgumentsExplicitlyTypedAsAny: true }
68+
{ allowArgumentsExplicitlyTypedAsAny: true },
6969
],
7070
'@typescript-eslint/no-empty-function': [
7171
'error',
72-
{ allow: ['arrowFunctions'] }
72+
{ allow: ['arrowFunctions'] },
7373
],
7474
'@typescript-eslint/no-empty-interface': 'off',
7575
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
@@ -80,12 +80,12 @@ module.exports = defineConfig({
8080
'@typescript-eslint/no-var-requires': 'off',
8181
'@typescript-eslint/consistent-type-imports': [
8282
'error',
83-
{ prefer: 'type-imports' }
83+
{ prefer: 'type-imports' },
8484
],
8585

8686
'import/no-nodejs-modules': [
8787
'error',
88-
{ allow: builtinModules.map((mod) => `node:${mod}`) }
88+
{ allow: builtinModules.map((mod) => `node:${mod}`) },
8989
],
9090
'import/no-duplicates': 'error',
9191
'import/order': 'error',
@@ -96,33 +96,38 @@ module.exports = defineConfig({
9696
ignoreDeclarationSort: true,
9797
ignoreMemberSort: false,
9898
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
99-
allowSeparatedGroups: false
100-
}
99+
allowSeparatedGroups: false,
100+
},
101101
],
102102

103-
'regexp/no-contradiction-with-assertion': 'error'
103+
'regexp/no-contradiction-with-assertion': 'error',
104104
},
105105
overrides: [
106106
{
107107
files: ['packages/**'],
108108
excludedFiles: '**/__tests__/**',
109109
rules: {
110-
'no-restricted-globals': ['error', 'require', '__dirname', '__filename']
111-
}
110+
'no-restricted-globals': [
111+
'error',
112+
'require',
113+
'__dirname',
114+
'__filename',
115+
],
116+
},
112117
},
113118
{
114119
files: ['*.spec.ts'],
115120
rules: {
116-
'node/no-extraneous-import': 'off'
117-
}
121+
'node/no-extraneous-import': 'off',
122+
},
118123
},
119124
{
120125
files: ['**/build.config.ts'],
121126
rules: {
122127
'no-undef': 'off',
123128
'node/no-missing-import': 'off',
124-
'@typescript-eslint/explicit-module-boundary-types': 'off'
125-
}
129+
'@typescript-eslint/explicit-module-boundary-types': 'off',
130+
},
126131
},
127132
{
128133
files: ['playground/**'],
@@ -135,17 +140,17 @@ module.exports = defineConfig({
135140
'node/no-unsupported-features/es-builtins': [
136141
'error',
137142
{
138-
version: '^14.18.0 || >=16.0.0'
139-
}
143+
version: '^14.18.0 || >=16.0.0',
144+
},
140145
],
141146
'node/no-unsupported-features/node-builtins': [
142147
'error',
143148
{
144-
version: '^14.18.0 || >=16.0.0'
145-
}
149+
version: '^14.18.0 || >=16.0.0',
150+
},
146151
],
147-
'@typescript-eslint/explicit-module-boundary-types': 'off'
148-
}
152+
'@typescript-eslint/explicit-module-boundary-types': 'off',
153+
},
149154
},
150155
{
151156
files: ['playground/**'],
@@ -154,21 +159,21 @@ module.exports = defineConfig({
154159
'no-undef': 'off',
155160
'no-empty': 'off',
156161
'no-constant-condition': 'off',
157-
'@typescript-eslint/no-empty-function': 'off'
158-
}
162+
'@typescript-eslint/no-empty-function': 'off',
163+
},
159164
},
160165
{
161166
files: ['*.js', '*.mjs', '*.cjs'],
162167
rules: {
163-
'@typescript-eslint/explicit-module-boundary-types': 'off'
164-
}
168+
'@typescript-eslint/explicit-module-boundary-types': 'off',
169+
},
165170
},
166171
{
167172
files: ['*.d.ts'],
168173
rules: {
169-
'@typescript-eslint/triple-slash-reference': 'off'
170-
}
171-
}
174+
'@typescript-eslint/triple-slash-reference': 'off',
175+
},
176+
},
172177
],
173-
reportUnusedDisableDirectives: true
178+
reportUnusedDisableDirectives: true,
174179
})

.github/renovate.json5

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"packageRules": [
99
{
1010
"depTypeList": ["peerDependencies"],
11-
"enabled": false
12-
}
11+
"enabled": false,
12+
},
1313
],
1414
"ignoreDeps": [
1515
// manually bumping
@@ -22,6 +22,6 @@
2222
"source-map", // `source-map:v0.7.0+` needs more investigation
2323
"dotenv-expand", // `dotenv-expand:6.0.0+` has breaking changes (#6858)
2424
"kill-port", // `kill-port:^2.0.0 has perf issues (#8392)
25-
"miniflare" // `miniflare:v2.0.0+` only supports node 16.7
26-
]
25+
"miniflare", // `miniflare:v2.0.0+` only supports node 16.7
26+
],
2727
}

.prettierrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"tabWidth": 2,
44
"singleQuote": true,
55
"printWidth": 80,
6-
"trailingComma": "none",
6+
"trailingComma": "all",
77
"overrides": [
88
{
99
"files": ["*.json5"],

packages/plugin-vue-jsx/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export default {
1010
plugins: [
1111
vueJsx({
1212
// options are passed on to @vue/babel-plugin-jsx
13-
})
14-
]
13+
}),
14+
],
1515
}
1616
```
1717

packages/plugin-vue-jsx/build.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export default defineBuildConfig({
55
clean: true,
66
declaration: true,
77
rollup: {
8-
emitCJS: true
9-
}
8+
emitCJS: true,
9+
},
1010
})

packages/plugin-vue-jsx/src/index.ts

+22-22
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ function vueJsxPlugin(options: Options = {}): Plugin {
4949
// only apply esbuild to ts files
5050
// since we are handling jsx and tsx now
5151
esbuild: {
52-
include: /\.ts$/
52+
include: /\.ts$/,
5353
},
5454
define: {
5555
__VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true,
56-
__VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false
57-
}
56+
__VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false,
57+
},
5858
}
5959
},
6060

@@ -88,10 +88,10 @@ function vueJsxPlugin(options: Options = {}): Plugin {
8888
plugins.push([
8989
// @ts-ignore missing type
9090
await import('@babel/plugin-transform-typescript').then(
91-
(r) => r.default
91+
(r) => r.default,
9292
),
9393
// @ts-ignore
94-
{ isTSX: true, allowExtensions: true }
94+
{ isTSX: true, allowExtensions: true },
9595
])
9696
}
9797

@@ -105,9 +105,9 @@ function vueJsxPlugin(options: Options = {}): Plugin {
105105
const callee = _path.node.callee as Identifier
106106
callee.name = `/* @__PURE__ */ ${callee.name}`
107107
}
108-
}
109-
}
110-
}
108+
},
109+
},
110+
},
111111
}
112112
})
113113
}
@@ -118,14 +118,14 @@ function vueJsxPlugin(options: Options = {}): Plugin {
118118
plugins,
119119
sourceMaps: needSourceMap,
120120
sourceFileName: id,
121-
configFile: false
121+
configFile: false,
122122
})!
123123

124124
if (!ssr && !needHmr) {
125125
if (!result.code) return
126126
return {
127127
code: result.code,
128-
map: result.map
128+
map: result.map,
129129
}
130130
}
131131

@@ -158,9 +158,9 @@ function vueJsxPlugin(options: Options = {}): Plugin {
158158
({ name }) => ({
159159
local: name,
160160
exported: name,
161-
id: getHash(id + name)
162-
})
163-
)
161+
id: getHash(id + name),
162+
}),
163+
),
164164
)
165165
} else if (node.specifiers.length) {
166166
for (const spec of node.specifiers) {
@@ -169,13 +169,13 @@ function vueJsxPlugin(options: Options = {}): Plugin {
169169
spec.exported.type === 'Identifier'
170170
) {
171171
const matched = declaredComponents.find(
172-
({ name }) => name === spec.local.name
172+
({ name }) => name === spec.local.name,
173173
)
174174
if (matched) {
175175
hotComponents.push({
176176
local: spec.local.name,
177177
exported: spec.exported.name,
178-
id: getHash(id + spec.exported.name)
178+
id: getHash(id + spec.exported.name),
179179
})
180180
}
181181
}
@@ -187,21 +187,21 @@ function vueJsxPlugin(options: Options = {}): Plugin {
187187
if (node.declaration.type === 'Identifier') {
188188
const _name = node.declaration.name
189189
const matched = declaredComponents.find(
190-
({ name }) => name === _name
190+
({ name }) => name === _name,
191191
)
192192
if (matched) {
193193
hotComponents.push({
194194
local: node.declaration.name,
195195
exported: 'default',
196-
id: getHash(id + 'default')
196+
id: getHash(id + 'default'),
197197
})
198198
}
199199
} else if (isDefineComponentCall(node.declaration)) {
200200
hasDefault = true
201201
hotComponents.push({
202202
local: '__default__',
203203
exported: 'default',
204-
id: getHash(id + 'default')
204+
id: getHash(id + 'default'),
205205
})
206206
}
207207
}
@@ -212,7 +212,7 @@ function vueJsxPlugin(options: Options = {}): Plugin {
212212
result.code =
213213
result.code!.replace(
214214
/export default defineComponent/g,
215-
`const __default__ = defineComponent`
215+
`const __default__ = defineComponent`,
216216
) + `\nexport default __default__`
217217
}
218218

@@ -248,10 +248,10 @@ function vueJsxPlugin(options: Options = {}): Plugin {
248248
if (!result.code) return
249249
return {
250250
code: result.code,
251-
map: result.map
251+
map: result.map,
252252
}
253253
}
254-
}
254+
},
255255
}
256256
}
257257

@@ -260,7 +260,7 @@ function parseComponentDecls(node: types.VariableDeclaration, source: string) {
260260
for (const decl of node.declarations) {
261261
if (decl.id.type === 'Identifier' && isDefineComponentCall(decl.init)) {
262262
names.push({
263-
name: decl.id.name
263+
name: decl.id.name,
264264
})
265265
}
266266
}

0 commit comments

Comments
 (0)