Skip to content

Commit 697bf65

Browse files
feat: custom eslint parser for Vue Vine (#56)
* chore: resolve lint issues * chore: playwright deps * wip: eslint-parser html utils * wip: more detailed description * feat: adjust token pos based on global offset * chore: remove duplicated import * fix: use basic tokens instead of intermediate * feat: init VineESLintAnalyzer * wip: refactor some names and orders * feat(eslint): basically implemented template root * fix(eslint): template root range * fix(eslint): build process * wip: ready for global analyze scope manager * wip: ready for global analyze scope manager * feat(eslint): basically implemented eslint-parser * fix: validate eslint in IDE
1 parent 3aecdd4 commit 697bf65

Some content is hidden

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

69 files changed

+18467
-7114
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ scripts/*.sh
1111
# because we didn't implement `.vine.ts`
1212
# template ESTree support yet
1313
packages/create-vue-vine/**/*.vine.ts
14-
packages/playground/**/*.vine.ts
14+

.eslintrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"extends": "@antfu",
33
"rules": {
4-
// "no-console": "off",
5-
// "no-useless-return": "off",
64
"curly": "off",
75
"prefer-const": "off"
86
}

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"prettier.enable": false
2+
"prettier.enable": false,
3+
"cSpell.enabled": false,
4+
"testing.automaticallyOpenPeekView": "never"
35
}

package.json

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,24 @@
88
"scripts": {
99
"play": "pnpm --filter @vue-vine/playground run dev",
1010
"dev": "esno scripts/run-dev.js",
11-
"build": "pnpm build:compiler && pnpm build:vite && pnpm build:main",
11+
"build": "pnpm build:compiler && pnpm build:vite && pnpm build:main && pnpm build:eslint-parser",
1212
"dev:compiler": "cross-env NODE_ENV=development pnpm --filter @vue-vine/compiler run dev",
1313
"dev:vite": "cross-env NODE_ENV=development pnpm --filter @vue-vine/vite-plugin run dev",
1414
"dev:main": "cross-env NODE_ENV=development pnpm --filter vue-vine run dev",
15-
"build:compiler": "cross-env NODE_ENV=development pnpm --filter @vue-vine/compiler run build",
16-
"build:vite": "cross-env NODE_ENV=development pnpm --filter @vue-vine/vite-plugin run build",
17-
"build:main": "cross-env NODE_ENV=development pnpm --filter vue-vine run build",
18-
"ext:dev": "cross-env NODE_ENV=development esno scripts/ext-dev.js dev",
19-
"ext:build": "cross-env NODE_ENV=production esno scripts/ext-dev.js build",
20-
"test": "pnpm test:compiler --run && pnpm test:e2e --run",
15+
"build:compiler": "cross-env NODE_ENV=production pnpm --filter @vue-vine/compiler run build",
16+
"build:vite": "cross-env NODE_ENV=production pnpm --filter @vue-vine/vite-plugin run build",
17+
"build:lsp": "cross-env NODE_ENV=production pnpm --filter @vue-vine/language-server run build",
18+
"build:eslint-parser": "cross-env NODE_ENV=production pnpm --filter @vue-vine/eslint-parser run build",
19+
"build:main": "cross-env NODE_ENV=production pnpm --filter vue-vine run build",
20+
"ext:dev": "cross-env NODE_ENV=development esno scripts/ext-dev.js",
21+
"ext:tsc": "cross-env NODE_ENV=production pnpm --filter vue-vine-extension run build:tsc",
22+
"ext:esbuild": "cross-env NODE_ENV=production pnpm --filter vue-vine-extension run build:esbuild",
23+
"ext:build": "cross-env NODE_ENV=production pnpm build:compiler && pnpm ext:tsc && pnpm ext:esbuild && pnpm build:lsp",
24+
"test": "esno scripts/run-test.js",
2125
"test:compiler": "pnpm --filter @vue-vine/compiler run test",
2226
"test:e2e": "pnpm --filter @vue-vine/e2e-test run test",
23-
"lint": "eslint . --cache",
27+
"test:eslint-parser": "pnpm --filter @vue-vine/eslint-parser run test",
28+
"lint": "pnpm run build:eslint-parser && eslint . --cache",
2429
"lint:fix": "pnpm lint --fix",
2530
"docs:dev": "pnpm --filter vue-vine-docs run dev",
2631
"docs:build": "pnpm --filter vue-vine-docs run build",
@@ -31,7 +36,7 @@
3136
"update:deps": "esno scripts/update-deps.js"
3237
},
3338
"devDependencies": {
34-
"@antfu/eslint-config": "^0.38.6",
39+
"@antfu/eslint-config": "^0.41.0",
3540
"@baiwusanyu/utils-log": "^1.0.15",
3641
"@changesets/cli": "^2.26.2",
3742
"concurrently": "^8.2.1",
@@ -40,7 +45,6 @@
4045
"eslint": "^8.48.0",
4146
"esno": "^0.16.3",
4247
"lint-staged": "^13.3.0",
43-
"pkgroll": "^1.11.0",
4448
"playwright-chromium": "^1.37.1",
4549
"rimraf": "^5.0.1",
4650
"rollup": "^3.28.1",
@@ -51,6 +55,11 @@
5155
"typescript": "^5.2.2",
5256
"vitest": "^0.31.4"
5357
},
58+
"pnpm": {
59+
"overrides": {
60+
"vscode-uri": "^3.0.8"
61+
}
62+
},
5463
"simple-git-hooks": {
5564
"pre-commit": "pnpm esno scripts/pre-commit.js"
5665
},

packages/compiler/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type {
2727
} from './src/types'
2828

2929
export function createCompilerCtx(
30-
options: VineCompilerOptions,
30+
options: VineCompilerOptions = {},
3131
): VineCompilerCtx {
3232
return {
3333
fileCtxMap: new Map(),

packages/compiler/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
".": {
1313
"dev": "./index.ts",
1414
"types": "./dist/index.d.ts",
15-
"require": "./dist/index.js",
16-
"import": "./dist/index.mjs"
15+
"import": "./dist/index.mjs",
16+
"require": "./dist/index.js"
1717
}
1818
},
1919
"main": "./dist/index.js",

packages/compiler/src/style/analyze-css-vars.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Implementation from vue
33
* https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/style/cssVars.ts
44
*/
5-
const enum LexerState {
6-
inParens,
5+
enum LexerState {
6+
inParens = 1,
77
inSingleQuoteString,
88
inDoubleQuoteString,
99
}

packages/compiler/src/style/trim-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { PluginCreator } from 'postcss'
22

3-
const trimPlugin: PluginCreator<{}> = () => {
3+
const trimPlugin: PluginCreator<object> = () => {
44
return {
55
postcssPlugin: 'vine-style-trim',
66
Once(root) {

packages/create-vue-vine/src/commands/create.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { join, relative } from 'node:path'
22
import { rm } from 'node:fs/promises'
3+
import process from 'node:process'
34
import { intro, log, outro, spinner } from '@clack/prompts'
45
import { Root, defineCommand } from 'clerc'
56
import gradient from 'gradient-string'

packages/create-vue-vine/src/utils/clack.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import process from 'node:process'
12
import { cancel as _cancel, confirm as _confirm, text as _text, isCancel } from '@clack/prompts'
23

34
export function cancel(...args: Parameters<typeof _cancel>): never {

0 commit comments

Comments
 (0)