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: enable prettier trailing commas #35

Merged
merged 1 commit into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 42 additions & 37 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ module.exports = defineConfig({
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:regexp/recommended'
'plugin:regexp/recommended',
],
plugins: ['import', 'regexp'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021
ecmaVersion: 2021,
},
rules: {
eqeqeq: ['warn', 'always', { null: 'never' }],
Expand All @@ -25,36 +25,36 @@ module.exports = defineConfig({
'prefer-const': [
'warn',
{
destructuring: 'all'
}
destructuring: 'all',
},
],

'node/no-missing-import': [
'error',
{
allowModules: ['types', 'estree', 'less', 'sass', 'stylus'],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
}
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
},
],
'node/no-missing-require': [
'error',
{
// for try-catching yarn pnp
allowModules: ['pnpapi', 'vite'],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
}
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
},
],
'node/no-extraneous-import': [
'error',
{
allowModules: ['vite', 'less', 'sass', 'vitest']
}
allowModules: ['vite', 'less', 'sass', 'vitest'],
},
],
'node/no-extraneous-require': [
'error',
{
allowModules: ['vite']
}
allowModules: ['vite'],
},
],
'node/no-deprecated-api': 'off',
'node/no-unpublished-import': 'off',
Expand All @@ -65,11 +65,11 @@ module.exports = defineConfig({
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/explicit-module-boundary-types': [
'error',
{ allowArgumentsExplicitlyTypedAsAny: true }
{ allowArgumentsExplicitlyTypedAsAny: true },
],
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] }
{ allow: ['arrowFunctions'] },
],
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
Expand All @@ -80,12 +80,12 @@ module.exports = defineConfig({
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' }
{ prefer: 'type-imports' },
],

'import/no-nodejs-modules': [
'error',
{ allow: builtinModules.map((mod) => `node:${mod}`) }
{ allow: builtinModules.map((mod) => `node:${mod}`) },
],
'import/no-duplicates': 'error',
'import/order': 'error',
Expand All @@ -96,27 +96,32 @@ module.exports = defineConfig({
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false
}
allowSeparatedGroups: false,
},
],

'regexp/no-contradiction-with-assertion': 'error'
'regexp/no-contradiction-with-assertion': 'error',
},
overrides: [
{
files: ['packages/**'],
excludedFiles: '**/__tests__/**',
rules: {
'no-restricted-globals': ['error', 'require', '__dirname', '__filename']
}
'no-restricted-globals': [
'error',
'require',
'__dirname',
'__filename',
],
},
},
{
files: ['**/build.config.ts'],
rules: {
'no-undef': 'off',
'node/no-missing-import': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
files: ['playground/**'],
Expand All @@ -129,17 +134,17 @@ module.exports = defineConfig({
'node/no-unsupported-features/es-builtins': [
'error',
{
version: '^14.18.0 || >=16.0.0'
}
version: '^14.18.0 || >=16.0.0',
},
],
'node/no-unsupported-features/node-builtins': [
'error',
{
version: '^14.18.0 || >=16.0.0'
}
version: '^14.18.0 || >=16.0.0',
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
files: ['playground/**'],
Expand All @@ -148,21 +153,21 @@ module.exports = defineConfig({
'no-undef': 'off',
'no-empty': 'off',
'no-constant-condition': 'off',
'@typescript-eslint/no-empty-function': 'off'
}
'@typescript-eslint/no-empty-function': 'off',
},
},
{
files: ['*.js', '*.mjs', '*.cjs'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
files: ['*.d.ts'],
rules: {
'@typescript-eslint/triple-slash-reference': 'off'
}
}
'@typescript-eslint/triple-slash-reference': 'off',
},
},
],
reportUnusedDisableDirectives: true
reportUnusedDisableDirectives: true,
})
8 changes: 4 additions & 4 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"packageRules": [
{
"depTypeList": ["peerDependencies"],
"enabled": false
}
"enabled": false,
},
],
"ignoreDeps": [
// manually bumping
Expand All @@ -22,6 +22,6 @@
"source-map", // `source-map:v0.7.0+` needs more investigation
"dotenv-expand", // `dotenv-expand:6.0.0+` has breaking changes (#6858)
"kill-port", // `kill-port:^2.0.0 has perf issues (#8392)
"miniflare" // `miniflare:v2.0.0+` only supports node 16.7
]
"miniflare", // `miniflare:v2.0.0+` only supports node 16.7
],
}
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"tabWidth": 2,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "none",
"trailingComma": "all",
"overrides": [
{
"files": ["*.json5"],
Expand Down
12 changes: 6 additions & 6 deletions packages/plugin-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
plugins: [react()]
plugins: [react()],
})
```

Expand All @@ -29,7 +29,7 @@ react({
// Exclude storybook stories
exclude: /\.stories\.(t|j)sx?$/,
// Only .tsx files
include: '**/*.tsx'
include: '**/*.tsx',
})
```

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

```js
react({
jsxRuntime: 'classic'
jsxRuntime: 'classic',
})
```

Expand Down Expand Up @@ -69,9 +69,9 @@ If you are using ES syntax that are still in proposal status (e.g. class propert
react({
babel: {
parserOpts: {
plugins: ['decorators-legacy']
}
}
plugins: ['decorators-legacy'],
},
},
})
```

Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export default defineBuildConfig({
declaration: true,
rollup: {
emitCJS: true,
inlineDependencies: true
}
inlineDependencies: true,
},
})
8 changes: 4 additions & 4 deletions packages/plugin-react/src/fast-refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export const runtimePublicPath = '/@react-refresh'

const _require = createRequire(import.meta.url)
const reactRefreshDir = path.dirname(
_require.resolve('react-refresh/package.json')
_require.resolve('react-refresh/package.json'),
)
const runtimeFilePath = path.join(
reactRefreshDir,
'cjs/react-refresh-runtime.development.js'
'cjs/react-refresh-runtime.development.js',
)

export const runtimeCode = `
Expand Down Expand Up @@ -112,7 +112,7 @@ import.meta.hot.accept(mod => {
export function addRefreshWrapper(
code: string,
id: string,
accept: boolean
accept: boolean,
): string {
return (
header.replace('__SOURCE__', JSON.stringify(id)) +
Expand All @@ -133,7 +133,7 @@ export function isRefreshBoundary(ast: t.File): boolean {
if (declaration.type === 'ClassDeclaration') return false
if (declaration.type === 'VariableDeclaration') {
return declaration.declarations.every((variable) =>
isComponentLikeIdentifier(variable.id)
isComponentLikeIdentifier(variable.id),
)
}
if (declaration.type === 'FunctionDeclaration') {
Expand Down
Loading