Skip to content

Commit d8f9980

Browse files
committed
Add type definitions
1 parent 60c28f9 commit d8f9980

File tree

7 files changed

+98
-15
lines changed

7 files changed

+98
-15
lines changed

.github/workflows/ci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ jobs:
9797
- name: ⬆️ Upload coverage report
9898
uses: codecov/codecov-action@v4
9999

100+
are-the-types-wrong:
101+
name: 🤔 Are the types wrong?
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: ⬇️ Checkout repo
105+
uses: actions/checkout@v4
106+
107+
- name: ⎔ Setup Node
108+
uses: actions/setup-node@v4
109+
with:
110+
node-version: 20
111+
112+
- name: 📥 Install dependencies
113+
run: npm install --legacy-peer-deps
114+
115+
- name: ▶️ Run test:types script
116+
run: npm run test:types -- --format=table
117+
100118
release:
101119
name: 🚀 Release
102120
needs: [ lint, test ]

configs.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ const plugin = {
99
rules,
1010
}
1111

12+
const recommended = {
13+
name: "@eslint-community/eslint-comments/recommended",
14+
plugins: {
15+
"@eslint-community/eslint-comments": plugin,
16+
},
17+
rules: rulesRecommended,
18+
}
19+
1220
module.exports = {
13-
recommended: {
14-
name: '@eslint-community/eslint-comments/recommended',
15-
plugins: {
16-
"@eslint-community/eslint-comments": plugin,
17-
},
18-
rules: rulesRecommended,
19-
},
21+
recommended,
2022
}
2123

2224
module.exports.default = module.exports

index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
/** DON'T EDIT THIS FILE WHICH WAS CREATED BY 'scripts/generate-index.js'. */
22
"use strict"
33

4+
const rules = require("./lib/rules")
5+
const utils = require("./lib/utils")
6+
const configs = require("./lib/configs")
7+
48
module.exports = {
5-
configs: require("./lib/configs"),
6-
rules: require("./lib/rules"),
7-
utils: require("./lib/utils"),
9+
configs,
10+
rules,
11+
utils,
812
}

package.json

+25-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,29 @@
66
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
77
},
88
"main": "index.js",
9+
"types": "./types/index.d.ts",
910
"files": [
1011
"configs.js",
11-
"lib"
12+
"lib",
13+
"types"
1214
],
13-
"exports": {
14-
"./configs": "./configs.js",
15-
".": "./index.js"
15+
"exports": {
16+
"./package.json": "./package.json",
17+
"./configs": {
18+
"types": "./types/configs.d.ts",
19+
"default": "./configs.js"
20+
},
21+
".": {
22+
"types": "./types/index.d.ts",
23+
"default": "./index.js"
24+
}
25+
},
26+
"typesVersions": {
27+
"*": {
28+
"configs": [
29+
"./types/configs.d.ts"
30+
]
31+
}
1632
},
1733
"peerDependencies": {
1834
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
@@ -22,10 +38,12 @@
2238
"ignore": "^5.2.4"
2339
},
2440
"devDependencies": {
41+
"@arethetypeswrong/cli": "^0.16.4",
2542
"@babel/core": "^7.22.9",
2643
"@babel/eslint-parser": "^7.22.9",
2744
"@eslint-community/eslint-plugin-mysticatea": "^15.5.1",
28-
"@types/node": "^14.18.54",
45+
"@types/eslint": "^9.6.1",
46+
"@types/node": "^22.8.1",
2947
"@vuepress/plugin-pwa": "^1.9.9",
3048
"cross-spawn": "^7.0.3",
3149
"esbuild": "^0.19.3",
@@ -37,6 +55,7 @@
3755
"opener": "^1.5.2",
3856
"rimraf": "^3.0.2",
3957
"semver": "^7.5.4",
58+
"typescript": "^5.6.3",
4059
"vite-plugin-eslint4b": "^0.2.1",
4160
"vitepress": "^1.0.0-rc.15"
4261
},
@@ -49,6 +68,7 @@
4968
"docs:watch": "vitepress dev docs",
5069
"lint": "eslint lib scripts tests",
5170
"test": "nyc mocha \"tests/lib/**/*.js\" --reporter dot --timeout 8000",
71+
"test:types": "attw --pack",
5272
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
5373
"watch": "npm run -s test -- --watch --growl"
5474
},

tsconfig.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"allowSyntheticDefaultImports": false,
4+
"esModuleInterop": false,
5+
"exactOptionalPropertyTypes": true,
6+
"forceConsistentCasingInFileNames": true,
7+
"isolatedModules": true,
8+
"lib": ["ESNext", "DOM"],
9+
"module": "NodeNext",
10+
"moduleResolution": "NodeNext",
11+
"noEmit": true,
12+
"resolveJsonModule": true,
13+
"skipLibCheck": false,
14+
"strict": true,
15+
"target": "ESNext",
16+
"useDefineForClassFields": true,
17+
"useUnknownInCatchVariables": true,
18+
"verbatimModuleSyntax": true
19+
},
20+
"include": ["."]
21+
}

types/configs.d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Linter } from "eslint"
2+
3+
declare namespace Configs {
4+
import defaultExports = Configs
5+
6+
export const recommended: Linter.Config
7+
8+
export { defaultExports as default }
9+
}
10+
11+
export = Configs

types/index.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { ESLint, Linter } from "eslint"
2+
3+
export declare const configs: { recommended: Linter.Config }
4+
5+
export declare const rules: NonNullable<ESLint.Plugin["rules"]>
6+
7+
export declare const utils: (ruleId?: string) => void

0 commit comments

Comments
 (0)