Skip to content

Commit

Permalink
chore: upgrade deps add configs
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Conaclos committed Jun 19, 2023
1 parent 4c5b501 commit 6c765cb
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 327 deletions.
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.json]
[package*.json]
indent_size = 2
insert_final_newline = false
510 changes: 255 additions & 255 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@
"build": "sh ./scripts/build.sh",
"clean": "rm -rf dist coverage",
"coverage": "c8 --reporter=lcovonly npm test",
"format": "rome format --write .",
"prepare": "validate-commit-msg",
"prepublishOnly": "npm run clean && npm test",
"test": "sh ./scripts/test.sh"
},
"devDependencies": {
"esbuild": "0.17.12",
"oletus": "3.3.0",
"rome": "12.0.0",
"typescript": "5.0.2",
"esbuild": "0.18.4",
"oletus": "4.0.0",
"rome": "12.1.3",
"typescript": "5.1.3",
"validate-commit-message": "3.2.0"
}
}
39 changes: 21 additions & 18 deletions rome.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
{
"formatter": {
"indentStyle": "space",
"indentSize": 4,
"ignore": ["*.json", "./tsconfig-base.json"]
},
"linter": {
"enabled": true,
"rules": {
"all": true
}
},
"javascript": {
"$schema": "https://docs.rome.tools/schemas/12.1.3/schema.json",
"formatter": {
"quoteProperties": "preserve",
"semicolons": "asNeeded"
"indentStyle": "space",
"indentSize": 4
},
"linter": {
"rules": {
"all": true
}
},
"javascript": {
"formatter": {
"semicolons": "asNeeded"
}
},
"organizeImports": {
"enabled": true
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
}
},
"organizeImports": {
"enabled": true
}
}
8 changes: 6 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/sh
set -eu

# https://node.green/#ES2020
# https://kangax.github.io/compat-table/es2016plus
TARGET=es2020

# build ESM
esbuild src/*.ts src/*/*.ts --platform=neutral --outdir=dist --log-level=warning
esbuild src/*.ts src/*/*.ts --target=$TARGET --platform=neutral --outdir=dist --log-level=warning

# build .d.ts
tsc --build src

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

cp -f dist/index.d.ts dist/index.d.cts
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
env NODE_ENV=development oletus tests/*/*.test.js

# lint
rome ci src tests
rome ci .

# type check
tsc --build tests
2 changes: 1 addition & 1 deletion src/env/dev.node.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare const process: { readonly env: Record<string, string | undefined> }

export const DEV: boolean = process.env["NODE_ENV"] === "development"
export const DEV: boolean = process.env.NODE_ENV === "development"
10 changes: 4 additions & 6 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"outDir": "../dist",
"noEmit": false,
"composite": true,
"emitDeclarationOnly": true,

"composite": true
},
"include": ["**/*.ts"]
"noEmit": false,
"outDir": "../dist"
}
}
5 changes: 0 additions & 5 deletions tests/codec/_util.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tests/codec/_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ByteCursor, Config } from "@bare-ts/lib"

/**
*
* @param {...number[]} rest
* @param {...number} rest
* @returns {ByteCursor}
*/
export function fromBytes(...rest) {
Expand Down
8 changes: 1 addition & 7 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"moduleResolution": "node",
"paths": { "@bare-ts/lib": ["../src/index.js"] }
},
"include": ["**/*.js", "**/*.ts"],
"references": [{ "path": "../src" }]
"extends": "../tsconfig-base.json"
}
46 changes: 21 additions & 25 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
{
"compilerOptions": {
// https://node.green/#ES2020
// https://kangax.github.io/compat-table/es2016plus
"lib": ["ES2020"],
"moduleResolution": "node16",
"module": "ES2020",
"target": "ES2020",
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"lib": ["ES2020"],
"module": "ES2020",
"moduleResolution": "node16",
"target": "ES2020",

// Don't implicitly import @types/*
"types": [],
"noEmit": true,

"noEmit": true,
"sourceMap": true,
"stripInternal": true,
"types": [],

"esModuleInterop": true,
"isolatedModules": true,
"resolveJsonModule": true,
"verbatimModuleSyntax": true,
"esModuleInterop": true,
"isolatedModules": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"verbatimModuleSyntax": true,

"allowUnreachableCode": false,
"checkJs": true,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"strict": true
}
"allowUnreachableCode": false,
"checkJs": true,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"strict": true
}
}

0 comments on commit 6c765cb

Please sign in to comment.