Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade all dependencies, enable more warnings/lints #3127

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{ "vars": "all", "args": "none", "varsIgnorePattern": "^_" }
// MAINTENANCE_TODO: Enable warnings for args
{ "vars": "all", "args": "none", "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
],
"@typescript-eslint/prefer-as-const": "warn",
"@typescript-eslint/prefer-for-of": "warn",
Expand Down
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ module.exports = function (grunt) {
},
'autoformat-out-wpt': {
cmd: 'node',
args: ['node_modules/prettier/bin-prettier', '--loglevel=warn', '--write', 'out-wpt/**/*.js'],
// MAINTENANCE_TODO(gpuweb/cts#3128): This autoformat step is broken after a dependencies upgrade.
args: ['node_modules/prettier/bin/prettier.cjs', '--log-level=warn', '--write', 'out-wpt/**/*.js'],
},
tsdoc: {
cmd: 'node',
Expand Down
6,436 changes: 4,251 additions & 2,185 deletions package-lock.json

Large diffs are not rendered by default.

53 changes: 27 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,49 @@
},
"homepage": "https://github.com/gpuweb/cts#readme",
"devDependencies": {
"@babel/cli": "^7.19.3",
"@babel/core": "^7.20.5",
"@babel/preset-typescript": "^7.18.6",
"@types/babel__core": "^7.1.20",
"@types/dom-mediacapture-transform": "^0.1.4",
"@types/dom-webcodecs": "^0.1.5",
"@types/express": "^4.17.14",
"@types/jquery": "^3.5.14",
"@types/morgan": "^1.9.3",
"@types/node": "^14.18.12",
"@types/offscreencanvas": "^2019.7.0",
"@types/pngjs": "^6.0.1",
"@types/serve-index": "^1.9.1",
"@typescript-eslint/parser": "^4.33.0",
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.2",
"@babel/preset-typescript": "^7.23.2",
"@types/babel__core": "^7.20.3",
"@types/dom-mediacapture-transform": "^0.1.8",
"@types/dom-webcodecs": "^0.1.9",
"@types/express": "^4.17.20",
"@types/jquery": "^3.5.25",
"@types/morgan": "^1.9.7",
"@types/node": "^20.8.10",
"@types/offscreencanvas": "^2019.7.2",
"@types/pngjs": "^6.0.3",
"@types/serve-index": "^1.9.3",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@webgpu/types": "^0.1.38",
"ansi-colors": "4.1.1",
"ansi-colors": "4.1.3",
"babel-plugin-add-header-comment": "^1.0.3",
"babel-plugin-const-enum": "^1.2.0",
"chokidar": "^3.5.3",
"eslint": "^7.11.0",
"eslint": "^8.52.0",
"eslint-plugin-ban": "^1.6.0",
"eslint-plugin-deprecation": "^1.3.3",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-gpuweb-cts": "file:./tools/eslint-plugin-gpuweb-cts",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-import": "^2.29.0",
"express": "^4.18.2",
"grunt": "^1.5.3",
"grunt": "^1.6.1",
"grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-run": "^0.8.1",
"grunt-ts": "^6.0.0-beta.22",
"gts": "^3.1.1",
"gts": "^5.2.0",
"http-server": "^14.1.1",
"morgan": "^1.10.0",
"playwright-core": "^1.29.2",
"pngjs": "^6.0.0",
"playwright-core": "^1.39.0",
"pngjs": "^7.0.0",
"portfinder": "^1.0.32",
"prettier": "~2.1.2",
"prettier": "~3.0.3",
"screenshot-ftw": "^1.0.5",
"serve-index": "^1.9.1",
"ts-node": "^9.0.0",
"typedoc": "^0.23.21",
"typescript": "~4.7.4"
"ts-node": "^10.9.1",
"typedoc": "^0.25.3",
"typescript": "~5.2.2"
}
}
2 changes: 1 addition & 1 deletion src/common/framework/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class Fixture<S extends SubcaseBatchState = SubcaseBatchState> {
o instanceof WebGLRenderingContext ||
o instanceof WebGL2RenderingContext
) {
this.objectsToCleanUp.push((o as unknown) as DestroyableObject);
this.objectsToCleanUp.push(o as unknown as DestroyableObject);
}
}
return o;
Expand Down
14 changes: 8 additions & 6 deletions src/common/framework/params_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface ParamsBuilder {
*/
export type ParamTypeOf<
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
T extends ParamsBuilder
T extends ParamsBuilder,
> = T extends SubcaseParamsBuilder<infer CaseP, infer SubcaseP>
? Merged<CaseP, SubcaseP>
: T extends CaseParamsBuilder<infer CaseP>
Expand Down Expand Up @@ -131,7 +131,7 @@ export function builderIterateCasesWithSubcases(
iterateCasesWithSubcases(caseFilter: TestParams | null): CaseSubcaseIterable<{}, {}>;
}

return ((builder as unknown) as IterableParamsBuilder).iterateCasesWithSubcases(caseFilter);
return (builder as unknown as IterableParamsBuilder).iterateCasesWithSubcases(caseFilter);
}

/**
Expand All @@ -144,7 +144,8 @@ export function builderIterateCasesWithSubcases(
*/
export class CaseParamsBuilder<CaseP extends {}>
extends ParamsBuilderBase<CaseP, {}>
implements Iterable<DeepReadonly<CaseP>>, ParamsBuilder {
implements Iterable<DeepReadonly<CaseP>>, ParamsBuilder
{
*iterateCasesWithSubcases(caseFilter: TestParams | null): CaseSubcaseIterable<CaseP, {}> {
for (const caseP of this.cases(caseFilter)) {
if (caseFilter) {
Expand Down Expand Up @@ -230,7 +231,7 @@ export class CaseParamsBuilder<CaseP extends {}>
values: Iterable<NewPValue>
): CaseParamsBuilder<Merged<CaseP, { [name in NewPKey]: NewPValue }>> {
assertNotGenerator(values);
const mapped = mapLazy(values, v => ({ [key]: v } as { [name in NewPKey]: NewPValue }));
const mapped = mapLazy(values, v => ({ [key]: v }) as { [name in NewPKey]: NewPValue });
return this.combineWithParams(mapped);
}

Expand Down Expand Up @@ -279,7 +280,8 @@ export const kUnitCaseParamsBuilder = new CaseParamsBuilder(function* () {
*/
export class SubcaseParamsBuilder<CaseP extends {}, SubcaseP extends {}>
extends ParamsBuilderBase<CaseP, SubcaseP>
implements ParamsBuilder {
implements ParamsBuilder
{
protected readonly subcases: (_: CaseP) => Generator<SubcaseP>;

constructor(
Expand All @@ -305,7 +307,7 @@ export class SubcaseParamsBuilder<CaseP extends {}, SubcaseP extends {}>
if (subcases.length) {
yield [
caseP as DeepReadonly<typeof caseP>,
subcases as DeepReadonly<typeof subcases[number]>[],
subcases as DeepReadonly<(typeof subcases)[number]>[],
];
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/common/internal/file_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ interface TestFileLoaderEventMap {
finish: MessageEvent<void>;
}

// Override the types for addEventListener/removeEventListener so the callbacks can be used as
// strongly-typed.
/* eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging */
export interface TestFileLoader extends EventTarget {
addEventListener<K extends keyof TestFileLoaderEventMap>(
type: K,
Expand All @@ -53,19 +56,16 @@ export interface TestFileLoader extends EventTarget {
}

// Base class for DefaultTestFileLoader and FakeTestFileLoader.
/* eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging */
export abstract class TestFileLoader extends EventTarget {
abstract listing(suite: string): Promise<TestSuiteListing>;
protected abstract import(path: string): Promise<SpecFile>;

async importSpecFile(suite: string, path: string[]): Promise<SpecFile> {
const url = `${suite}/${path.join('/')}.spec.js`;
this.dispatchEvent(
new MessageEvent<ImportInfo>('import', { data: { url } })
);
this.dispatchEvent(new MessageEvent<ImportInfo>('import', { data: { url } }));
const ret = await this.import(url);
this.dispatchEvent(
new MessageEvent<ImportInfo>('imported', { data: { url } })
);
this.dispatchEvent(new MessageEvent<ImportInfo>('imported', { data: { url } }));
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/internal/params_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export type FlattenUnionOfInterfaces<T> = {
};

/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
function typeAssert<T extends 'pass'>() {}
function typeAssert<_ extends 'pass'>() {}
{
type Test<T, U> = [T] extends [U]
? [U] extends [T]
Expand Down
4 changes: 2 additions & 2 deletions src/common/internal/query/json_param_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const fromStringMagicValue = new Map<string, unknown>([
[jsNegativeZeroMagicValue, -0],
]);

function stringifyFilter(k: string, v: unknown): unknown {
function stringifyFilter(_k: string, v: unknown): unknown {
// Make sure no one actually uses a magic value as a parameter.
if (typeof v === 'string') {
assert(
Expand Down Expand Up @@ -93,7 +93,7 @@ export function stringifyParamValueUniquely(value: JSONWithUndefined): string {

// 'any' is part of the JSON.parse reviver interface, so cannot be avoided.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function parseParamValueReviver(k: string, v: any): any {
function parseParamValueReviver(_k: string, v: any): any {
if (fromStringMagicValue.has(v)) {
return fromStringMagicValue.get(v);
}
Expand Down
24 changes: 12 additions & 12 deletions src/common/internal/query/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export class TestQueryMultiFile {
* Immutable (makes copies of constructor args).
*/
export class TestQueryMultiTest extends TestQueryMultiFile {
readonly level: TestQueryLevel = 2;
readonly isMultiFile: false = false;
override readonly level: TestQueryLevel = 2;
override readonly isMultiFile = false as const;
readonly isMultiTest: boolean = true;
readonly testPathParts: readonly string[];

Expand All @@ -79,11 +79,11 @@ export class TestQueryMultiTest extends TestQueryMultiFile {
this.testPathParts = [...test];
}

get depthInLevel() {
override get depthInLevel() {
return this.testPathParts.length;
}

protected toStringHelper(): string[] {
protected override toStringHelper(): string[] {
return [
this.suite,
this.filePathParts.join(kPathSeparator),
Expand All @@ -99,8 +99,8 @@ export class TestQueryMultiTest extends TestQueryMultiFile {
* (which aren't normally supposed to change; they're marked readonly in TestParams).
*/
export class TestQueryMultiCase extends TestQueryMultiTest {
readonly level: TestQueryLevel = 3;
readonly isMultiTest: false = false;
override readonly level: TestQueryLevel = 3;
override readonly isMultiTest = false as const;
readonly isMultiCase: boolean = true;
readonly params: TestParams;

Expand All @@ -110,11 +110,11 @@ export class TestQueryMultiCase extends TestQueryMultiTest {
this.params = { ...params };
}

get depthInLevel() {
override get depthInLevel() {
return Object.keys(this.params).length;
}

protected toStringHelper(): string[] {
protected override toStringHelper(): string[] {
return [
this.suite,
this.filePathParts.join(kPathSeparator),
Expand All @@ -130,14 +130,14 @@ export class TestQueryMultiCase extends TestQueryMultiTest {
* Immutable (makes copies of constructor args).
*/
export class TestQuerySingleCase extends TestQueryMultiCase {
readonly level: TestQueryLevel = 4;
readonly isMultiCase: false = false;
override readonly level: TestQueryLevel = 4;
override readonly isMultiCase = false as const;

get depthInLevel() {
override get depthInLevel() {
return 0;
}

protected toStringHelper(): string[] {
protected override toStringHelper(): string[] {
return [
this.suite,
this.filePathParts.join(kPathSeparator),
Expand Down
6 changes: 3 additions & 3 deletions src/common/internal/test_group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface TestGroupBuilder<F extends Fixture> {
test(name: string): TestBuilderWithName<F>;
}
export function makeTestGroup<F extends Fixture>(fixture: FixtureClass<F>): TestGroupBuilder<F> {
return new TestGroup((fixture as unknown) as FixtureClass);
return new TestGroup(fixture as unknown as FixtureClass);
}

// Interfaces for running tests
Expand Down Expand Up @@ -127,7 +127,7 @@ export class TestGroup<F extends Fixture> implements TestGroupBuilder<F> {

const test = new TestBuilder(parts, this.fixture, testCreationStack);
this.tests.push(test);
return (test as unknown) as TestBuilderWithName<F>;
return test as unknown as TestBuilderWithName<F>;
}

validate(): void {
Expand Down Expand Up @@ -250,7 +250,7 @@ class TestBuilder<S extends SubcaseBatchState, F extends Fixture> {
return this;
}

specURL(url: string): this {
specURL(_url: string): this {
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/runtime/helper/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function getOptionsInfoFromSearchString<Type extends CTSOptions>(
const parser = info.parser || optionEnabled;
optionValues[optionName] = parser(camelCaseToSnakeCase(optionName), searchParams);
}
return (optionValues as unknown) as Type;
return optionValues as unknown as Type;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/common/runtime/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ function prepareParams(params: Record<string, ParamValue>): string {

// This is just a cast in one place.
export function optionsToRecord(options: CTSOptions) {
return (options as unknown) as Record<string, boolean | string>;
return options as unknown as Record<string, boolean | string>;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/common/tools/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": "../../../tsconfig.json" },
"parserOptions": { "project": "./tsconfig.json" },
"rules": {
"no-console": "off",
"no-process-exit": "off",
Expand Down
2 changes: 1 addition & 1 deletion src/common/tools/dev_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ watcher.on('change', dirtyCompileCache);
const app = express();

// Send Chrome Origin Trial tokens
app.use((req, res, next) => {
app.use((_req, res, next) => {
res.header('Origin-Trial', [
// Token for http://localhost:8080
'AvyDIV+RJoYs8fn3W6kIrBhWw0te0klraoz04mw/nPb8VTus3w5HCdy+vXqsSzomIH745CT6B5j1naHgWqt/tw8AAABJeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwODAiLCJmZWF0dXJlIjoiV2ViR1BVIiwiZXhwaXJ5IjoxNjYzNzE4Mzk5fQ==',
Expand Down
8 changes: 4 additions & 4 deletions src/common/util/data_tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { ResolveType, ZipKeysWithValues } from './types.js';
export type valueof<K> = K[keyof K];

export function keysOf<T extends string>(obj: { [k in T]: unknown }): readonly T[] {
return (Object.keys(obj) as unknown[]) as T[];
return Object.keys(obj) as unknown[] as T[];
}

export function numericKeysOf<T>(obj: object): readonly T[] {
return (Object.keys(obj).map(n => Number(n)) as unknown[]) as T[];
return Object.keys(obj).map(n => Number(n)) as unknown[] as T[];
}

/**
Expand All @@ -32,7 +32,7 @@ export function objectsToRecord<T extends Object>(objects: readonly T[]): Record
export function makeTable<
Members extends readonly string[],
Defaults extends readonly unknown[],
Table extends { readonly [k: string]: readonly unknown[] }
Table extends { readonly [k: string]: readonly unknown[] },
>(
members: Members,
defaults: Defaults,
Expand Down Expand Up @@ -99,7 +99,7 @@ export function makeTableRenameAndFilter<
Members extends readonly string[],
DataMembers extends readonly string[],
Defaults extends readonly unknown[],
Table extends { readonly [k: string]: readonly unknown[] }
Table extends { readonly [k: string]: readonly unknown[] },
>(
columnRenames: { [key: string]: string },
columnsKept: Members,
Expand Down
2 changes: 1 addition & 1 deletion src/common/util/preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class If extends Directive {
}

class ElseIf extends If {
applyTo(stack: StateStack) {
override applyTo(stack: StateStack) {
assert(stack.length >= 1);
const { allowsFollowingElse, state: siblingState } = stack.pop()!;
this.checkDepth(stack);
Expand Down
Loading