Skip to content

Commit 374196f

Browse files
committed
Merge branch 'master' into tsdown
# Conflicts: # .gitignore # eslint.config.mjs # package.json # tsconfig.json
2 parents 1490841 + 2c29d7a commit 374196f

26 files changed

+637
-579
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ jobs:
5555
run: npm install -f
5656
- name: Install ESLint v${{ matrix.eslint }}
5757
run: node scripts/ci-install-eslint ${{ matrix.eslint }}
58-
- name: Build
59-
run: npm run -s build
6058
- name: Test
61-
run: npm run -s test:mocha
59+
run: npm run -s test
6260
test-for-old-eslint:
6361
name: Test
6462
strategy:
@@ -82,4 +80,4 @@ jobs:
8280
- name: Install ESLint v${{ matrix.eslint }}
8381
run: node scripts/ci-install-eslint ${{ matrix.eslint }}
8482
- name: Test
85-
run: npm run -s test:debug
83+
run: npm run -s test

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/.nyc_output
21
/coverage
32
node_modules
43
/test/temp

.nycrc

Lines changed: 0 additions & 19 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const compat = new FlatCompat({
2222
export default [
2323
{
2424
ignores: [
25-
".nyc_output",
2625
"coverage",
2726
"dist",
2827
"**/node_modules",
@@ -62,7 +61,7 @@ export default [
6261
},
6362

6463
loggerFn: false,
65-
project: "tsconfig.json",
64+
project: ["tsconfig.json", "tsconfig.test.json"],
6665
},
6766
},
6867

package.json

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030
"@eslint/js": "^9.19.0",
3131
"@types/debug": "^4.1.7",
3232
"@types/estree": "^1.0.0",
33-
"@types/mocha": "^9.0.0",
3433
"@types/node": "^18.8.4",
3534
"@types/semver": "^7.3.12",
3635
"@typescript-eslint/eslint-plugin": "^8.22.0",
3736
"@typescript-eslint/parser": "^8.22.0",
37+
"@vitest/coverage-v8": "^3.2.4",
38+
"@vitest/ui": "^3.2.4",
3839
"chokidar": "^3.5.2",
3940
"cross-spawn": "^7.0.3",
4041
"eslint": "^9.19.0",
@@ -46,38 +47,31 @@
4647
"eslint-plugin-unicorn": "^57.0.0",
4748
"fs-extra": "^10.0.0",
4849
"jsonc-eslint-parser": "^2.0.3",
49-
"mocha": "^9.1.3",
5050
"npm-run-all": "^4.1.5",
51-
"nyc": "^15.1.0",
52-
"opener": "^1.5.2",
5351
"prettier": "^3.4.2",
5452
"rimraf": "^3.0.2",
5553
"ts-node": "^10.9.2",
5654
"tsdown": "^0.12.9",
5755
"typescript": "~5.7.3",
56+
"vite": "^6.3.5",
57+
"vitest": "^3.2.4",
5858
"wait-on": "^6.0.0",
5959
"warun": "^1.0.0"
6060
},
6161
"scripts": {
6262
"build": "tsdown",
63-
"clean": "rimraf .nyc_output coverage",
64-
"coverage": "opener ./coverage/lcov-report/index.html",
63+
"coverage": "vitest --coverage --ui",
6564
"lint": "eslint src test package.json",
66-
"pretest": "run-s build lint",
67-
"test": "npm run -s test:mocha",
68-
"test:mocha": "mocha --require ts-node/register \"test/*.js\" --reporter dot --timeout 60000",
69-
"test:cover": "nyc mocha \"test/*.js\" --reporter dot --timeout 60000",
70-
"test:debug": "mocha --require ts-node/register/transpile-only \"test/*.js\" --reporter dot --timeout 60000",
65+
"test": "vitest",
66+
"test:cover": "vitest --coverage",
7167
"update-fixtures": "ts-node --transpile-only scripts/update-fixtures-ast.js && ts-node --transpile-only scripts/update-fixtures-document-fragment.js",
7268
"preversion": "npm test",
7369
"version": "npm run -s build",
7470
"postversion": "git push && git push --tags",
7571
"prewatch": "npm run -s clean",
7672
"watch": "run-p watch:*",
7773
"watch:tsdown": "tsdown --watch",
78-
"watch:test": "wait-on dist/index.js && warun dist/index.js \"test/*.js\" \"test/fixtures/ast/*/*.json\" \"test/fixtures/*\" --debounce 1000 --no-initial -- nyc mocha \"test/*.js\" --reporter dot --timeout 10000",
79-
"watch:update-ast": "wait-on dist/index.js && warun dist/index.js \"test/fixtures/ast/*/*.vue\" -- ts-node scripts/update-fixtures-ast.js",
80-
"watch:coverage-report": "wait-on coverage/lcov-report/index.html && opener coverage/lcov-report/index.html"
74+
"watch:update-ast": "wait-on dist/index.js && warun dist/index.js \"test/fixtures/ast/*/*.vue\" -- ts-node scripts/update-fixtures-ast.js"
8175
},
8276
"repository": {
8377
"type": "git",

scripts/ci-install-eslint.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ function sh(command) {
3030

3131
// Install ESLint of the requested version
3232
await sh(`npm install eslint@${requestedVersionSpec} -f`)
33+
if (Number(requestedVersion) < 9)
34+
await sh(`npm install @types/eslint -D -f`)
3335

3436
// Install ESLint submodule of the requested version
3537
// const installedVersion = require("eslint/package.json").version

src/ast/nodes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { ParseError } from "./errors"
88
import type { HasLocation } from "./locations"
99
import type { Token } from "./tokens"
1010
import type { TSESTree } from "@typescript-eslint/utils"
11+
import type { ParserServices } from "../parser-services"
1112

1213
//------------------------------------------------------------------------------
1314
// Common
@@ -70,7 +71,7 @@ export type ESLintNode =
7071
*/
7172
export interface ESLintExtendedProgram {
7273
ast: ESLintProgram
73-
services?: {}
74+
services?: ParserServices
7475
visitorKeys?: { [type: string]: string[] }
7576
scopeManager?: ScopeManager
7677
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function parseForESLint(
8585
* @param options The parser options.
8686
* @returns The parsing result.
8787
*/
88-
export function parse(code: string, options: any): AST.ESLintProgram {
88+
export function parse(code: string, options?: any): AST.ESLintProgram {
8989
return parseForESLint(code, options).ast
9090
}
9191

src/parser-services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export interface ParserServices {
8383
| ((lang: string | null, customBlock: VElement) => boolean)
8484
create: CustomBlockVisitorFactory
8585
},
86-
scriptVisitor: { [key: string]: (...args: any) => void },
86+
scriptVisitor?: { [key: string]: (...args: any) => void },
8787
): { [key: string]: (...args: any) => void }
8888

8989
/**
@@ -262,7 +262,7 @@ export function define(
262262
| ((lang: string | null, customBlock: VElement) => boolean)
263263
create: CustomBlockVisitorFactory
264264
},
265-
scriptVisitor: { [key: string]: (...args: any) => void },
265+
scriptVisitor?: { [key: string]: (...args: any) => void },
266266
): { [key: string]: (...args: any) => void } {
267267
if (scriptVisitor == null) {
268268
scriptVisitor = {} //eslint-disable-line no-param-reassign

0 commit comments

Comments
 (0)