Skip to content

Commit 32e7bfc

Browse files
committed
Add type definitions
1 parent d6869df commit 32e7bfc

File tree

7 files changed

+96
-14
lines changed

7 files changed

+96
-14
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
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: 18
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

Lines changed: 9 additions & 7 deletions
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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
/** DON'T EDIT THIS FILE WHICH WAS CREATED BY 'scripts/generate-index.js'. */
21
"use strict"
32

3+
const rules = require("./lib/rules")
4+
const utils = require("./lib/utils")
5+
const configs = require("./lib/configs")
6+
47
module.exports = {
5-
configs: require("./lib/configs"),
6-
rules: require("./lib/rules"),
7-
utils: require("./lib/utils"),
8+
configs,
9+
rules,
10+
utils,
811
}

package.json

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,30 @@
66
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
77
},
88
"main": "index.js",
9+
"types": "./types/index.d.ts",
910
"type": "commonjs",
1011
"files": [
1112
"configs.js",
12-
"lib"
13+
"lib",
14+
"types"
1315
],
1416
"exports": {
15-
"./configs": "./configs.js",
16-
".": "./index.js"
17+
"./package.json": "./package.json",
18+
"./configs": {
19+
"types": "./types/configs.d.ts",
20+
"default": "./configs.js"
21+
},
22+
".": {
23+
"types": "./types/index.d.ts",
24+
"default": "./index.js"
25+
}
26+
},
27+
"typesVersions": {
28+
"*": {
29+
"configs": [
30+
"./types/configs.d.ts"
31+
]
32+
}
1733
},
1834
"peerDependencies": {
1935
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
@@ -23,11 +39,13 @@
2339
"ignore": "^5.2.4"
2440
},
2541
"devDependencies": {
42+
"@arethetypeswrong/cli": "^0.17.4",
2643
"@babel/core": "^7.22.9",
2744
"@babel/eslint-parser": "^7.22.9",
2845
"@eslint-community/eslint-plugin-mysticatea": "^15.5.1",
2946
"@eslint/core": "^0.13.0",
3047
"@eslint/css": "^0.6.0",
48+
"@types/eslint": "^8",
3149
"@types/node": "^14.18.54",
3250
"@vuepress/plugin-pwa": "^1.9.9",
3351
"cross-spawn": "^7.0.3",
@@ -40,6 +58,7 @@
4058
"opener": "^1.5.2",
4159
"rimraf": "^3.0.2",
4260
"semver": "^7.5.4",
61+
"typescript": "^5.8.3",
4362
"vite-plugin-eslint4b": "^0.2.1",
4463
"vitepress": "^1.0.0-rc.15"
4564
},
@@ -53,6 +72,7 @@
5372
"lint": "eslint lib scripts tests",
5473
"test": "nyc npm run debug",
5574
"debug": "mocha \"tests/lib/**/*.js\" --reporter dot --timeout 8000",
75+
"test:types": "attw --pack",
5676
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
5777
"watch": "npm run -s test -- --watch --growl"
5878
},

tsconfig.json

Lines changed: 21 additions & 0 deletions
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"],
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

Lines changed: 11 additions & 0 deletions
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.FlatConfig
7+
8+
export { defaultExports as default }
9+
}
10+
11+
export = Configs

types/index.d.ts

Lines changed: 7 additions & 0 deletions
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.FlatConfig }
4+
5+
export declare const rules: NonNullable<ESLint.Plugin["rules"]>
6+
7+
export declare const utils: { patch: (ruleId?: string) => void }

0 commit comments

Comments
 (0)