Skip to content

Commit 8eadbb6

Browse files
ci: rework compiling tests
1 parent 1e07a9f commit 8eadbb6

File tree

11 files changed

+57
-59
lines changed

11 files changed

+57
-59
lines changed

.eslintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
"parserOptions": {
1515
"project": ["./tsconfig.json"]
1616
},
17-
"ignorePatterns": ["/build/", "/coverage/", "/lib/", "/cz-adapter/**/*.js"],
17+
"ignorePatterns": [
18+
"/build/",
19+
"/coverage/",
20+
"/lib/",
21+
"/tests-compiled/",
22+
"/cz-adapter/**/*.js"
23+
],
1824
"rules": {
1925
"functional/prefer-immutable-types": "off",
2026
"@typescript-eslint/no-explicit-any": "warn",

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/lib/
22
/build/
33
/coverage/
4+
/tests-compiled/
45

56
.nyc_output/
67

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/lib/
33
/build/
44
/coverage/
5+
/tests-compiled/
56

67
.nyc_output/
78

ava.config.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ function getBoolean(value) {
1111
: Boolean(asNumber);
1212
}
1313

14-
const testAllFiles = getBoolean(process.env["TEST_ALL_FILES"]);
1514
const useCompiledTests = getBoolean(process.env["USE_COMPILED_TESTS"]);
1615
const onlyTestWorkFile = getBoolean(process.env["ONLY_TEST_WORK_FILE"]);
1716

1817
const avaCommonConfig = {
19-
files: testAllFiles
20-
? ["tests/rules/*.test.*"]
21-
: onlyTestWorkFile
18+
files: onlyTestWorkFile
2219
? ["tests/rules/work.test.*"]
2320
: ["tests/**/!(work)*.test.*"],
2421
timeout: "5m",
@@ -33,6 +30,7 @@ const avaTsConfig = {
3330

3431
const avaJsConfig = {
3532
...avaCommonConfig,
33+
files: avaCommonConfig.files.map((file) => `tests-compiled/${file}`),
3634
};
3735

3836
export default useCompiledTests ? avaJsConfig : avaTsConfig;

knip.jsonc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"entry": ["src/index.ts!", "tests/**/*.test.ts", "cz-adapter/index.ts"],
44
"project": ["src/**/*.ts!", "tests/**/*.ts", "cz-adapter/**/*.ts"],
55
"ignoreDependencies": [
6-
"@typescript-eslint/eslint-plugin-disable-type-checked"
6+
"@typescript-eslint/eslint-plugin-disable-type-checked",
7+
"glob"
78
],
89
"ignore": ["tests/fixture/file.ts"]
910
}

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
],
4747
"scripts": {
4848
"build": "pnpm run build:node && pnpm run build:docs",
49-
"build-tests": "rimraf build && node --no-warnings=ExperimentalWarning --loader=ts-paths-esm-loader/transpile-only --experimental-specifier-resolution=node scripts/compile-tests.mts",
49+
"build-tests": "rimraf tests-compiled && rollup -c rollup.config.tests.ts --configPlugin @rollup/plugin-typescript",
5050
"build:docs": "eslint-doc-generator",
5151
"build:node": "rimraf lib && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript",
5252
"cz": "git-cz",
@@ -128,6 +128,7 @@
128128
"eslint-plugin-sonarjs": "0.19.0",
129129
"eslint-plugin-unicorn": "48.0.0",
130130
"espree": "9.6.1",
131+
"glob": "^10.3.3",
131132
"husky": "8.0.3",
132133
"knip": "2.15.5",
133134
"lint-staged": "13.2.3",
@@ -140,8 +141,6 @@
140141
"rollup-plugin-auto-external": "2.0.0",
141142
"semantic-release": "21.0.7",
142143
"ts-node": "10.9.1",
143-
"ts-paths-esm-loader": "^1.4.3",
144-
"tsc-prog": "2.2.1",
145144
"tsconfig-paths": "4.2.0",
146145
"tslib": "2.6.0",
147146
"typescript": "5.1.6",

pnpm-lock.yaml

Lines changed: 3 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rollup.config.tests.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import rollupPluginCommonjs from "@rollup/plugin-commonjs";
2+
import rollupPluginJSON from "@rollup/plugin-json";
3+
import rollupPluginTypescript from "@rollup/plugin-typescript";
4+
import { glob } from "glob";
5+
import { defineConfig } from "rollup";
6+
import rollupPluginAutoExternal from "rollup-plugin-auto-external";
7+
8+
const testFiles = await glob("./tests/**/*.test.ts");
9+
10+
export default defineConfig({
11+
input: Object.fromEntries(testFiles.map((file) => [file, file])),
12+
13+
output: [
14+
{
15+
sourcemap: false,
16+
dir: "tests-compiled",
17+
format: "cjs",
18+
},
19+
],
20+
21+
plugins: [
22+
rollupPluginAutoExternal(),
23+
rollupPluginCommonjs(),
24+
rollupPluginTypescript(),
25+
rollupPluginJSON({
26+
preferConst: true,
27+
}),
28+
],
29+
30+
external: [],
31+
32+
treeshake: {
33+
annotations: true,
34+
moduleSideEffects: [],
35+
propertyReadSideEffects: false,
36+
unknownGlobalSideEffects: false,
37+
},
38+
});

scripts/.eslintrc.json

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

scripts/compile-tests.mts

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

tests/helpers/configs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from "node:path";
22

33
import { type RuleTesterConfig } from "@typescript-eslint/rule-tester";
44

5-
const fixturePath = path.join(__dirname, "../fixture");
5+
const fixturePath = path.join(process.cwd(), "tests/fixture");
66
export const filename = path.join(fixturePath, "file.ts");
77

88
const typescriptParser = require.resolve("@typescript-eslint/parser");

0 commit comments

Comments
 (0)