Skip to content

Commit a2b3340

Browse files
committed
chore: upgrade all deps, migrate to ESLint v9
1 parent cb541de commit a2b3340

34 files changed

+955
-1071
lines changed

.eslintignore

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

.eslintrc.json

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

eslint.config.mjs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import eslint from "@eslint/js";
2+
import vitest from "@vitest/eslint-plugin";
3+
import tseslint from "typescript-eslint";
4+
import globals from "globals";
5+
6+
const config = tseslint.config(
7+
{
8+
name: "argos/global-ignores",
9+
ignores: ["**/dist", "examples", "docs"],
10+
},
11+
{
12+
name: "argos/globals",
13+
languageOptions: {
14+
globals: {
15+
...globals.node,
16+
},
17+
},
18+
},
19+
eslint.configs.recommended,
20+
...tseslint.configs.recommended,
21+
{
22+
name: "argos/custom-ts-rules",
23+
rules: {
24+
curly: "error",
25+
"@typescript-eslint/no-explicit-any": "off",
26+
"@typescript-eslint/consistent-type-imports": "error",
27+
"@typescript-eslint/no-unused-vars": [
28+
"error",
29+
{
30+
varsIgnorePattern: "^_",
31+
},
32+
],
33+
},
34+
},
35+
{
36+
name: "argos/cjs",
37+
files: ["**/*.c[tj]s"],
38+
rules: {
39+
"@typescript-eslint/no-require-imports": "off",
40+
},
41+
},
42+
{
43+
name: "argos/jest",
44+
files: ["**/*.spec.[tj]s"],
45+
languageOptions: {
46+
globals: {
47+
...globals.jest,
48+
},
49+
},
50+
},
51+
{
52+
name: "argos/vitest",
53+
files: ["**/*.test.?(m)[tj]s"],
54+
plugins: {
55+
vitest,
56+
},
57+
rules: {
58+
...vitest.configs.recommended.rules,
59+
},
60+
},
61+
);
62+
63+
export default config;

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
"devDependencies": {
55
"@commitlint/cli": "^19.6.1",
66
"@commitlint/config-conventional": "^19.6.0",
7+
"@eslint/js": "^9.18.0",
8+
"@vitest/eslint-plugin": "^1.1.25",
79
"cross-env": "^7.0.3",
8-
"eslint": "^8.57.1",
10+
"eslint": "^9.18.0",
11+
"globals": "^15.14.0",
912
"lerna": "^8.1.9",
1013
"prettier": "^3.4.2",
1114
"tsup": "^8.3.5",
1215
"typedoc": "^0.27.6",
1316
"typescript": "5.7.3",
14-
"vitest": "^2.1.8"
17+
"typescript-eslint": "^8.20.0",
18+
"vitest": "^3.0.2"
1519
},
1620
"scripts": {
1721
"build": "cross-env NODE_ENV=production pnpm -r run build",

packages/browser/src/global/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import type {
2+
SetupOptions,
3+
TeardownOptions,
4+
StabilizationOptions,
5+
} from "./stabilization";
16
import {
27
checkIsStable,
38
setup,
49
teardown,
5-
SetupOptions,
6-
TeardownOptions,
7-
StabilizationOptions,
810
getStabilityFailureReasons,
911
} from "./stabilization";
1012
import { getColorScheme, getMediaType } from "./media";

packages/browser/src/global/stabilization.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ const SPELL_CHECK_QUERY =
5959
function disableSpellCheck(document: Document) {
6060
const inputs = document.querySelectorAll(SPELL_CHECK_QUERY);
6161
inputs.forEach((element) => {
62-
if (!checkIsHTMLElement(element)) return;
62+
if (!checkIsHTMLElement(element)) {
63+
return;
64+
}
6365
setAndBackupSpellcheck(element, "false");
6466
});
6567
}
@@ -129,11 +131,17 @@ function setAndBackupPosition(element: HTMLElement, position: string) {
129131
*/
130132
function stabilizeElementPositions(document: Document) {
131133
const window = document.defaultView;
132-
if (!window) return;
134+
if (!window) {
135+
return;
136+
}
133137
const elements = Array.from(document.querySelectorAll("*"));
134138
elements.forEach((element) => {
135-
if (!checkIsHTMLElement(element)) return;
136-
if (element.tagName === "IFRAME") return;
139+
if (!checkIsHTMLElement(element)) {
140+
return;
141+
}
142+
if (element.tagName === "IFRAME") {
143+
return;
144+
}
137145
const style = window.getComputedStyle(element);
138146
const position = style.position;
139147
if (position === "fixed") {
@@ -149,10 +157,14 @@ function stabilizeElementPositions(document: Document) {
149157
*/
150158
function restoreElementPositions(document: Document) {
151159
const window = document.defaultView;
152-
if (!window) return;
160+
if (!window) {
161+
return;
162+
}
153163
const elements = Array.from(document.querySelectorAll("*"));
154164
elements.forEach((element) => {
155-
if (!checkIsHTMLElement(element)) return;
165+
if (!checkIsHTMLElement(element)) {
166+
return;
167+
}
156168
const position = element.getAttribute("data-argos-bck-position");
157169
if (position === "unset") {
158170
element.style.removeProperty("position");

packages/cli/src/commands/finalize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ora from "ora";
2-
import { Command } from "commander";
2+
import type { Command } from "commander";
33
import { finalize } from "@argos-ci/core";
44
import { parallelNonce } from "../options";
55

packages/cli/src/commands/upload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Command, Option } from "commander";
1+
import type { Command } from "commander";
2+
import { Option } from "commander";
23
import { upload } from "@argos-ci/core";
34
import ora from "ora";
45
import { parallelNonce } from "../options";

packages/core/src/ci-environment/services/github-actions.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Service, Context } from "../types";
33
import axios from "axios";
44
import { debug } from "../../debug";
55
import { getMergeBaseCommitSha, listParentCommits } from "../git";
6-
import * as webhooks from "@octokit/webhooks";
6+
import type * as webhooks from "@octokit/webhooks";
77

88
type EventPayload = webhooks.EmitterWebhookEvent["payload"];
99

@@ -114,13 +114,19 @@ function getBranchFromPayload(payload: EventPayload): string | null {
114114
}
115115

116116
function getRepositoryFromContext({ env }: Context): string | null {
117-
if (!env.GITHUB_REPOSITORY) return null;
117+
if (!env.GITHUB_REPOSITORY) {
118+
return null;
119+
}
118120
return env.GITHUB_REPOSITORY.split("/")[1] || null;
119121
}
120122

121123
function readEventPayload({ env }: Context): EventPayload | null {
122-
if (!env.GITHUB_EVENT_PATH) return null;
123-
if (!existsSync(env.GITHUB_EVENT_PATH)) return null;
124+
if (!env.GITHUB_EVENT_PATH) {
125+
return null;
126+
}
127+
if (!existsSync(env.GITHUB_EVENT_PATH)) {
128+
return null;
129+
}
124130
return JSON.parse(readFileSync(env.GITHUB_EVENT_PATH, "utf-8"));
125131
}
126132

@@ -184,7 +190,7 @@ const service: Service = {
184190
runAttempt: env.GITHUB_RUN_ATTEMPT
185191
? Number(env.GITHUB_RUN_ATTEMPT)
186192
: null,
187-
nonce: `${env.GITHUB_RUN_ID}-${env.GITHUB_RUN_ATTEMPT}` || null,
193+
nonce: `${env.GITHUB_RUN_ID}-${env.GITHUB_RUN_ATTEMPT}`,
188194
branch:
189195
getBranchFromContext(context) ||
190196
pullRequest?.head.ref ||

packages/core/src/ci-environment/services/travis.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@ import type { Context, Service } from "../types";
22
import { getMergeBaseCommitSha, listParentCommits } from "../git";
33

44
const getOwner = ({ env }: Context) => {
5-
if (!env.TRAVIS_REPO_SLUG) return null;
5+
if (!env.TRAVIS_REPO_SLUG) {
6+
return null;
7+
}
68
return env.TRAVIS_REPO_SLUG.split("/")[0] || null;
79
};
810

911
const getRepository = ({ env }: Context) => {
10-
if (!env.TRAVIS_REPO_SLUG) return null;
12+
if (!env.TRAVIS_REPO_SLUG) {
13+
return null;
14+
}
1115
return env.TRAVIS_REPO_SLUG.split("/")[1] || null;
1216
};
1317

1418
const getPrNumber = ({ env }: Context) => {
15-
if (env.TRAVIS_PULL_REQUEST) return Number(env.TRAVIS_PULL_REQUEST);
19+
if (env.TRAVIS_PULL_REQUEST) {
20+
return Number(env.TRAVIS_PULL_REQUEST);
21+
}
1622
return null;
1723
};
1824

packages/core/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getCiEnvironment } from "./ci-environment";
33

44
const mustBeApiBaseUrl = (value: any) => {
55
const URL_REGEX =
6-
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
6+
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
77

88
if (!URL_REGEX.test(value)) {
99
throw new Error("Invalid Argos API base URL");

packages/core/src/optimize.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const exists = async (filepath: string) => {
99
try {
1010
await stat(filepath);
1111
return true;
12-
} catch (error) {
12+
} catch {
1313
return false;
1414
}
1515
};

packages/core/src/s3.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable vitest/expect-expect */
12
import { describe, it } from "vitest";
23
import { join } from "node:path";
34
// import { fileURLToPath } from "node:url";

packages/core/src/upload.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import {
2-
ArgosAPISchema,
3-
createClient,
4-
throwAPIError,
5-
} from "@argos-ci/api-client";
1+
import type { ArgosAPISchema } from "@argos-ci/api-client";
2+
import { createClient, throwAPIError } from "@argos-ci/api-client";
63
import { readConfig } from "./config";
74
import { discoverScreenshots } from "./discovery";
85
import { optimizeScreenshot } from "./optimize";

packages/core/src/util/chunk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export const chunk = <T>(collection: T[], size: number) => {
66

77
// add each chunk to the result
88
for (let x = 0; x < Math.ceil(collection.length / size); x++) {
9-
let start = x * size;
10-
let end = start + size;
9+
const start = x * size;
10+
const end = start + size;
1111

1212
result.push(collection.slice(start, end));
1313
}

packages/cypress/.eslintrc.json

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

packages/cypress/eslint.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pluginCypress from "eslint-plugin-cypress/flat";
2+
import rootConfig from "../../eslint.config.mjs";
3+
4+
export default [
5+
...rootConfig,
6+
{
7+
plugins: {
8+
cypress: pluginCypress,
9+
},
10+
rules: {
11+
"cypress/unsafe-to-chain-command": "error",
12+
},
13+
},
14+
];

packages/cypress/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@
5757
"@argos-ci/cli": "workspace:*",
5858
"@argos-ci/cypress": "workspace:.",
5959
"@types/node": "^18.19.44",
60-
"cypress": "^13.17.0",
61-
"eslint-plugin-cypress": "^3.5.0",
62-
"eslint-plugin-html": "^8.1.1"
60+
"cypress": "^14.0.0",
61+
"eslint-plugin-cypress": "^4.1.0"
6362
},
6463
"scripts": {
6564
"build": "tsup",

packages/cypress/src/support.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
type ScreenshotMetadata,
1313
validateThreshold,
1414
} from "@argos-ci/util/browser";
15-
// @ts-ignore
15+
// @ts-expect-error - can't import json in TypeScript
1616
import { version } from "../package.json";
1717

1818
type ArgosScreenshotOptions = Partial<
@@ -72,7 +72,9 @@ declare global {
7272

7373
function injectArgos() {
7474
cy.window({ log: false }).then((window) => {
75-
if (typeof (window as any).__ARGOS__ !== "undefined") return;
75+
if (typeof (window as any).__ARGOS__ !== "undefined") {
76+
return;
77+
}
7678
window.eval(getGlobalScript());
7779
});
7880
}
@@ -101,7 +103,7 @@ Cypress.Commands.add(
101103
(subject, name, options = {}) => {
102104
const {
103105
viewports,
104-
argosCSS,
106+
argosCSS: _argosCSS,
105107
stabilize = true,
106108
...cypressOptions
107109
} = options;
@@ -147,7 +149,7 @@ Cypress.Commands.add(
147149
);
148150
}
149151

150-
let ref: any = {};
152+
const ref: any = {};
151153

152154
cy.wrap(subject).screenshot(name, {
153155
blackout: ['[data-visual-test="blackout"]'].concat(
@@ -179,7 +181,7 @@ Cypress.Commands.add(
179181
title: Cypress.currentTest.title,
180182
titlePath: Cypress.currentTest.titlePath,
181183
retry: Cypress.currentRetry,
182-
// @ts-ignore
184+
// @ts-expect-error - private property
183185
retries: cy.state("runnable")._retries,
184186
},
185187
browser: {

packages/gitlab/src/statuses.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ArgosAPIClient, createClient } from "@argos-ci/api-client";
1+
import type { ArgosAPIClient } from "@argos-ci/api-client";
2+
import { createClient } from "@argos-ci/api-client";
23
import { Gitlab } from "@gitbeaker/rest";
34

45
type GitlabAPIClient = InstanceType<typeof Gitlab>;

0 commit comments

Comments
 (0)