Skip to content

Commit 0cb69b5

Browse files
committed
fix: lint
1 parent a52a647 commit 0cb69b5

File tree

11 files changed

+1338
-242
lines changed

11 files changed

+1338
-242
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ dist
7979

8080
# IDE
8181
.idea
82+
83+
core-vapor

.vscode/settings.json

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
11
{
2-
// Use the project's typescript version
3-
"typescript.tsdk": "node_modules/typescript/lib",
2+
// Enable the ESlint flat config support
3+
"eslint.experimental.useFlatConfig": true,
4+
"eslint.runtime": null,
45

5-
"cSpell.enabledLanguageIds": ["markdown", "plaintext", "text", "yml"],
6+
// Disable the default formatter, use eslint instead
7+
"prettier.enable": false,
8+
"editor.formatOnSave": false,
69

7-
// Use prettier to format typescript, javascript and JSON files
8-
"editor.formatOnSave": true,
9-
"[typescript]": {
10-
"editor.defaultFormatter": "esbenp.prettier-vscode"
10+
// Auto fix
11+
"editor.codeActionsOnSave": {
12+
"source.fixAll": "explicit",
13+
"source.organizeImports": "never"
1114
},
12-
"[javascript]": {
13-
"editor.defaultFormatter": "esbenp.prettier-vscode"
14-
},
15-
"[json]": {
16-
"editor.defaultFormatter": "esbenp.prettier-vscode"
17-
}
15+
16+
// Silent the stylistic rules in you IDE, but still auto fix them
17+
"eslint.rules.customizations": [
18+
{ "rule": "style/*", "severity": "off" },
19+
{ "rule": "*-indent", "severity": "off" },
20+
{ "rule": "*-spacing", "severity": "off" },
21+
{ "rule": "*-spaces", "severity": "off" },
22+
{ "rule": "*-order", "severity": "off" },
23+
{ "rule": "*-dangle", "severity": "off" },
24+
{ "rule": "*-newline", "severity": "off" },
25+
{ "rule": "*quotes", "severity": "off" },
26+
{ "rule": "*semi", "severity": "off" }
27+
],
28+
29+
// Enable eslint for all supported languages
30+
"eslint.validate": [
31+
"javascript",
32+
"javascriptreact",
33+
"typescript",
34+
"typescriptreact",
35+
"vue",
36+
"html",
37+
"markdown",
38+
"json",
39+
"jsonc",
40+
"yaml"
41+
]
1842
}

eslint.config.js

Lines changed: 9 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,16 @@
1-
const { builtinModules } = require('node:module')
1+
import antfu from '@antfu/eslint-config'
22

3-
const DOMGlobals = ['window', 'document']
4-
const NodeGlobals = ['module', 'require']
5-
6-
const banConstEnum = {
7-
selector: 'TSEnumDeclaration[const=true]',
8-
message:
9-
'Please use non-const enums. This project automatically inlines enums.',
10-
}
11-
12-
/**
13-
* @type {import('eslint-define-config').ESLintConfig}
14-
*/
15-
module.exports = {
16-
parser: '@typescript-eslint/parser',
17-
parserOptions: {
18-
sourceType: 'module',
19-
},
20-
plugins: ['jest', 'import', '@typescript-eslint'],
3+
export default antfu({
214
rules: {
22-
'no-debugger': 'error',
23-
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
24-
// most of the codebase are expected to be env agnostic
25-
'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
26-
27-
'no-restricted-syntax': [
28-
'error',
29-
banConstEnum,
30-
// since we target ES2015 for baseline support, we need to forbid object
31-
// rest spread usage in destructure as it compiles into a verbose helper.
32-
'ObjectPattern > RestElement',
33-
// tsc compiles assignment spread into Object.assign() calls, but esbuild
34-
// still generates verbose helpers, so spread assignment is also prohiboted
35-
'ObjectExpression > SpreadElement',
36-
'AwaitExpression',
37-
],
38-
'sort-imports': ['error', { ignoreDeclarationSort: true }],
39-
40-
'import/no-nodejs-modules': [
41-
'error',
42-
{ allow: builtinModules.map(mod => `node:${mod}`) },
43-
],
44-
// This rule enforces the preference for using '@ts-expect-error' comments in TypeScript
45-
// code to indicate intentional type errors, improving code clarity and maintainability.
46-
'@typescript-eslint/prefer-ts-expect-error': 'error',
47-
// Enforce the use of 'import type' for importing types
48-
'@typescript-eslint/consistent-type-imports': [
5+
'style/object-property-newline': 'off',
6+
'style/jsx-max-props-per-line': 'off',
7+
'style/jsx-curly-newline': 'off',
8+
'style/jsx-self-closing-comp': 'error',
9+
'style/jsx-one-expression-per-line': [
4910
'error',
5011
{
51-
fixStyle: 'inline-type-imports',
52-
disallowTypeAnnotations: false,
12+
allow: 'literal',
5313
},
5414
],
55-
// Enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers
56-
'@typescript-eslint/no-import-type-side-effects': 'error',
5715
},
58-
overrides: [
59-
// tests, no restrictions (runs in Node / jest with jsdom)
60-
{
61-
files: ['**/__tests__/**', 'packages/dts-test/**'],
62-
rules: {
63-
'no-console': 'off',
64-
'no-restricted-globals': 'off',
65-
'no-restricted-syntax': 'off',
66-
'jest/no-disabled-tests': 'error',
67-
'jest/no-focused-tests': 'error',
68-
},
69-
},
70-
// shared, may be used in any env
71-
{
72-
files: ['packages/shared/**', '.eslintrc.cjs'],
73-
rules: {
74-
'no-restricted-globals': 'off',
75-
},
76-
},
77-
// Packages targeting DOM
78-
{
79-
files: ['packages/{vue,vue-compat,runtime-dom}/**'],
80-
rules: {
81-
'no-restricted-globals': ['error', ...NodeGlobals],
82-
},
83-
},
84-
// Packages targeting Node
85-
{
86-
files: ['packages/{compiler-sfc,compiler-ssr,server-renderer}/**'],
87-
rules: {
88-
'no-restricted-globals': ['error', ...DOMGlobals],
89-
'no-restricted-syntax': ['error', banConstEnum],
90-
},
91-
},
92-
// Private package, browser only + no syntax restrictions
93-
{
94-
files: [
95-
'packages/template-explorer/**',
96-
'packages/sfc-playground/**',
97-
'playground/**',
98-
],
99-
rules: {
100-
'no-restricted-globals': ['error', ...NodeGlobals],
101-
'no-restricted-syntax': ['error', banConstEnum],
102-
'no-console': 'off',
103-
},
104-
},
105-
// JavaScript files
106-
{
107-
files: ['*.js', '*.cjs'],
108-
rules: {
109-
// We only do `no-unused-vars` checks for js files, TS files are checked by TypeScript itself.
110-
'no-unused-vars': ['error', { vars: 'all', args: 'none' }],
111-
},
112-
},
113-
// Node scripts
114-
{
115-
files: [
116-
'scripts/**',
117-
'./*.{js,ts}',
118-
'packages/*/*.js',
119-
'packages/vue/*/*.js',
120-
],
121-
rules: {
122-
'no-restricted-globals': 'off',
123-
'no-restricted-syntax': ['error', banConstEnum],
124-
'no-console': 'off',
125-
},
126-
},
127-
// Import nodejs modules in compiler-sfc
128-
{
129-
files: ['packages/compiler-sfc/src/**'],
130-
rules: {
131-
'import/no-nodejs-modules': ['error', { allow: builtinModules }],
132-
},
133-
},
134-
],
135-
}
16+
})

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "module",
44
"version": "0.1.2",
55
"packageManager": "[email protected]",
6-
"description": "",
6+
"description": "Convert JSX to Template for compiler-vapor",
77
"license": "MIT",
88
"homepage": "https://github.com/zhiyuanzmj/unplugin-vue-jsx-vapor#readme",
99
"repository": {
@@ -103,22 +103,22 @@
103103
"webpack": "^4 || ^5"
104104
},
105105
"peerDependenciesMeta": {
106-
"webpack": {
106+
"@nuxt/kit": {
107107
"optional": true
108108
},
109-
"rollup": {
109+
"@nuxt/schema": {
110110
"optional": true
111111
},
112-
"vite": {
112+
"esbuild": {
113113
"optional": true
114114
},
115-
"esbuild": {
115+
"rollup": {
116116
"optional": true
117117
},
118-
"@nuxt/kit": {
118+
"vite": {
119119
"optional": true
120120
},
121-
"@nuxt/schema": {
121+
"webpack": {
122122
"optional": true
123123
}
124124
},
@@ -128,10 +128,10 @@
128128
"vue": "link:core-vapor/packages/vue"
129129
},
130130
"devDependencies": {
131+
"@antfu/eslint-config": "^2.6.2",
131132
"@nuxt/kit": "^3.8.2",
132133
"@nuxt/schema": "^3.8.2",
133134
"@types/node": "^20.10.3",
134-
"@typescript-eslint/parser": "^6.18.1",
135135
"bumpp": "^9.2.0",
136136
"chalk": "^5.3.0",
137137
"eslint": "^8.55.0",

playground/App.vue

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="tsx">
2-
import { defineComponent } from 'vue';
2+
import { defineComponent } from 'vue'
33
import { ref } from 'vue/vapor'
44
55
export default defineComponent({
@@ -11,23 +11,44 @@ export default defineComponent({
1111
<form onSubmit_prevent>
1212
<input
1313
v-bind:value={count.value}
14-
onInput={(event: any) => count.value=event.target.value}
14+
onInput={(event: any) => count.value = event.target.value}
1515
/>
1616
17-
<div>v-text: <span v-text={count.value}/></div>
18-
<div>v-html: <span v-html={count.value}/></div>
19-
<div>v-once: <span v-once>{count.value}</span></div>
20-
<div>v-pre: <span v-pre>{count.value}</span></div>
21-
<div>v-cloak: <span v-cloak>{count.value}</span></div>
17+
<div>
18+
v-text:
19+
<span v-text={count.value} />
20+
</div>
21+
<div>
22+
v-html:
23+
<span v-html={count.value} />
24+
</div>
25+
<div>
26+
v-once:
27+
<span v-once>
28+
{count.value}
29+
</span>
30+
</div>
31+
<div>
32+
v-pre:
33+
<span v-pre>
34+
{count.value}
35+
</span>
36+
</div>
37+
<div>
38+
v-cloak:
39+
<span v-cloak>
40+
{count.value}
41+
</span>
42+
</div>
2243
</form>
2344
</>
2445
)
25-
}
46+
},
2647
})
2748
</script>
2849

2950
<style>
3051
[v-cloak] {
3152
color: red;
3253
}
33-
</style>
54+
</style>

playground/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
},
66
"devDependencies": {
77
"@vitejs/plugin-vue": "^5.0.2",
8-
"@vue-macros/volar": "^0.18.10",
9-
"vite": "^5.0.4",
10-
"vite-plugin-inspect": "^0.8.1",
118
"@vue-macros/define-render": "^1.5.1",
129
"@vue-macros/reactivity-transform": "^0.4.2",
13-
"unplugin-vue-jsx-vapor": "workspace:*"
10+
"@vue-macros/volar": "^0.18.10",
11+
"unplugin-vue-jsx-vapor": "workspace:*",
12+
"vite": "^5.0.4",
13+
"vite-plugin-inspect": "^0.8.1"
1414
}
1515
}

playground/tsconfig.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"compilerOptions": {
33
"target": "es2017",
4-
"lib": ["esnext", "DOM"],
5-
"module": "esnext",
6-
"jsxImportSource": "vue",
74
"jsx": "preserve",
85
"jsxFactory": "h",
6+
"jsxImportSource": "vue",
7+
"lib": ["esnext", "DOM"],
8+
"module": "esnext",
99
"moduleResolution": "node",
1010
"resolveJsonModule": true,
1111
"strict": true,
@@ -15,7 +15,7 @@
1515
"vueCompilerOptions": {
1616
"plugins": [
1717
"@vue-macros/volar/export-render",
18-
"@vue-macros/volar/jsx-directive",
18+
"@vue-macros/volar/jsx-directive"
1919
]
2020
},
2121
"exclude": ["dist", "eslint.config.js"]

0 commit comments

Comments
 (0)