diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a216666..ca080a26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,37 +13,12 @@ env: VSCODE_VERSION: '1.103.0' jobs: - lint: - runs-on: ubuntu-24.04-arm - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup-node-and-node-modules - with: - node-version: 22 - - uses: actions/cache@v4 - with: - path: | - node_modules/.cache/prettier/.prettier-cache - packages/*/dist - packages/*/tsconfig.build.tsbuildinfo - tsconfig.tsbuildinfo - key: lint-tools-${{ runner.arch }}-${{ runner.os }}-${{ github.sha }} - restore-keys: lint-tools-${{ runner.arch }}-${{ runner.os }} - - run: npm run lint - build: - runs-on: ubuntu-24.04-arm - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup-node-and-node-modules - with: - node-version: 22 - - run: npm run build test-vitest: strategy: fail-fast: false matrix: - node: [20, 22] - os: [ubuntu-24.04-arm, macos-latest, windows-11-arm] + node: [22] + os: [macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -59,33 +34,5 @@ jobs: tsconfig.tsbuildinfo key: test-vitest-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}-${{ github.sha }} restore-keys: test-vitest-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }} - - run: npm run test:vitest - test-vscode: - strategy: - fail-fast: false - matrix: - node: [20, 22] - os: [ubuntu-24.04-arm, macos-latest, windows-11-arm] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup-node-and-node-modules - with: - node-version: ${{ matrix.node }} - - uses: actions/cache@v4 - with: - path: | - packages/*/dist - packages/*/tsconfig.build.tsbuildinfo - tsconfig.tsbuildinfo - key: test-vscode-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}-${{ github.sha }} - restore-keys: test-vscode-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }} - - uses: actions/cache@v4 - with: - path: .vscode-test - key: vscode-test-${{ runner.arch }}-${{ runner.os }}-vscode-${{ env.VSCODE_VERSION }} - - - run: xvfb-run -a npm run test:vscode - if: runner.os == 'Linux' - - run: npm run test:vscode - if: runner.os != 'Linux' + - run: npm run build + - run: npm run test:vitest -- file-operation -t "updating file" diff --git a/.vscode/launch.json b/.vscode/launch.json index 23da7323..71f9393a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -88,7 +88,7 @@ "--profile-temp", "--skip-welcome", "--folder-uri=${workspaceFolder}/examples/1-basic", - "${workspaceFolder}/examples/1-basic/src/a.tsx" + "${workspaceFolder}/examples/1-basic/index.ts" ], "preLaunchTask": "npm: build - packages/vscode", "env": { diff --git a/examples/1-basic/a.module.css b/examples/1-basic/a.module.css new file mode 100644 index 00000000..3566ed4b --- /dev/null +++ b/examples/1-basic/a.module.css @@ -0,0 +1,4 @@ +.a_1 { +} +.a-2 { +} diff --git a/examples/1-basic/index.ts b/examples/1-basic/index.ts new file mode 100644 index 00000000..32d94e8f --- /dev/null +++ b/examples/1-basic/index.ts @@ -0,0 +1,2 @@ +import styles from './a.module.css'; +styles.a_1; diff --git a/examples/1-basic/src/a.module.css b/examples/1-basic/src/a.module.css deleted file mode 100644 index f530e445..00000000 --- a/examples/1-basic/src/a.module.css +++ /dev/null @@ -1,11 +0,0 @@ -.a_1 { color: red; } -.a_2 { color: red; } -.a_2 { color: red; } -@value a_3: red; -@keyframes a_4 { - 0% { transform: translateY(0); } - 100% { transform: translateY(-100%); } -} - -@import './b.module.css'; -@value c_1, c_2 as c_alias from './c.module.css'; diff --git a/examples/1-basic/src/a.tsx b/examples/1-basic/src/a.tsx deleted file mode 100644 index 8f9f4d56..00000000 --- a/examples/1-basic/src/a.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import styles from './a.module.css'; - -styles.a_1; -styles.a_2; -styles.a_3; -styles.a_4; -styles.b_1; -styles.b_2; -styles.c_1; -styles.c_alias; -styles.unknown; // Expected TS2339 error - -const jsx = ( -
- // ^ Try completing className prop. It should insert `className={}`. -) diff --git a/examples/1-basic/src/b.module.css b/examples/1-basic/src/b.module.css deleted file mode 100644 index 7b2d30e3..00000000 --- a/examples/1-basic/src/b.module.css +++ /dev/null @@ -1,2 +0,0 @@ -.b_1 { color: red; composes: b_2; } -@value b_2: red; diff --git a/examples/1-basic/src/c.module.css b/examples/1-basic/src/c.module.css deleted file mode 100644 index 8db0ee3b..00000000 --- a/examples/1-basic/src/c.module.css +++ /dev/null @@ -1,2 +0,0 @@ -@value c_1: red; -@value c_2: red; diff --git a/examples/1-basic/tsconfig.json b/examples/1-basic/tsconfig.json index a17e0773..f51f46d3 100644 --- a/examples/1-basic/tsconfig.json +++ b/examples/1-basic/tsconfig.json @@ -1,18 +1,4 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "target": "ES5", // Simplify tsserver.log - "lib": ["ES5"], // Simplify tsserver.log - "module": "Preserve", - "moduleResolution": "bundler", - "jsx": "react-jsx", - - "noEmit": true, - "incremental": false, - "rootDirs": [".", "generated"], - "types": [] // Simplify tsserver.log - }, - "cmkOptions": { - "enabled": true - } + "compilerOptions": {}, + "cmkOptions": {} } diff --git a/package-lock.json b/package-lock.json index 67e5717d..b036109f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -876,7 +876,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=18" }, @@ -899,7 +898,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=18" } @@ -1485,7 +1483,6 @@ "resolved": "https://registry.npmjs.org/@eslint/css/-/css-0.10.0.tgz", "integrity": "sha512-pHoYRWS08oeU0qVez1pZCcbqHzoJnM5VMtrxH2nWDJ0ukq9DkwWV1BTY+PWK+eWBbndN9W0O9WjJTyAHsDoPOg==", "license": "Apache-2.0", - "peer": true, "dependencies": { "@eslint/core": "^0.14.0", "@eslint/css-tree": "^3.6.1", @@ -3061,7 +3058,6 @@ "integrity": "sha512-DRh5K+ka5eJic8CjH7td8QpYEV6Zo10gfRkjHCO3weqZHWDtAaSTFtl4+VMqOJ4N5jcuhZ9/l+yy8rVgw7BQeQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.10.0" } @@ -3153,7 +3149,6 @@ "integrity": "sha512-g3WpVQHngx0aLXn6kfIYCZxM6rRJlWzEkVpqEFLT3SgEDsp9cpCbxxgwnE504q4H+ruSDh/VGS6nqZIDynP+vg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.39.0", "@typescript-eslint/types": "8.39.0", @@ -3880,7 +3875,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5715,7 +5709,6 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.33.0.tgz", "integrity": "sha512-TS9bTNIryDzStCpJN93aC5VRSW3uTx9sClUn4B87pwiCaJh220otoI0X8mJKr+VcPtniMdN8GKjlwgWGUv5ZKA==", "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", @@ -9540,7 +9533,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -9587,7 +9579,6 @@ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", "license": "MIT", - "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -9645,7 +9636,6 @@ "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, "license": "MIT", - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -10988,7 +10978,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@csstools/css-parser-algorithms": "^3.0.5", "@csstools/css-tokenizer": "^3.0.4", @@ -11388,7 +11377,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -11481,7 +11469,6 @@ "integrity": "sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "~0.25.0", "get-tsconfig": "^4.7.5" @@ -11640,7 +11627,6 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz", "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -11823,7 +11809,6 @@ "integrity": "sha512-yJ+Mp7OyV+4S+afWo+QyoL9jFWD11QFH0i5i7JypnfTcA1rmgxCbiA8WwAICDEtZ1Z1hzrVhN8R8rGTqkTY8ZQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.6", @@ -11937,7 +11922,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, diff --git a/packages/ts-plugin/e2e-test/file-operation.test.ts b/packages/ts-plugin/e2e-test/file-operation.test.ts index f887855d..3fac9d53 100644 --- a/packages/ts-plugin/e2e-test/file-operation.test.ts +++ b/packages/ts-plugin/e2e-test/file-operation.test.ts @@ -74,7 +74,7 @@ test('adding file', async () => { `); }); -test('updating file', async () => { +test('updating file', { repeats: 100 - 1 }, async () => { const tsserver = launchTsserver(); const iff = await createIFF({ 'index.ts': dedent` @@ -115,15 +115,22 @@ test('updating file', async () => { `); // Update a.module.css to have a semantic error - await writeFile( - iff.paths['a.module.css'], - dedent` - .a_1 {} - .a-2 {} - `, - ); await tsserver.sendUpdateOpen({ - openFiles: [{ file: iff.paths['a.module.css'] }], + changedFiles: [ + { + fileName: iff.paths['a.module.css'], + textChanges: [ + { + start: { line: 1, offset: 1 }, + end: { line: 1, offset: 1 }, + newText: dedent` + .a_1 {} + .a-2 {} + `, + }, + ], + }, + ], }); // The diagnostics in a.module.css are updated diff --git a/scripts/test-vitest-updating-file.sh b/scripts/test-vitest-updating-file.sh new file mode 100755 index 00000000..1e20a240 --- /dev/null +++ b/scripts/test-vitest-updating-file.sh @@ -0,0 +1,13 @@ +#!/bin/bash +failed=0 +for i in $(seq 1 50); do + if npm run test:vitest -- file-operation.test.ts -t "updating file" > /dev/null 2>&1; then + echo "Attempt #$i: passed" + else + echo -e "\033[31mAttempt #$i: failed\033[0m" + failed=1 + fi +done +if [ "$failed" -eq 1 ]; then + exit 1 +fi diff --git a/vitest.config.ts b/vitest.config.ts index e83e54ab..b57f79c7 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -7,6 +7,7 @@ export default defineConfig({ // On GitHub Actions, the Windows runner is slow and tests may fail with the default timeout. // Therefore, we set the timeout to 10 seconds. testTimeout: 10_000, + isolate: false, projects: [ { extends: true, @@ -25,7 +26,7 @@ export default defineConfig({ test: { name: 'e2e', include: ['packages/*/e2e-test/**/*.test.ts'], - globalSetup: ['./scripts/vitest-e2e-test-setup.ts'], + // globalSetup: ['./scripts/vitest-e2e-test-setup.ts'], }, }, ],