Skip to content

Commit

Permalink
Add basic type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Nov 20, 2024
1 parent e603aa5 commit 8683642
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ jobs:
- name: 📥 Install dependencies
run: npm install --legacy-peer-deps

- name: ▶️ Run check-exports script
run: npm run check-exports -- --format=table

- name: ▶️ Run test:types script
run: npm run test:types -- --format=table
run: npm run test:types

release:
name: 🚀 Release
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"cross-spawn": "^7.0.3",
"esbuild": "^0.19.3",
"eslint": "^8.46.0",
"expect-type": "^1.1.0",
"fs-extra": "^10.1.0",
"mocha": "^10.4.0",
"monaco-editor": "^0.47.0",
Expand All @@ -68,7 +69,8 @@
"docs:watch": "vitepress dev docs",
"lint": "eslint lib scripts tests",
"test": "nyc mocha \"tests/lib/**/*.js\" --reporter dot --timeout 8000",
"test:types": "attw --pack",
"test:types": "tsc -p tsconfig.json",
"check-exports": "attw --pack",
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
"watch": "npm run -s test -- --watch --growl"
},
Expand Down
18 changes: 18 additions & 0 deletions tests/types/configs.test-d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import configs = require("@eslint-community/eslint-plugin-eslint-comments/configs")
import expectTypeModule = require("expect-type")

import type { Linter } from "eslint"

import expectTypeOf = expectTypeModule.expectTypeOf

expectTypeOf(configs)
.toHaveProperty("recommended")
.toMatchTypeOf<Linter.FlatConfig>()

expectTypeOf([configs.recommended]).toMatchTypeOf<Linter.FlatConfig[]>()

expectTypeOf(configs.recommended).toMatchTypeOf<Linter.FlatConfig>()

expectTypeOf(configs)
.toHaveProperty("recommended")
.toMatchTypeOf<Linter.FlatConfig>()
15 changes: 15 additions & 0 deletions tests/types/configs.test-d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import configs from "@eslint-community/eslint-plugin-eslint-comments/configs"
import type { Linter } from "eslint"
import { expectTypeOf } from "expect-type"

expectTypeOf(configs)
.toHaveProperty("recommended")
.toMatchTypeOf<Linter.FlatConfig>()

expectTypeOf([configs.recommended]).toMatchTypeOf<Linter.FlatConfig[]>()

expectTypeOf(configs.recommended).toMatchTypeOf<Linter.FlatConfig>()

expectTypeOf(configs)
.toHaveProperty("recommended")
.toMatchTypeOf<Linter.FlatConfig>()
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
"compilerOptions": {
"allowSyntheticDefaultImports": false,
"esModuleInterop": false,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"lib": ["ESNext"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": false,
"skipLibCheck": true,
"strict": true,
"target": "ESNext",
"useDefineForClassFields": true,
Expand Down

0 comments on commit 8683642

Please sign in to comment.