Skip to content

Commit

Permalink
chore: migrate to ESM and Vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Aug 26, 2022
1 parent 24d22b7 commit 810c173
Show file tree
Hide file tree
Showing 212 changed files with 3,416 additions and 4,288 deletions.
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module.exports = {
root: true,
extends: ['alloy', 'alloy/typescript'],
env: {
jest: true,
},
globals: {
page: 'readonly',
globalThis: 'readonly',
Expand All @@ -19,6 +16,7 @@ module.exports = {
},
],
rules: {
'max-nested-callbacks': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/no-require-imports': 'off',
},
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,11 @@ jobs:
- name: Type check
run: pnpm run type-check

- name: Test
run: pnpm --silent run test
- name: Test unit
run: pnpm run test-unit

- name: Test serve
run: pnpm run test-serve

- name: Test build
run: pnpm run test-build
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ dist

#
lib/
temp/
playground-temp/
packages/runtime/public/build/bundle.js
29 changes: 0 additions & 29 deletions jest.config.js

This file was deleted.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
"preinstall": "npx only-allow pnpm",
"dev": "pnpm -r --filter=./packages/** --parallel run dev",
"build": "pnpm -r --filter=./packages/** run build",
"clean": "pnpm -r --filter=./packages/** run clean",
"build:test": "pnpm -r --filter=./packages/** run build:test",
"clean": "pnpm -r --filter=./packages/** run clean",
"format": "prettier --check \"packages/*/src/**/*.{ts,js,svelte}\"",
"lint": "eslint \"packages/*/src/**/*.{ts,js,svelte}\"",
"test": "jest --clearCache && cross-env jest --runInBand",
"test-win": "jest --clearCache && cross-env jest --runInBand --testPathIgnorePatterns=multiple-hmr",
"test:coverage": "jest --clearCache && jest --runInBand --coverage=true",
"test": "run-s test-unit test-serve test-build",
"test-unit": "vitest run",
"test-serve": "vitest run -c vitest.config.e2e.ts",
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
"test-unit:watch": "vitest",
"changelog": "pnpm -r --filter=./packages/** run changelog",
"test:watch": "jest -w",
"type-check": "pnpm -r --parallel --filter \"vite-plugin-checker\" exec tsc --noEmit",
"ci:publish": "zx scripts/publish.mjs",
"docs:dev": "pnpm --filter docs exec vitepress dev .",
Expand All @@ -42,7 +43,6 @@
"@types/babel__code-frame": "^7.0.2",
"@types/debug": "^4.1.5",
"@types/fs-extra": "^9.0.11",
"@types/jest": "^27.4.0",
"@types/klaw": "^3.0.3",
"@types/node": "^14.14.31",
"@types/prompts": "^2.0.13",
Expand All @@ -61,14 +61,13 @@
"fast-json-stable-stringify": "^2.1.0",
"fs-extra": "^10.0.0",
"husky": "4.3.7",
"jest": "^27.4.7",
"jest-environment-node": "^27.4.6",
"jest-serializer-path": "^0.1.15",
"klaw": "^4.0.1",
"lint-staged": "^11.0.0",
"minimist": "^1.2.5",
"nodemon": "^2.0.15",
"playwright-chromium": "^1.19.2",
"npm-run-all": "^4.1.5",
"playwright-chromium": "^1.24.0",
"prettier": "^2.3.2",
"prettier-plugin-svelte": "^2.6.0",
"prompts": "^2.4.1",
Expand All @@ -77,10 +76,11 @@
"sort-deep-object-arrays": "^1.1.2",
"strip-ansi": "^7.0.0",
"svelte": "^3.46.4",
"ts-jest": "^27.1.3",
"tiny-invariant": "^1.1.0",
"typescript": "~4.5.5",
"vite": "^2.7.13",
"vite": "^3.0.7",
"vite-plugin-checker": "workspace:*",
"vitest": "^0.21.1",
"ws": "^8.5.0",
"zx": "^1.14.2"
}
Expand Down
Binary file added packages/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1

exports[`logger diagnosticToTerminalLog get error 1`] = `
exports[`logger > diagnosticToTerminalLog > get error 1`] = `
" ERROR(ESLint) Unexpected var, use let or const instead.
FILE /Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1

Expand All @@ -14,7 +14,7 @@ exports[`logger diagnosticToTerminalLog get error 1`] = `
"
`;

exports[`logger diagnosticToTerminalLog get warning 1`] = `
exports[`logger > diagnosticToTerminalLog > get warning 1`] = `
" WARNING(ESLint) Unexpected var, use let or const instead.
FILE /Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1

Expand All @@ -28,9 +28,9 @@ exports[`logger diagnosticToTerminalLog get warning 1`] = `
"
`;

exports[`logger normalizeEslintDiagnostic get multiple diagnostics 1`] = `
Array [
Object {
exports[`logger > normalizeEslintDiagnostic > get multiple diagnostics 1`] = `
[
{
"checker": "ESLint",
"codeFrame": "   1 | import { text } from './text'
  2 |
Expand All @@ -42,12 +42,12 @@ Array [
"conclusion": "",
"id": "/Users/vite-plugin-checker/playground/eslint/src/main.ts",
"level": 1,
"loc": Object {
"end": Object {
"loc": {
"end": {
"column": 20,
"line": 3,
},
"start": Object {
"start": {
"column": 1,
"line": 3,
},
Expand All @@ -61,7 +61,7 @@ Array [
5 |
6 | const rootDom = document.querySelector('#root')!",
},
Object {
{
"checker": "ESLint",
"codeFrame": "   2 |
  3 | var hello = 'Hello'
Expand All @@ -73,12 +73,12 @@ Array [
"conclusion": "",
"id": "/Users/vite-plugin-checker/playground/eslint/src/main.ts",
"level": 1,
"loc": Object {
"end": Object {
"loc": {
"end": {
"column": 22,
"line": 4,
},
"start": Object {
"start": {
"column": 1,
"line": 4,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1

exports[`VLS config customized config 1`] = `
Object {
"css": Object {},
"emmet": Object {},
"html": Object {
"suggest": Object {},
exports[`VLS config > customized config 1`] = `
{
"css": {},
"emmet": {},
"html": {
"suggest": {},
},
"javascript": Object {
"format": Object {},
"javascript": {
"format": {},
},
"languageStylus": Object {},
"stylusSupremacy": Object {},
"typescript": Object {
"format": Object {},
"languageStylus": {},
"stylusSupremacy": {},
"typescript": {
"format": {},
"tsdk": null,
},
"vetur": Object {
"completion": Object {
"vetur": {
"completion": {
"autoImport": false,
"scaffoldSnippetSources": Object {
"scaffoldSnippetSources": {
"user": "🗒️",
"vetur": "",
"workspace": "💼",
},
"tagCasing": "initial",
},
"dev": Object {
"dev": {
"logLevel": "INFO",
"vlsPath": "",
"vlsPort": -1,
},
"experimental": Object {
"experimental": {
"templateInterpolationService": true,
},
"format": Object {
"defaultFormatter": Object {},
"defaultFormatterOptions": Object {},
"format": {
"defaultFormatter": {},
"defaultFormatterOptions": {},
"enable": true,
"options": Object {
"options": {
"tabSize": 2,
"useTabs": false,
},
"scriptInitialIndent": false,
"styleInitialIndent": false,
},
"grammar": Object {
"customBlocks": Object {},
"grammar": {
"customBlocks": {},
},
"ignoreProjectWarning": false,
"languageFeatures": Object {
"languageFeatures": {
"codeActions": true,
"semanticTokens": true,
"updateImportOnFileMove": true,
},
"trace": Object {
"trace": {
"server": "off",
},
"useWorkspaceDependencies": false,
"validation": Object {
"validation": {
"interpolation": false,
"script": true,
"style": false,
Expand All @@ -69,65 +69,65 @@ Object {
}
`;

exports[`VLS config default config 1`] = `
Object {
"css": Object {},
"emmet": Object {},
"html": Object {
"suggest": Object {},
exports[`VLS config > default config 1`] = `
{
"css": {},
"emmet": {},
"html": {
"suggest": {},
},
"javascript": Object {
"format": Object {},
"javascript": {
"format": {},
},
"languageStylus": Object {},
"stylusSupremacy": Object {},
"typescript": Object {
"format": Object {},
"languageStylus": {},
"stylusSupremacy": {},
"typescript": {
"format": {},
"tsdk": null,
},
"vetur": Object {
"completion": Object {
"vetur": {
"completion": {
"autoImport": false,
"scaffoldSnippetSources": Object {
"scaffoldSnippetSources": {
"user": "🗒️",
"vetur": "",
"workspace": "💼",
},
"tagCasing": "initial",
},
"dev": Object {
"dev": {
"logLevel": "INFO",
"vlsPath": "",
"vlsPort": -1,
},
"experimental": Object {
"experimental": {
"templateInterpolationService": true,
},
"format": Object {
"defaultFormatter": Object {},
"defaultFormatterOptions": Object {},
"format": {
"defaultFormatter": {},
"defaultFormatterOptions": {},
"enable": true,
"options": Object {
"options": {
"tabSize": 2,
"useTabs": false,
},
"scriptInitialIndent": false,
"styleInitialIndent": false,
},
"grammar": Object {
"customBlocks": Object {},
"grammar": {
"customBlocks": {},
},
"ignoreProjectWarning": false,
"languageFeatures": Object {
"languageFeatures": {
"codeActions": true,
"semanticTokens": true,
"updateImportOnFileMove": true,
},
"trace": Object {
"trace": {
"server": "off",
},
"useWorkspaceDependencies": false,
"validation": Object {
"validation": {
"interpolation": true,
"script": true,
"style": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { tsLocationToBabelLocation } from '../../src/codeFrame'
import { describe, expect, it } from 'vitest'

import { SourceLocation } from '@babel/code-frame'

import { tsLocationToBabelLocation } from '../src/codeFrame'

describe('code frame', () => {
it('should add 1 offset to TS location', () => {
const babelLoc = tsLocationToBabelLocation({
Expand Down

0 comments on commit 810c173

Please sign in to comment.