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 #37

Merged
merged 1 commit into from
Dec 4, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
83 changes: 44 additions & 39 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,33 +96,38 @@ 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: ['*.spec.ts'],
rules: {
'node/no-extraneous-import': 'off'
}
'node/no-extraneous-import': 'off',
},
},
{
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 @@ -135,17 +140,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 @@ -154,21 +159,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
4 changes: 2 additions & 2 deletions packages/plugin-vue-jsx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default {
plugins: [
vueJsx({
// options are passed on to @vue/babel-plugin-jsx
})
]
}),
],
}
```

Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue-jsx/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export default defineBuildConfig({
clean: true,
declaration: true,
rollup: {
emitCJS: true
}
emitCJS: true,
},
})
44 changes: 22 additions & 22 deletions packages/plugin-vue-jsx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ function vueJsxPlugin(options: Options = {}): Plugin {
// only apply esbuild to ts files
// since we are handling jsx and tsx now
esbuild: {
include: /\.ts$/
include: /\.ts$/,
},
define: {
__VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true,
__VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false
}
__VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false,
},
}
},

Expand Down Expand Up @@ -88,10 +88,10 @@ function vueJsxPlugin(options: Options = {}): Plugin {
plugins.push([
// @ts-ignore missing type
await import('@babel/plugin-transform-typescript').then(
(r) => r.default
(r) => r.default,
),
// @ts-ignore
{ isTSX: true, allowExtensions: true }
{ isTSX: true, allowExtensions: true },
])
}

Expand All @@ -105,9 +105,9 @@ function vueJsxPlugin(options: Options = {}): Plugin {
const callee = _path.node.callee as Identifier
callee.name = `/* @__PURE__ */ ${callee.name}`
}
}
}
}
},
},
},
}
})
}
Expand All @@ -118,14 +118,14 @@ function vueJsxPlugin(options: Options = {}): Plugin {
plugins,
sourceMaps: needSourceMap,
sourceFileName: id,
configFile: false
configFile: false,
})!

if (!ssr && !needHmr) {
if (!result.code) return
return {
code: result.code,
map: result.map
map: result.map,
}
}

Expand Down Expand Up @@ -158,9 +158,9 @@ function vueJsxPlugin(options: Options = {}): Plugin {
({ name }) => ({
local: name,
exported: name,
id: getHash(id + name)
})
)
id: getHash(id + name),
}),
),
)
} else if (node.specifiers.length) {
for (const spec of node.specifiers) {
Expand All @@ -169,13 +169,13 @@ function vueJsxPlugin(options: Options = {}): Plugin {
spec.exported.type === 'Identifier'
) {
const matched = declaredComponents.find(
({ name }) => name === spec.local.name
({ name }) => name === spec.local.name,
)
if (matched) {
hotComponents.push({
local: spec.local.name,
exported: spec.exported.name,
id: getHash(id + spec.exported.name)
id: getHash(id + spec.exported.name),
})
}
}
Expand All @@ -187,21 +187,21 @@ function vueJsxPlugin(options: Options = {}): Plugin {
if (node.declaration.type === 'Identifier') {
const _name = node.declaration.name
const matched = declaredComponents.find(
({ name }) => name === _name
({ name }) => name === _name,
)
if (matched) {
hotComponents.push({
local: node.declaration.name,
exported: 'default',
id: getHash(id + 'default')
id: getHash(id + 'default'),
})
}
} else if (isDefineComponentCall(node.declaration)) {
hasDefault = true
hotComponents.push({
local: '__default__',
exported: 'default',
id: getHash(id + 'default')
id: getHash(id + 'default'),
})
}
}
Expand All @@ -212,7 +212,7 @@ function vueJsxPlugin(options: Options = {}): Plugin {
result.code =
result.code!.replace(
/export default defineComponent/g,
`const __default__ = defineComponent`
`const __default__ = defineComponent`,
) + `\nexport default __default__`
}

Expand Down Expand Up @@ -248,10 +248,10 @@ function vueJsxPlugin(options: Options = {}): Plugin {
if (!result.code) return
return {
code: result.code,
map: result.map
map: result.map,
}
}
}
},
}
}

Expand All @@ -260,7 +260,7 @@ function parseComponentDecls(node: types.VariableDeclaration, source: string) {
for (const decl of node.declarations) {
if (decl.id.type === 'Identifier' && isDefineComponentCall(decl.init)) {
names.push({
name: decl.id.name
name: decl.id.name,
})
}
}
Expand Down