Skip to content

Commit 27f34f8

Browse files
committed
Run type tests against different versions of ESLint and TS during CI
1 parent 2a65705 commit 27f34f8

File tree

5 files changed

+56
-15
lines changed

5 files changed

+56
-15
lines changed

Diff for: .github/workflows/ci.yml

+46-5
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ jobs:
4343
run: npm run lint
4444

4545
test:
46-
name:
47-
🧪 Test (Node@${{ matrix.node }} - ESLint@${{ matrix.eslint }} - ${{
46+
name: 🧪 Test (Node@${{ matrix.node }} - ESLint@${{ matrix.eslint }} - ${{
4847
matrix.os }})
4948
strategy:
5049
fail-fast: false
@@ -118,12 +117,54 @@ jobs:
118117
- name: ▶️ Run test:types script
119118
run: npm run test:types
120119

120+
type-tests:
121+
name: 🧪 Type tests with ESLint ${{ matrix.eslint }} and TypeScript ${{ matrix.ts }}
122+
runs-on: ubuntu-latest
123+
124+
strategy:
125+
fail-fast: false
126+
127+
matrix:
128+
eslint: [8, 9]
129+
ts: ["5.0", "5.1", "5.2", "5.3", "5.4", "5.5", "5.6"]
130+
131+
steps:
132+
- name: ⬇️ Checkout repo
133+
uses: actions/checkout@v4
134+
135+
- name: ⎔ Setup Node
136+
uses: actions/setup-node@v4
137+
with:
138+
node-version: 18
139+
140+
- name: 📥 Install dependencies
141+
run: npm install
142+
143+
- name: Pack the package
144+
id: pack
145+
run: npm install "$(npm pack | tail -n1)"
146+
147+
- name: 📥 Uninstall @types/eslint
148+
if: matrix.eslint != 8
149+
run: npm uninstall @types/eslint
150+
151+
- name: 📥 Install ESLint version ${{ matrix.eslint }}
152+
run: npm install --save-dev eslint@${{ matrix.eslint }}
153+
154+
- name: 📥 Install TypeScript version ${{ matrix.ts }}
155+
run: npm install --save-dev typescript@${{ matrix.ts }} -f
156+
157+
- name: ▶️ Run test:types script
158+
run: npm run test:types
159+
160+
- name: 📝 List version of ESLint
161+
run: npm why eslint @types/eslint
162+
121163
release:
122164
name: 🚀 Release
123-
needs: [ lint, test ]
165+
needs: [lint, test]
124166
runs-on: ubuntu-latest
125-
if:
126-
github.repository == 'eslint-community/eslint-plugin-eslint-comments' &&
167+
if: github.repository == 'eslint-community/eslint-plugin-eslint-comments' &&
127168
contains('refs/heads/main,refs/heads/next,refs/heads/beta,refs/heads/alpha',
128169
github.ref) && github.event_name == 'push'
129170
steps:

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"cross-spawn": "^7.0.3",
5050
"esbuild": "^0.19.3",
5151
"eslint": "^8.46.0",
52-
"expect-type": "^1.1.0",
52+
"expect-type": "^1.2.0",
5353
"fs-extra": "^10.1.0",
5454
"mocha": "^10.4.0",
5555
"monaco-editor": "^0.47.0",

Diff for: tests/types/configs.test-d.cts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import expectTypeOf = expectTypeModule.expectTypeOf
77

88
expectTypeOf(configs)
99
.toHaveProperty("recommended")
10-
.toMatchTypeOf<Linter.FlatConfig>()
10+
.toExtend<Linter.FlatConfig>()
1111

12-
expectTypeOf([configs.recommended]).toMatchTypeOf<Linter.FlatConfig[]>()
12+
expectTypeOf([configs.recommended]).toExtend<Linter.FlatConfig[]>()
1313

14-
expectTypeOf(configs.recommended).toMatchTypeOf<Linter.FlatConfig>()
14+
expectTypeOf(configs.recommended).toExtend<Linter.FlatConfig>()
1515

1616
expectTypeOf(configs)
1717
.toHaveProperty("recommended")
18-
.toMatchTypeOf<Linter.FlatConfig>()
18+
.toExtend<Linter.FlatConfig>()

Diff for: tests/types/configs.test-d.mts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { expectTypeOf } from "expect-type"
44

55
expectTypeOf(configs)
66
.toHaveProperty("recommended")
7-
.toMatchTypeOf<Linter.FlatConfig>()
7+
.toExtend<Linter.FlatConfig>()
88

9-
expectTypeOf([configs.recommended]).toMatchTypeOf<Linter.FlatConfig[]>()
9+
expectTypeOf([configs.recommended]).toExtend<Linter.FlatConfig[]>()
1010

11-
expectTypeOf(configs.recommended).toMatchTypeOf<Linter.FlatConfig>()
11+
expectTypeOf(configs.recommended).toExtend<Linter.FlatConfig>()
1212

1313
expectTypeOf(configs)
1414
.toHaveProperty("recommended")
15-
.toMatchTypeOf<Linter.FlatConfig>()
15+
.toExtend<Linter.FlatConfig>()

Diff for: types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ESLint, Linter } from "eslint"
22

3-
export declare const configs: { recommended: Linter.FlatConfig }
3+
export declare const configs: { recommended: Linter.LegacyConfig }
44

55
export declare const rules: NonNullable<ESLint.Plugin["rules"]>
66

0 commit comments

Comments
 (0)