Skip to content

Commit b647e74

Browse files
authored
chore: enable prettier trailing commas (#35)
1 parent 4422206 commit b647e74

38 files changed

+245
-240
lines changed

.eslintrc.cjs

Lines changed: 42 additions & 37 deletions
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,27 +96,32 @@ 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: ['**/build.config.ts'],
115120
rules: {
116121
'no-undef': 'off',
117122
'node/no-missing-import': 'off',
118-
'@typescript-eslint/explicit-module-boundary-types': 'off'
119-
}
123+
'@typescript-eslint/explicit-module-boundary-types': 'off',
124+
},
120125
},
121126
{
122127
files: ['playground/**'],
@@ -129,17 +134,17 @@ module.exports = defineConfig({
129134
'node/no-unsupported-features/es-builtins': [
130135
'error',
131136
{
132-
version: '^14.18.0 || >=16.0.0'
133-
}
137+
version: '^14.18.0 || >=16.0.0',
138+
},
134139
],
135140
'node/no-unsupported-features/node-builtins': [
136141
'error',
137142
{
138-
version: '^14.18.0 || >=16.0.0'
139-
}
143+
version: '^14.18.0 || >=16.0.0',
144+
},
140145
],
141-
'@typescript-eslint/explicit-module-boundary-types': 'off'
142-
}
146+
'@typescript-eslint/explicit-module-boundary-types': 'off',
147+
},
143148
},
144149
{
145150
files: ['playground/**'],
@@ -148,21 +153,21 @@ module.exports = defineConfig({
148153
'no-undef': 'off',
149154
'no-empty': 'off',
150155
'no-constant-condition': 'off',
151-
'@typescript-eslint/no-empty-function': 'off'
152-
}
156+
'@typescript-eslint/no-empty-function': 'off',
157+
},
153158
},
154159
{
155160
files: ['*.js', '*.mjs', '*.cjs'],
156161
rules: {
157-
'@typescript-eslint/explicit-module-boundary-types': 'off'
158-
}
162+
'@typescript-eslint/explicit-module-boundary-types': 'off',
163+
},
159164
},
160165
{
161166
files: ['*.d.ts'],
162167
rules: {
163-
'@typescript-eslint/triple-slash-reference': 'off'
164-
}
165-
}
168+
'@typescript-eslint/triple-slash-reference': 'off',
169+
},
170+
},
166171
],
167-
reportUnusedDisableDirectives: true
172+
reportUnusedDisableDirectives: true,
168173
})

.github/renovate.json5

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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-react/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { defineConfig } from 'vite'
1414
import react from '@vitejs/plugin-react'
1515

1616
export default defineConfig({
17-
plugins: [react()]
17+
plugins: [react()],
1818
})
1919
```
2020

@@ -29,7 +29,7 @@ react({
2929
// Exclude storybook stories
3030
exclude: /\.stories\.(t|j)sx?$/,
3131
// Only .tsx files
32-
include: '**/*.tsx'
32+
include: '**/*.tsx',
3333
})
3434
```
3535

@@ -39,7 +39,7 @@ By default, the plugin uses the [automatic JSX runtime](https://github.com/alloc
3939

4040
```js
4141
react({
42-
jsxRuntime: 'classic'
42+
jsxRuntime: 'classic',
4343
})
4444
```
4545

@@ -69,9 +69,9 @@ If you are using ES syntax that are still in proposal status (e.g. class propert
6969
react({
7070
babel: {
7171
parserOpts: {
72-
plugins: ['decorators-legacy']
73-
}
74-
}
72+
plugins: ['decorators-legacy'],
73+
},
74+
},
7575
})
7676
```
7777

packages/plugin-react/build.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export default defineBuildConfig({
77
declaration: true,
88
rollup: {
99
emitCJS: true,
10-
inlineDependencies: true
11-
}
10+
inlineDependencies: true,
11+
},
1212
})

packages/plugin-react/src/fast-refresh.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export const runtimePublicPath = '/@react-refresh'
77

88
const _require = createRequire(import.meta.url)
99
const reactRefreshDir = path.dirname(
10-
_require.resolve('react-refresh/package.json')
10+
_require.resolve('react-refresh/package.json'),
1111
)
1212
const runtimeFilePath = path.join(
1313
reactRefreshDir,
14-
'cjs/react-refresh-runtime.development.js'
14+
'cjs/react-refresh-runtime.development.js',
1515
)
1616

1717
export const runtimeCode = `
@@ -112,7 +112,7 @@ import.meta.hot.accept(mod => {
112112
export function addRefreshWrapper(
113113
code: string,
114114
id: string,
115-
accept: boolean
115+
accept: boolean,
116116
): string {
117117
return (
118118
header.replace('__SOURCE__', JSON.stringify(id)) +
@@ -133,7 +133,7 @@ export function isRefreshBoundary(ast: t.File): boolean {
133133
if (declaration.type === 'ClassDeclaration') return false
134134
if (declaration.type === 'VariableDeclaration') {
135135
return declaration.declarations.every((variable) =>
136-
isComponentLikeIdentifier(variable.id)
136+
isComponentLikeIdentifier(variable.id),
137137
)
138138
}
139139
if (declaration.type === 'FunctionDeclaration') {

0 commit comments

Comments
 (0)