Skip to content

test: move to vitest #269

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

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e47b73f
feat: move `parser-options` to `vitest`
9romise Jul 4, 2025
1cdfa2f
feat: move `crlf` to `vitest`
9romise Jul 4, 2025
cff4786
chore: update
9romise Jul 4, 2025
97a675f
feat: move `define-document-visitor` to `vitest`
9romise Jul 4, 2025
4f1c036
feat: move `define-custom-blocks-visitor` to `vitest`
9romise Jul 5, 2025
1918ef5
feat: move `parser-options-project` to `vitest`
9romise Jul 5, 2025
d0804ec
feat: move `document-fragment` to `vitest`
9romise Jul 5, 2025
9308a3d
fix: correct ParserServices type
9romise Jul 5, 2025
6dea54a
feat: move `tokens` to `vitest`
9romise Jul 5, 2025
d07b415
refactor: use `replacer` in `test-utils`
9romise Jul 5, 2025
e2f8d84
chore: up
9romise Jul 5, 2025
7c58687
feat: enhance test-utils
9romise Jul 5, 2025
3386bab
refactor: move `variables-references` to `vitest`
9romise Jul 5, 2025
52e752b
feat: move `ast` to `vitest`
9romise Jul 5, 2025
bd0ad3d
feat: move `index` to `vitest`
9romise Jul 5, 2025
8099d38
refactor: move all test to `vitest`
9romise Jul 5, 2025
f3f67de
chore: enhance type definition
9romise Jul 5, 2025
3cd2989
chore: uninstall mocha
9romise Jul 5, 2025
94d42ef
test: update
9romise Jul 5, 2025
7367567
chore: update
9romise Jul 5, 2025
7aa76c6
chore: update ci
9romise Jul 5, 2025
dd1335a
fix: update something maybe wrong
9romise Jul 5, 2025
f558d6a
chore: update, try fix ci
9romise Jul 5, 2025
6c1b3a9
chore: up
9romise Jul 5, 2025
a27eccc
ci: try fix
9romise Jul 5, 2025
5a21916
chore: up
9romise Jul 5, 2025
50e1e69
ci: fix
9romise Jul 5, 2025
8acc52a
chore: use vite^6 for node18 test
9romise Jul 5, 2025
52150d8
chore: update timeout config
9romise Jul 5, 2025
2131857
chore: update
9romise Jul 5, 2025
1114790
chore: flat diff
9romise Jul 5, 2025
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
6 changes: 2 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ jobs:
run: npm install -f
- name: Install ESLint v${{ matrix.eslint }}
run: node scripts/ci-install-eslint ${{ matrix.eslint }}
- name: Build
run: npm run -s build
- name: Test
run: npm run -s test:mocha
run: npm run -s test
test-for-old-eslint:
name: Test
strategy:
Expand All @@ -82,4 +80,4 @@ jobs:
- name: Install ESLint v${{ matrix.eslint }}
run: node scripts/ci-install-eslint ${{ matrix.eslint }}
- name: Test
run: npm run -s test:debug
run: npm run -s test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/.nyc_output
/.temp
/coverage
node_modules
Expand Down
3 changes: 1 addition & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const compat = new FlatCompat({
export default [
{
ignores: [
".nyc_output",
".temp",
"coverage",
"**/node_modules",
Expand Down Expand Up @@ -64,7 +63,7 @@ export default [
},

loggerFn: false,
project: "tsconfig.json",
project: ["tsconfig.json", "tsconfig.test.json"],
},
},

Expand Down
23 changes: 9 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
"@eslint/js": "^9.19.0",
"@types/debug": "^4.1.7",
"@types/estree": "^1.0.0",
"@types/mocha": "^9.0.0",
"@types/node": "^18.8.4",
"@types/semver": "^7.3.12",
"@typescript-eslint/eslint-plugin": "^8.22.0",
"@typescript-eslint/parser": "^8.22.0",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/ui": "^3.2.4",
"chokidar": "^3.5.2",
"cross-spawn": "^7.0.3",
"dts-bundle": "^0.7.3",
Expand All @@ -47,10 +48,7 @@
"eslint-plugin-unicorn": "^57.0.0",
"fs-extra": "^10.0.0",
"jsonc-eslint-parser": "^2.0.3",
"mocha": "^9.1.3",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"opener": "^1.5.2",
"prettier": "^3.4.2",
"rimraf": "^3.0.2",
"rollup": "^2.60.0",
Expand All @@ -59,20 +57,19 @@
"rollup-plugin-sourcemaps": "^0.6.3",
"ts-node": "^10.9.2",
"typescript": "~5.7.3",
"vite": "^6.3.5",
"vitest": "^3.2.4",
"wait-on": "^6.0.0",
"warun": "^1.0.0"
},
"scripts": {
"prebuild": "npm run -s clean",
"build": "tsc --module es2015 && rollup -c -o index.js && dts-bundle --name vue-eslint-parser --main .temp/index.d.ts --out ../index.d.ts",
"clean": "rimraf .nyc_output .temp coverage index.*",
"coverage": "opener ./coverage/lcov-report/index.html",
"clean": "rimraf .temp index.*",
"coverage": "vitest --coverage --ui",
"lint": "eslint src test package.json",
"pretest": "run-s build lint",
"test": "npm run -s test:mocha",
"test:mocha": "mocha --require ts-node/register \"test/*.js\" --reporter dot --timeout 60000",
"test:cover": "nyc mocha \"test/*.js\" --reporter dot --timeout 60000",
"test:debug": "mocha --require ts-node/register/transpile-only \"test/*.js\" --reporter dot --timeout 60000",
"test": "vitest",
"test:cover": "vitest --coverage",
"update-fixtures": "ts-node --transpile-only scripts/update-fixtures-ast.js && ts-node --transpile-only scripts/update-fixtures-document-fragment.js",
"preversion": "npm test",
"version": "npm run -s build",
Expand All @@ -81,9 +78,7 @@
"watch": "run-p watch:*",
"watch:tsc": "tsc --module es2015 --watch",
"watch:rollup": "wait-on .temp/index.js && rollup -c -o index.js --watch",
"watch:test": "wait-on index.js && warun index.js \"test/*.js\" \"test/fixtures/ast/*/*.json\" \"test/fixtures/*\" --debounce 1000 --no-initial -- nyc mocha \"test/*.js\" --reporter dot --timeout 10000",
"watch:update-ast": "wait-on index.js && warun index.js \"test/fixtures/ast/*/*.vue\" -- ts-node scripts/update-fixtures-ast.js",
"watch:coverage-report": "wait-on coverage/lcov-report/index.html && opener coverage/lcov-report/index.html"
"watch:update-ast": "wait-on index.js && warun index.js \"test/fixtures/ast/*/*.vue\" -- ts-node scripts/update-fixtures-ast.js"
},
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions scripts/ci-install-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ function sh(command) {

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

// Install ESLint submodule of the requested version
// const installedVersion = require("eslint/package.json").version
Expand Down
3 changes: 2 additions & 1 deletion src/ast/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { ParseError } from "./errors"
import type { HasLocation } from "./locations"
import type { Token } from "./tokens"
import type { TSESTree } from "@typescript-eslint/utils"
import type { ParserServices } from "../parser-services"

//------------------------------------------------------------------------------
// Common
Expand Down Expand Up @@ -70,7 +71,7 @@ export type ESLintNode =
*/
export interface ESLintExtendedProgram {
ast: ESLintProgram
services?: {}
services?: ParserServices
visitorKeys?: { [type: string]: string[] }
scopeManager?: ScopeManager
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function parseForESLint(
* @param options The parser options.
* @returns The parsing result.
*/
export function parse(code: string, options: any): AST.ESLintProgram {
export function parse(code: string, options?: any): AST.ESLintProgram {
return parseForESLint(code, options).ast
}

Expand Down
4 changes: 2 additions & 2 deletions src/parser-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export interface ParserServices {
| ((lang: string | null, customBlock: VElement) => boolean)
create: CustomBlockVisitorFactory
},
scriptVisitor: { [key: string]: (...args: any) => void },
scriptVisitor?: { [key: string]: (...args: any) => void },
): { [key: string]: (...args: any) => void }

/**
Expand Down Expand Up @@ -262,7 +262,7 @@ export function define(
| ((lang: string | null, customBlock: VElement) => boolean)
create: CustomBlockVisitorFactory
},
scriptVisitor: { [key: string]: (...args: any) => void },
scriptVisitor?: { [key: string]: (...args: any) => void },
): { [key: string]: (...args: any) => void } {
if (scriptVisitor == null) {
scriptVisitor = {} //eslint-disable-line no-param-reassign
Expand Down
Loading