Skip to content

Commit 917f46e

Browse files
committed
Add basic type tests
1 parent 32e7bfc commit 917f46e

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
@@ -51,6 +51,7 @@
5151
"cross-spawn": "^7.0.3",
5252
"esbuild": "^0.19.3",
5353
"eslint": "^8.46.0",
54+
"expect-type": "^1.2.1",
5455
"fs-extra": "^10.1.0",
5556
"mocha": "^10.4.0",
5657
"monaco-editor": "^0.47.0",
@@ -72,7 +73,8 @@
7273
"lint": "eslint lib scripts tests",
7374
"test": "nyc npm run debug",
7475
"debug": "mocha \"tests/lib/**/*.js\" --reporter dot --timeout 8000",
75-
"test:types": "attw --pack",
76+
"test:types": "tsc -p tsconfig.json",
77+
"check-exports": "attw --pack",
7678
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
7779
"watch": "npm run -s test -- --watch --growl"
7880
},

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+
.toExtend<Linter.FlatConfig>()
11+
12+
expectTypeOf([configs.recommended]).toExtend<Linter.FlatConfig[]>()
13+
14+
expectTypeOf(configs.recommended).toExtend<Linter.FlatConfig>()
15+
16+
expectTypeOf(configs)
17+
.toHaveProperty("recommended")
18+
.toExtend<Linter.FlatConfig>()

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+
.toExtend<Linter.FlatConfig>()
8+
9+
expectTypeOf([configs.recommended]).toExtend<Linter.FlatConfig[]>()
10+
11+
expectTypeOf(configs.recommended).toExtend<Linter.FlatConfig>()
12+
13+
expectTypeOf(configs)
14+
.toHaveProperty("recommended")
15+
.toExtend<Linter.FlatConfig>()

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)