diff --git a/apps/go-conditional-tests/dist/index.js b/apps/go-conditional-tests/dist/index.js index 61660d533..c4c33d8c5 100644 --- a/apps/go-conditional-tests/dist/index.js +++ b/apps/go-conditional-tests/dist/index.js @@ -135428,12 +135428,12 @@ async function buildStep(inputs) { async function runStep(inputs, pkgs) { const packages = await processChangedPackages(inputs, pkgs); const changedPkgs = Object.fromEntries( - Object.entries(packages).filter(([_2, pkg]) => pkg.shouldRun) + Object.entries(packages).filter(([, pkg]) => pkg.shouldRun) ); logObject("Changed Test Packages", changedPkgs); const maybeExecdPkgs = await runTestBinaries(inputs, packages); const execdPkgs = Object.fromEntries( - Object.entries(maybeExecdPkgs).filter(([_2, pkg]) => !!pkg.run) + Object.entries(maybeExecdPkgs).filter(([, pkg]) => !!pkg.run) ); logObject("Executed Test Packages", execdPkgs); return maybeExecdPkgs; diff --git a/apps/go-conditional-tests/src/github.ts b/apps/go-conditional-tests/src/github.ts index 7bc0385e3..2920a3e45 100644 --- a/apps/go-conditional-tests/src/github.ts +++ b/apps/go-conditional-tests/src/github.ts @@ -2,7 +2,6 @@ import * as core from "@actions/core"; import * as github from "@actions/github"; import * as cache from "@actions/cache"; import * as fs from "fs"; -import * as path from "path"; function getCacheKey(testSuite: string, branch: string, commitSha?: string) { const key = `go-test-hashes-${testSuite}-${branch}`; diff --git a/apps/go-conditional-tests/src/main.ts b/apps/go-conditional-tests/src/main.ts index 15ea26664..7bd39767d 100644 --- a/apps/go-conditional-tests/src/main.ts +++ b/apps/go-conditional-tests/src/main.ts @@ -155,13 +155,13 @@ async function runStep( const packages = await pipeline.processChangedPackages(inputs, pkgs); const changedPkgs = Object.fromEntries( - Object.entries(packages).filter(([_, pkg]) => pkg.shouldRun), + Object.entries(packages).filter(([, pkg]) => pkg.shouldRun), ); logObject("Changed Test Packages", changedPkgs); const maybeExecdPkgs = await pipeline.runTestBinaries(inputs, packages); const execdPkgs = Object.fromEntries( - Object.entries(maybeExecdPkgs).filter(([_, pkg]) => !!pkg.run), + Object.entries(maybeExecdPkgs).filter(([, pkg]) => !!pkg.run), ); logObject("Executed Test Packages", execdPkgs); diff --git a/apps/go-conditional-tests/src/pipeline/filter.ts b/apps/go-conditional-tests/src/pipeline/filter.ts index d12ea1d77..e0a8d63a5 100644 --- a/apps/go-conditional-tests/src/pipeline/filter.ts +++ b/apps/go-conditional-tests/src/pipeline/filter.ts @@ -1,5 +1,3 @@ -import * as path from "path"; - import * as core from "@actions/core"; import { execa } from "execa"; diff --git a/apps/go-conditional-tests/test/github.test.ts b/apps/go-conditional-tests/test/github.test.ts index a4566dee9..a3f6003cb 100644 --- a/apps/go-conditional-tests/test/github.test.ts +++ b/apps/go-conditional-tests/test/github.test.ts @@ -46,7 +46,7 @@ describe("getTestHashIndex", () => { }); it("should return empty object when no cache hit", async () => { - (cache.restoreCache as any).mockResolvedValue(null); + vi.mocked(cache.restoreCache).mockResolvedValue(undefined); const result = await getTestHashIndex("unit"); @@ -62,8 +62,8 @@ describe("getTestHashIndex", () => { base: { ref: "main" }, head: { ref: "feature", sha: "abcdef1" }, }; - (cache.restoreCache as any).mockResolvedValue("some-cache-key"); - (fs.promises.readFile as any).mockResolvedValue('{"pkg1": "hash1"}'); + vi.mocked(cache.restoreCache).mockResolvedValue("some-cache-key"); + vi.mocked(fs.promises.readFile).mockResolvedValue('{"pkg1": "hash1"}'); await getTestHashIndex("unit"); @@ -90,8 +90,8 @@ describe("getTestHashIndex", () => { }, }, }; - (cache.restoreCache as any).mockResolvedValue("some-cache-key"); - (fs.promises.readFile as any).mockResolvedValue('{"pkg1": "hash1"}'); + vi.mocked(cache.restoreCache).mockResolvedValue("some-cache-key"); + vi.mocked(fs.promises.readFile).mockResolvedValue('{"pkg1": "hash1"}'); await getTestHashIndex("unit"); @@ -106,8 +106,8 @@ describe("getTestHashIndex", () => { }); it("should handle file read errors", async () => { - (cache.restoreCache as any).mockResolvedValue("some-cache-key"); - (fs.promises.readFile as any).mockRejectedValue(new Error("read error")); + vi.mocked(cache.restoreCache).mockResolvedValue("some-cache-key"); + vi.mocked(fs.promises.readFile).mockRejectedValue(new Error("read error")); const result = await getTestHashIndex("unit"); @@ -186,7 +186,7 @@ describe("saveTestHashIndex", () => { }); it("should handle cache reservation errors", async () => { - (cache.saveCache as any).mockRejectedValue( + vi.mocked(cache.saveCache).mockRejectedValue( new cache.ReserveCacheError("already reserved"), ); @@ -198,7 +198,7 @@ describe("saveTestHashIndex", () => { }); it("should throw non-reservation errors", async () => { - (cache.saveCache as any).mockRejectedValue(new Error("network error")); + vi.mocked(cache.saveCache).mockRejectedValue(new Error("network error")); await expect(saveTestHashIndex("unit", { pkg1: "hash1" })).rejects.toThrow( "network error", diff --git a/apps/go-conditional-tests/test/pipeline.test.ts b/apps/go-conditional-tests/test/pipeline.test.ts index f7e75f8ed..b2bfc5754 100644 --- a/apps/go-conditional-tests/test/pipeline.test.ts +++ b/apps/go-conditional-tests/test/pipeline.test.ts @@ -1,6 +1,5 @@ import { describe, it, expect, vi, beforeEach, Mock } from "vitest"; import * as core from "@actions/core"; -import * as github from "@actions/github"; import { Inputs } from "../src/main.js"; import { saveTestHashIndex } from "../src/github.js"; @@ -256,7 +255,11 @@ describe("runTestBinaries", () => { directory: "/path/pkg1", hash: "hash1", shouldRun: true, - compile: { binary: "bin1", log: "log1", execution: {} as any }, + compile: { + binary: "bin1", + log: "log1", + execution: { command: "", exitCode: 0, cwd: "", durationMs: 0 }, + }, }, }; diff --git a/apps/go-conditional-tests/test/pipeline/build.test.ts b/apps/go-conditional-tests/test/pipeline/build.test.ts index 4281bf839..3e0401786 100644 --- a/apps/go-conditional-tests/test/pipeline/build.test.ts +++ b/apps/go-conditional-tests/test/pipeline/build.test.ts @@ -195,7 +195,8 @@ describe("validateCompilationResultsOrThrow", () => { isCanceled: false, killed: false, pid: 1234, - } as any, + pipe: vi.fn(), + }, }; readdirSyncMock.mockReturnValue(["github.com-example-pkg-test"]); diff --git a/apps/go-conditional-tests/test/pipeline/filter.test.ts b/apps/go-conditional-tests/test/pipeline/filter.test.ts index 166182d5f..27d16fe79 100644 --- a/apps/go-conditional-tests/test/pipeline/filter.test.ts +++ b/apps/go-conditional-tests/test/pipeline/filter.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi, beforeEach } from "vitest"; +import { describe, it, expect, vi, beforeEach, Mock } from "vitest"; import { execa } from "execa"; @@ -17,6 +17,8 @@ vi.mock("@actions/core", () => ({ debug: vi.fn(), })); +const execaMock = execa as unknown as Mock; + describe("listPackages", () => { beforeEach(() => { vi.clearAllMocks(); @@ -29,7 +31,7 @@ describe("listPackages", () => { ]; // Mock execa for 'go list' command - (execa as any).mockResolvedValueOnce({ + execaMock.mockResolvedValueOnce({ stdout: mockedStdout, }); diff --git a/apps/go-conditional-tests/test/pipeline/hash.test.ts b/apps/go-conditional-tests/test/pipeline/hash.test.ts index 7c50ab508..abf8e419e 100644 --- a/apps/go-conditional-tests/test/pipeline/hash.test.ts +++ b/apps/go-conditional-tests/test/pipeline/hash.test.ts @@ -35,7 +35,9 @@ describe("hashFile", () => { }, }); - vi.spyOn(fs, "createReadStream").mockReturnValue(readableStream as any); + vi.spyOn(fs, "createReadStream").mockReturnValue( + readableStream as fs.ReadStream, + ); // Act const hash = await hashFile(testFilePath); @@ -177,7 +179,11 @@ function createPackageEntry( return { importPath: "foo.com/bar/baz/v2/qux", directory: "baz/qux", - compile: { binary: "", log: "", execution: null as any }, + compile: { + binary: "", + log: "", + execution: { command: "", exitCode: 0, cwd: "", durationMs: 0 }, + }, hash, }; } diff --git a/apps/go-conditional-tests/test/pipeline/run.test.ts b/apps/go-conditional-tests/test/pipeline/run.test.ts index 13eab7023..a465fa0cb 100644 --- a/apps/go-conditional-tests/test/pipeline/run.test.ts +++ b/apps/go-conditional-tests/test/pipeline/run.test.ts @@ -1,4 +1,3 @@ -import * as path from "path"; import * as fs from "fs"; import { describe, it, expect, vi, beforeEach, Mock } from "vitest"; @@ -146,7 +145,7 @@ describe("runTestBinary", () => { directory: "/path/to/pkg", }; const binaryPath = "/path/to/binary"; - const runFlags = []; + const runFlags: string[] = []; const coverageDir = "/coverage"; const executionResult = { @@ -327,6 +326,7 @@ describe("validateRunResultsOrThrow", () => { isCanceled: false, killed: false, pid: 1234, + pipe: vi.fn(), }; const results = [ @@ -339,7 +339,7 @@ describe("validateRunResultsOrThrow", () => { importPath: "github.com/example/pkg", directory: "/path/to/pkg", }, - execution: executionResult as any, + execution: executionResult, }, ] satisfies RunResult[]; diff --git a/apps/go-mod-validator/dist/index.js b/apps/go-mod-validator/dist/index.js index 5341e1f41..77c286ae3 100644 --- a/apps/go-mod-validator/dist/index.js +++ b/apps/go-mod-validator/dist/index.js @@ -29928,7 +29928,7 @@ function goModsToGoModules(goModFilePath, goMods, depPrefix) { } return true; }).map((d) => { - const [_, owner, repo, ...subModulePathElements] = d.Path.split("/"); + const [, owner, repo, ...subModulePathElements] = d.Path.split("/"); const baseModule = { owner, repo, diff --git a/apps/go-mod-validator/src/deps.ts b/apps/go-mod-validator/src/deps.ts index 8add344ac..ae23d85ba 100644 --- a/apps/go-mod-validator/src/deps.ts +++ b/apps/go-mod-validator/src/deps.ts @@ -304,7 +304,7 @@ export function goModsToGoModules( }) .map((d: GoMod): GoModule => { // repo format github.com/smartcontractkit/chainlink - const [_, owner, repo, ...subModulePathElements] = d.Path.split("/"); + const [, owner, repo, ...subModulePathElements] = d.Path.split("/"); const baseModule: BaseGoModule = { owner, repo, diff --git a/eslint.config.mjs b/eslint.config.mjs index bcc0f3e74..9a4f8dc34 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,21 +1,10 @@ -import { FlatCompat } from "@eslint/eslintrc"; -import { dirname } from "path"; -import { fileURLToPath } from "url"; +import eslintConfigPrettier from "eslint-config-prettier"; import js from "@eslint/js"; +import * as jsoncEslintParser from "jsonc-eslint-parser"; import nx from "@nx/eslint-plugin"; +import tseslint from "typescript-eslint"; -const compat = new FlatCompat({ - baseDirectory: dirname(fileURLToPath(import.meta.url)), - recommendedConfig: js.configs.recommended, -}); - -const prettierCompat = (files, config = {}) => - compat - .config({ extends: ["prettier"], ...config }) - .map((flatConfig) => ({ ...flatConfig, files })); - -export default [ - ...compat.extends("prettier"), +export default tseslint.config( ...nx.configs["flat/base"], { files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"], @@ -35,10 +24,27 @@ export default [ ], }, }, - ...nx.configs["flat/typescript"], - ...prettierCompat(["**/*.ts", "**/*.tsx"]), - ...nx.configs["flat/javascript"], - ...prettierCompat(["**/*.js", "**/*.jsx"]), - ...prettierCompat(["**/*.json"], { parser: "jsonc-eslint-parser" }), - ...prettierCompat(["**/*.yaml", "**/*.yml"]), -]; + { + files: ["**/*.ts", "**/*.tsx"], + extends: [tseslint.configs.recommended], + languageOptions: { + parser: tseslint.parser, + ecmaVersion: 2020, + sourceType: "module", + parserOptions: { + tsconfigRootDir: import.meta.dirname, + }, + }, + }, + { + files: ["**/*.js", "**/*.jsx"], + ...js.configs.recommended, + }, + { + files: ["**/*.json"], + languageOptions: { + parser: jsoncEslintParser, + }, + }, + eslintConfigPrettier, +); diff --git a/libs/jira-tracing/tsconfig.json b/libs/jira-tracing/tsconfig.json index a60b75933..83511165b 100644 --- a/libs/jira-tracing/tsconfig.json +++ b/libs/jira-tracing/tsconfig.json @@ -1,110 +1,7 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "ES2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "commonjs" /* Specify what module code is generated. */, - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, - - /* Type Checking */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */, - "ignoreDeprecations": "6.0", "types": ["node"] - } + }, + "include": ["**/*.ts"] } diff --git a/tsconfig.base.json b/tsconfig.base.json index 8cae41cd9..5a8f29d1e 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -5,9 +5,7 @@ "composite": true, "declaration": true, "declarationMap": true, - "emitDecoratorMetadata": true, "esModuleInterop": true, - "experimentalDecorators": true, "forceConsistentCasingInFileNames": true, "importHelpers": true, "incremental": true,