Skip to content

Commit

Permalink
Update TypeScript, Prettier, and other dev deps (#1014)
Browse files Browse the repository at this point in the history
### Public-Facing Changes

[BREAKING] The `@mcap/core` source code now uses [private
properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties).
Depending on what runtime and build system you use to consume this
package, you may need to add plugins or change settings to handle the
new syntax. Modern JS engines and bundlers should not require any
changes.

### Description

- Upgrade TypeScript, Prettier, `@foxglove/eslint-plugin` etc. and fix
new lint errors.
- Use `es2022` for typescript `target` & `module` settings
  • Loading branch information
jtbandes authored Nov 16, 2023
1 parent f87352f commit 886f652
Show file tree
Hide file tree
Showing 54 changed files with 2,849 additions and 2,158 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.yarn/**/*.cjs filter=lfs diff=lfs merge=lfs -text
*.bag filter=lfs diff=lfs merge=lfs -text
*.bfbs filter=lfs diff=lfs merge=lfs -text
*.csv linguist-generated=true
Expand Down
32 changes: 19 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- run: corepack enable && yarn install --immutable
- run: echo '::add-matcher::.github/cspell-problem-matcher.json'
Expand All @@ -30,7 +30,7 @@ jobs:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- run: corepack enable && yarn install --immutable
- run: yarn workspace @foxglove/mcap-conformance lint:ci
Expand All @@ -44,7 +44,7 @@ jobs:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- uses: actions/cache@v3
with:
Expand All @@ -63,7 +63,7 @@ jobs:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- uses: actions/setup-go@v4
with:
Expand All @@ -81,7 +81,7 @@ jobs:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- uses: actions/setup-python@v4
with:
Expand All @@ -99,7 +99,7 @@ jobs:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- run: corepack enable && yarn install --immutable
- run: yarn test:conformance:generate-inputs --verify
Expand All @@ -113,7 +113,7 @@ jobs:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- run: corepack enable && yarn install --immutable
- run: yarn test:conformance:generate-inputs --verify
Expand All @@ -127,7 +127,7 @@ jobs:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- uses: swift-actions/setup-swift@v1
with:
Expand All @@ -145,7 +145,7 @@ jobs:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -199,9 +199,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
registry-url: https://registry.npmjs.org
- run: corepack enable && yarn install --immutable
Expand All @@ -221,9 +223,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- run: corepack enable && yarn install --immutable
- run: yarn workspace @foxglove/mcap-benchmarks lint:ci
Expand All @@ -233,9 +237,11 @@ jobs:
- run: yarn workspace @foxglove/mcap-example-bag2mcap lint:ci
- run: yarn workspace @foxglove/mcap-example-bag2mcap typecheck
- run: yarn workspace @foxglove/mcap-example-basicwriter lint:ci
- run: yarn workspace @foxglove/mcap-example-basicwriter lint:ci
- run: yarn workspace @foxglove/mcap-example-flatbufferswriter typecheck
- run: yarn workspace @foxglove/mcap-example-basicwriter typecheck
- run: yarn workspace @foxglove/mcap-example-flatbufferswriter lint:ci
- run: yarn workspace @foxglove/mcap-example-flatbufferswriter typecheck
- run: yarn workspace @foxglove/mcap-example-text-annotation-demo lint:ci
- run: yarn workspace @foxglove/mcap-example-text-annotation-demo typecheck

python:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
cache: yarn

- run: corepack enable && yarn install --immutable
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ dist
site/
.cache
.pnp.*
.yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/sdks

*.db3-shm
*.db3-wal
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ python/Pipfile.lock
tests/conformance/data/**/*.json
typescript/examples/flatbuffer/output/**/*.ts
website/.docusaurus
rust/target
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"files.trimTrailingWhitespace": true,

"typescript.tsdk": "node_modules/typescript/lib",
"prettier.prettierPath": "./node_modules/prettier",
"eslint.packageManager": "yarn",
"prettier.prettierPath": "./node_modules/prettier/index.cjs",
"eslint.options": {
"reportUnusedDisableDirectives": "error"
},
Expand Down
3 changes: 3 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
Git LFS file not shown
4 changes: 4 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
defaultSemverRangePrefix: ""

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
},
"packageManager": "yarn@3.5.0",
"devDependencies": {
"cspell": "^6.26.3",
"prettier": "^2.8.4",
"typedoc": "^0.23.25"
"cspell": "8.0.0",
"prettier": "3.1.0",
"typedoc": "0.25.3",
"typescript": "5.2.2"
}
}
22 changes: 11 additions & 11 deletions tests/conformance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@
},
"devDependencies": {
"@foxglove/crc": "^0.0.3",
"@foxglove/eslint-plugin": "0.21.0",
"@foxglove/eslint-plugin": "1.0.0",
"@foxglove/tsconfig": "1.1.0",
"@mcap/core": "*",
"@types/diff": "^5.0.2",
"@types/js-yaml": "^4.0.5",
"@types/node": "18.13.0",
"@typescript-eslint/eslint-plugin": "5.52.0",
"@typescript-eslint/parser": "5.52.0",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"colors": "1.4.0",
"commander": "10.0.0",
"commander": "11.1.0",
"diff": "^5.1.0",
"eslint": "8.34.0",
"eslint-config-prettier": "8.6.0",
"eslint": "8.53.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-es": "4.1.0",
"eslint-plugin-filenames": "1.3.2",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "27.2.1",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-jest": "27.6.0",
"eslint-plugin-prettier": "5.0.1",
"js-yaml": "4.1.0",
"json-stable-stringify": "1.0.2",
"kaitai-struct": "0.10.0",
"kaitai-struct-compiler": "0.10.0",
"lodash": "4.17.21",
"prettier": "2.8.4",
"prettier": "3.1.0",
"ts-node": "10.9.1",
"tsconfig-paths": "^4.1.2",
"typescript": "4.9.5"
"typescript": "5.2.2"
}
}
4 changes: 2 additions & 2 deletions tests/conformance/scripts/run-tests/runners/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export abstract class IndexedReadTestRunner {
messages: [],
statistics: [],
};
const knownSchemaIds: Set<number> = new Set();
const knownChannelIds: Set<number> = new Set();
const knownSchemaIds = new Set<number>();
const knownChannelIds = new Set<number>();
for (const record of testCase.records) {
switch (record.type) {
case "Schema":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class TypescriptIndexedReaderTestRunner extends IndexedReadTestRu
async runReadTest(filePath: string): Promise<IndexedReadTestResult> {
const handle = await fs.open(filePath, "r");
try {
return await this._run(handle);
return await this.#run(handle);
} finally {
await handle.close();
}
Expand Down Expand Up @@ -40,7 +40,7 @@ export default class TypescriptIndexedReaderTestRunner extends IndexedReadTestRu
return true;
}

private async _run(fileHandle: fs.FileHandle): Promise<IndexedReadTestResult> {
async #run(fileHandle: fs.FileHandle): Promise<IndexedReadTestResult> {
let buffer = new ArrayBuffer(4096);
const readable = {
size: async () => BigInt((await fileHandle.stat()).size),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { WriteTestRunner } from "./TestRunner";
type JsonValue<T> = T extends number | bigint | string
? string
: T extends Uint8Array
? number[]
: T extends Map<infer K, infer V>
? K extends number | bigint | string
? Record<JsonValue<K>, JsonValue<V>>
: never
: never;
? number[]
: T extends Map<infer K, infer V>
? K extends number | bigint | string
? Record<JsonValue<K>, JsonValue<V>>
: never
: never;

type JsonRecord<R extends keyof McapTypes.McapRecords> = {
type: R;
Expand Down
18 changes: 9 additions & 9 deletions typescript/benchmarks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ import { add, complete, cycle, suite } from "benny";
* the copies without actually allocating the full initial capacity.
*/
class FakeMemoryWritable {
private _lastWrittenData: Uint8Array;
private _size = 0;
#lastWrittenData: Uint8Array;
#size = 0;

constructor(capacity: number) {
this._lastWrittenData = new Uint8Array(capacity);
this.#lastWrittenData = new Uint8Array(capacity);
}

reset() {
this._size = 0;
this.#size = 0;
}
position() {
return BigInt(this._size);
return BigInt(this.#size);
}
async write(data: Uint8Array) {
if (data.byteLength > this._lastWrittenData.byteLength) {
if (data.byteLength > this.#lastWrittenData.byteLength) {
throw new Error(
`Write out of bounds, capacity would need to be at least ${this._size + data.byteLength}`,
`Write out of bounds, capacity would need to be at least ${this.#size + data.byteLength}`,
);
}
this._lastWrittenData.set(data, 0);
this._size += data.byteLength;
this.#lastWrittenData.set(data, 0);
this.#size += data.byteLength;
}
}

Expand Down
18 changes: 9 additions & 9 deletions typescript/benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
"bench:debug": "NODE_OPTIONS='--inspect-brk' ts-node --files --project tsconfig.cjs.json index.ts"
},
"devDependencies": {
"@foxglove/eslint-plugin": "0.21.0",
"@foxglove/eslint-plugin": "1.0.0",
"@foxglove/tsconfig": "1.1.0",
"@mcap/core": "*",
"@types/node": "18.13.0",
"@typescript-eslint/eslint-plugin": "5.52.0",
"@typescript-eslint/parser": "5.52.0",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"benny": "^3.7.1",
"eslint": "8.34.0",
"eslint-config-prettier": "8.6.0",
"eslint": "8.53.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-es": "4.1.0",
"eslint-plugin-filenames": "1.3.2",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-prettier": "4.2.1",
"prettier": "2.8.4",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-prettier": "5.0.1",
"prettier": "3.1.0",
"ts-node": "10.9.1",
"tsconfig-paths": "4.1.2",
"typescript": "4.9.5"
"typescript": "5.2.2"
}
}
3 changes: 2 additions & 1 deletion typescript/benchmarks/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"noEmit": true,
"rootDir": "..",
"outDir": "./dist/esm",
"lib": ["es2020", "dom"],
"target": "es2022",
"lib": ["es2022", "dom"],
"paths": {
"@mcap/core": ["../core/src"]
},
Expand Down
Loading

0 comments on commit 886f652

Please sign in to comment.