Skip to content

Commit 6c765cb

Browse files
committed
chore: upgrade deps add configs
- Remove TS config `noImplicitAny` and `noImplicitTHis`. They are both enabled under `strict` in TSC >=5.0 - Remove TS config `noUnusedLocals`: this should be checked by a linter. - Remove TS config `noUncheckedIndexedAccess`. It can conflict with rome's `useLiteralKeys` linter rule. - Enable skipLibCheck (recommended by TSC) - Remove stripInternal (no use) - Add tsconfig and rome $schema for auto-completion in IDE - Remove `npx` in scripts: it incurs a 30% slowdown. - Specify `--target` for _ESbuild_. _ESbuild_ >= 0.18.0 no longer relies on `tsconfig`'s `target` option. - Check formatting of JSON files - Add `npm run iormat` script for formatting files - Use 4 space indentation for all JSON files
1 parent 4c5b501 commit 6c765cb

File tree

12 files changed

+317
-327
lines changed

12 files changed

+317
-327
lines changed

.editorconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ indent_size = 4
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.json]
11+
[package*.json]
1212
indent_size = 2
13-
insert_final_newline = false

package-lock.json

Lines changed: 255 additions & 255 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@
5656
"build": "sh ./scripts/build.sh",
5757
"clean": "rm -rf dist coverage",
5858
"coverage": "c8 --reporter=lcovonly npm test",
59+
"format": "rome format --write .",
5960
"prepare": "validate-commit-msg",
6061
"prepublishOnly": "npm run clean && npm test",
6162
"test": "sh ./scripts/test.sh"
6263
},
6364
"devDependencies": {
64-
"esbuild": "0.17.12",
65-
"oletus": "3.3.0",
66-
"rome": "12.0.0",
67-
"typescript": "5.0.2",
65+
"esbuild": "0.18.4",
66+
"oletus": "4.0.0",
67+
"rome": "12.1.3",
68+
"typescript": "5.1.3",
6869
"validate-commit-message": "3.2.0"
6970
}
7071
}

rome.json

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
{
2-
"formatter": {
3-
"indentStyle": "space",
4-
"indentSize": 4,
5-
"ignore": ["*.json", "./tsconfig-base.json"]
6-
},
7-
"linter": {
8-
"enabled": true,
9-
"rules": {
10-
"all": true
11-
}
12-
},
13-
"javascript": {
2+
"$schema": "https://docs.rome.tools/schemas/12.1.3/schema.json",
143
"formatter": {
15-
"quoteProperties": "preserve",
16-
"semicolons": "asNeeded"
4+
"indentStyle": "space",
5+
"indentSize": 4
6+
},
7+
"linter": {
8+
"rules": {
9+
"all": true
10+
}
11+
},
12+
"javascript": {
13+
"formatter": {
14+
"semicolons": "asNeeded"
15+
}
16+
},
17+
"organizeImports": {
18+
"enabled": true
19+
},
20+
"vcs": {
21+
"enabled": true,
22+
"clientKind": "git",
23+
"useIgnoreFile": true
1724
}
18-
},
19-
"organizeImports": {
20-
"enabled": true
21-
}
2225
}

scripts/build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#!/bin/sh
22
set -eu
33

4+
# https://node.green/#ES2020
5+
# https://kangax.github.io/compat-table/es2016plus
6+
TARGET=es2020
7+
48
# build ESM
5-
esbuild src/*.ts src/*/*.ts --platform=neutral --outdir=dist --log-level=warning
9+
esbuild src/*.ts src/*/*.ts --target=$TARGET --platform=neutral --outdir=dist --log-level=warning
610

711
# build .d.ts
812
tsc --build src
913

1014
# build CommonJS (fallback)
11-
esbuild src/index.ts --bundle --platform=node > dist/index.cjs
15+
esbuild src/index.ts --bundle --target=$TARGET --platform=node > dist/index.cjs
1216

1317
cp -f dist/index.d.ts dist/index.d.cts

scripts/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
env NODE_ENV=development oletus tests/*/*.test.js
77

88
# lint
9-
rome ci src tests
9+
rome ci .
1010

1111
# type check
1212
tsc --build tests

src/env/dev.node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
declare const process: { readonly env: Record<string, string | undefined> }
22

3-
export const DEV: boolean = process.env["NODE_ENV"] === "development"
3+
export const DEV: boolean = process.env.NODE_ENV === "development"

src/tsconfig.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
{
22
"extends": "../tsconfig-base.json",
33
"compilerOptions": {
4-
"outDir": "../dist",
5-
"noEmit": false,
4+
"composite": true,
65
"emitDeclarationOnly": true,
7-
8-
"composite": true
9-
},
10-
"include": ["**/*.ts"]
6+
"noEmit": false,
7+
"outDir": "../dist"
8+
}
119
}

tests/codec/_util.d.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/codec/_util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ByteCursor, Config } from "@bare-ts/lib"
22

33
/**
44
*
5-
* @param {...number[]} rest
5+
* @param {...number} rest
66
* @returns {ByteCursor}
77
*/
88
export function fromBytes(...rest) {

tests/tsconfig.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
{
2-
"extends": "../tsconfig-base.json",
3-
"compilerOptions": {
4-
"moduleResolution": "node",
5-
"paths": { "@bare-ts/lib": ["../src/index.js"] }
6-
},
7-
"include": ["**/*.js", "**/*.ts"],
8-
"references": [{ "path": "../src" }]
2+
"extends": "../tsconfig-base.json"
93
}

tsconfig-base.json

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
{
2-
"compilerOptions": {
3-
// https://node.green/#ES2020
4-
// https://kangax.github.io/compat-table/es2016plus
5-
"lib": ["ES2020"],
6-
"moduleResolution": "node16",
7-
"module": "ES2020",
8-
"target": "ES2020",
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"compilerOptions": {
4+
"lib": ["ES2020"],
5+
"module": "ES2020",
6+
"moduleResolution": "node16",
7+
"target": "ES2020",
98

10-
// Don't implicitly import @types/*
11-
"types": [],
9+
"noEmit": true,
1210

13-
"noEmit": true,
14-
"sourceMap": true,
15-
"stripInternal": true,
11+
"types": [],
1612

17-
"esModuleInterop": true,
18-
"isolatedModules": true,
19-
"resolveJsonModule": true,
20-
"verbatimModuleSyntax": true,
13+
"esModuleInterop": true,
14+
"isolatedModules": true,
15+
"resolveJsonModule": true,
16+
"skipLibCheck": true,
17+
"verbatimModuleSyntax": true,
2118

22-
"allowUnreachableCode": false,
23-
"checkJs": true,
24-
"exactOptionalPropertyTypes": true,
25-
"noFallthroughCasesInSwitch": true,
26-
"noImplicitOverride": true,
27-
"noImplicitReturns": true,
28-
"noPropertyAccessFromIndexSignature": true,
29-
"strict": true
30-
}
19+
"allowUnreachableCode": false,
20+
"checkJs": true,
21+
"exactOptionalPropertyTypes": true,
22+
"noFallthroughCasesInSwitch": true,
23+
"noImplicitOverride": true,
24+
"noImplicitReturns": true,
25+
"strict": true
26+
}
3127
}

0 commit comments

Comments
 (0)