Skip to content

Commit 47d2440

Browse files
committed
Add basic type tests
1 parent e603aa5 commit 47d2440

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ jobs:
112112
- name: 📥 Install dependencies
113113
run: npm install --legacy-peer-deps
114114

115+
- name: ▶️ Run check-exports script
116+
run: npm run check-exports -- --format=table
117+
115118
- name: ▶️ Run test:types script
116-
run: npm run test:types -- --format=table
119+
run: npm run test:types
117120

118121
release:
119122
name: 🚀 Release

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"cross-spawn": "^7.0.3",
4949
"esbuild": "^0.19.3",
5050
"eslint": "^8.46.0",
51+
"expect-type": "^1.1.0",
5152
"fs-extra": "^10.1.0",
5253
"mocha": "^10.4.0",
5354
"monaco-editor": "^0.47.0",
@@ -68,7 +69,8 @@
6869
"docs:watch": "vitepress dev docs",
6970
"lint": "eslint lib scripts tests",
7071
"test": "nyc mocha \"tests/lib/**/*.js\" --reporter dot --timeout 8000",
71-
"test:types": "attw --pack",
72+
"test:types": "tsc -p tsconfig.json",
73+
"check-exports": "attw --pack",
7274
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
7375
"watch": "npm run -s test -- --watch --growl"
7476
},

tests/types/configs.test-d.cts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import configs = require("@eslint-community/eslint-plugin-eslint-comments/configs")
2+
import expectTypeModule = require("expect-type")
3+
4+
import type { Linter } from "eslint"
5+
6+
import expectTypeOf = expectTypeModule.expectTypeOf
7+
8+
expectTypeOf(configs)
9+
.toHaveProperty("recommended")
10+
.toMatchTypeOf<Linter.FlatConfig>()
11+
12+
expectTypeOf([configs.recommended]).toMatchTypeOf<Linter.Config[]>()
13+
14+
expectTypeOf(configs.recommended).toMatchTypeOf<Linter.Config>()
15+
16+
expectTypeOf(configs)
17+
.toHaveProperty("recommended")
18+
.toMatchTypeOf<Linter.Config>()

tests/types/configs.test-d.mts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import configs from "@eslint-community/eslint-plugin-eslint-comments/configs"
2+
import type { Linter } from "eslint"
3+
import { expectTypeOf } from "expect-type"
4+
5+
expectTypeOf(configs)
6+
.toHaveProperty("recommended")
7+
.toMatchTypeOf<Linter.FlatConfig>()
8+
9+
expectTypeOf([configs.recommended]).toMatchTypeOf<Linter.Config[]>()
10+
11+
expectTypeOf(configs.recommended).toMatchTypeOf<Linter.Config>()
12+
13+
expectTypeOf(configs)
14+
.toHaveProperty("recommended")
15+
.toMatchTypeOf<Linter.Config>()

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
"compilerOptions": {
33
"allowSyntheticDefaultImports": false,
44
"esModuleInterop": false,
5-
"exactOptionalPropertyTypes": true,
65
"forceConsistentCasingInFileNames": true,
76
"isolatedModules": true,
87
"lib": ["ESNext"],
98
"module": "NodeNext",
109
"moduleResolution": "NodeNext",
1110
"noEmit": true,
1211
"resolveJsonModule": true,
13-
"skipLibCheck": false,
12+
"skipLibCheck": true,
1413
"strict": true,
1514
"target": "ESNext",
1615
"useDefineForClassFields": true,

0 commit comments

Comments
 (0)