Skip to content

Commit f35a9a5

Browse files
committed
chore: add base type compilation setup
1 parent 1e13293 commit f35a9a5

File tree

6 files changed

+124
-8
lines changed

6 files changed

+124
-8
lines changed

.github/workflows/ci.yml

+20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ jobs:
2828
- name: ▶️ Run lint script
2929
run: npm run lint
3030

31+
types:
32+
name: 🌋 Types
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: ⬇️ Checkout repo
36+
uses: actions/checkout@v4
37+
38+
- name: ⎔ Setup Node
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: lts/*
42+
43+
- name: 📥 Install dependencies
44+
run: npm ci
45+
46+
- name: ▶️ Typecheck
47+
uses: gozala/[email protected]
48+
with:
49+
error_fail_threshold: 160
50+
3151
test:
3252
name:
3353
🧪 Test (Node@${{ matrix.node }} - ESLint@${{ matrix.eslint }} - ${{

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ node_modules
22
.idea
33
coverage/
44
.eslintcache
5+
6+
# Generated types
7+
/rules/**/*.d.ts
8+
/rules/**/*.d.ts.map
9+
/index.d.ts
10+
/index.d.ts.map

declaration.tsconfig.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "./tsconfig",
4+
"exclude": ["__tests__/**/*"],
5+
"compilerOptions": {
6+
"declaration": true,
7+
"declarationMap": true,
8+
"noEmit": false,
9+
"emitDeclarationOnly": true
10+
}
11+
}

package-lock.json

+28-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@
2222
"Aadit M Shah <[email protected]> (https://aadit.codes/)"
2323
],
2424
"scripts": {
25+
"build:0": "run-s clean",
26+
"build:1-declaration": "tsc -p declaration.tsconfig.json",
27+
"build": "run-s build:*",
28+
"check": "run-s clean && run-p check:*",
29+
"clean:declarations-lib": "rm -rf $(find rules -type f -name '*.d.ts*')",
30+
"clean:declarations-top": "rm -rf $(find . -maxdepth 1 -type f -name '*.d.ts*')",
31+
"clean": "run-p clean:*",
2532
"format": "prettier --write . && eslint . --fix",
26-
"lint": "npm-run-all \"lint:*\"",
2733
"lint:eslint-docs": "npm run update:eslint-docs && git diff --exit-code",
2834
"lint:js": "eslint --report-unused-disable-directives .",
35+
"skip:lint:tsc": "tsc",
36+
"lint": "run-s clean && run-p lint:*",
2937
"prepare": "husky",
38+
"skip:prepublishOnly": "run-s build",
3039
"test": "jest --coverage",
3140
"update:eslint-docs": "eslint-doc-generator && npm run format"
3241
},
@@ -66,6 +75,8 @@
6675
]
6776
},
6877
"devDependencies": {
78+
"@types/eslint": "^9.6.0",
79+
"@types/node": "^18.19.42",
6980
"@typescript-eslint/parser": "^7.17.0",
7081
"doctoc": "^2.2.1",
7182
"eslint": "^8.56.0",
@@ -81,7 +92,7 @@
8192
"lint-staged": "^15.2.7",
8293
"npm-run-all2": "^6.2.2",
8394
"prettier": "^3.3.3",
84-
"typescript": "~5.5.4"
95+
"typescript": "~5.5.3"
8596
},
8697
"peerDependencies": {
8798
"eslint": "^7.0.0 || ^8.0.0 || ^9.0.0"

tsconfig.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"files": ["index.js"],
3+
"include": ["rules/**/*", "__tests__/**/*"],
4+
"compilerOptions": {
5+
"lib": ["es2022"],
6+
"target": "es2022",
7+
"types": ["node"],
8+
9+
"module": "node16",
10+
"moduleResolution": "node16",
11+
12+
"strict": true,
13+
14+
"skipLibCheck": false, // See https://github.com/voxpelli/tsconfig/issues/1
15+
16+
/* Clean up generated declarations */
17+
"removeComments": false,
18+
"stripInternal": true,
19+
20+
/* Make it a JS-targeted config */
21+
"allowJs": true,
22+
"checkJs": false, // Set to true to check all js files
23+
"noEmit": true,
24+
"resolveJsonModule": true,
25+
26+
/* Additional type checks */
27+
"exactOptionalPropertyTypes": true,
28+
"noFallthroughCasesInSwitch": true,
29+
"noImplicitOverride": true,
30+
"noPropertyAccessFromIndexSignature": true,
31+
"noUncheckedIndexedAccess": true,
32+
33+
/* Additional non-type checks */
34+
"forceConsistentCasingInFileNames": true,
35+
"noImplicitReturns": false, // Deactivated as I believe implicit "return undefined" at end of function is okay + explicit clashes with ESLint "no-useless-return"
36+
"noUnusedLocals": true,
37+
"noUnusedParameters": true
38+
39+
/* To make strict checking somewhat less strict during a transition stage, add one or more of: */
40+
/*
41+
"noImplicitThis": false,
42+
"noImplicitAny": false,
43+
"strictNullChecks": false,
44+
*/
45+
}
46+
}

0 commit comments

Comments
 (0)