Skip to content

Commit 5a512fa

Browse files
committed
chore: update linting configuration to eslint 9
fixup CI scripts
1 parent 7f8653e commit 5a512fa

27 files changed

+700
-557
lines changed

.eslintignore

-3
This file was deleted.

.eslintrc.js

-31
This file was deleted.

.github/workflows/ci.yml

+25-26
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ jobs:
1515
pnpm-cache: ${{ steps.vars.outputs.pnpm-cache }}
1616
key: ${{ steps.vars.outputs.key }}
1717
steps:
18-
- uses: actions/checkout@v3
19-
- uses: pnpm/action-setup@v2.2.4
20-
- uses: actions/setup-node@v3
18+
- uses: actions/checkout@v4
19+
- uses: pnpm/action-setup@v3
20+
- uses: actions/setup-node@v4
2121
with:
22-
node-version: "18.x"
22+
node-version-file: '.nvmrc'
2323
- id: vars
2424
run: |
2525
echo "pnpm-cache=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
2626
echo "key=${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT
2727
- name: Cache NPM and Cypress 📦
28-
uses: actions/cache@v3
28+
uses: actions/cache@v4
2929
id: cache
3030
with:
3131
path: |
@@ -44,13 +44,13 @@ jobs:
4444
runs-on: ubuntu-latest
4545
needs: cache
4646
steps:
47-
- uses: actions/checkout@v3
48-
- uses: pnpm/action-setup@v2.2.4
49-
- uses: actions/setup-node@v3
47+
- uses: actions/checkout@v4
48+
- uses: pnpm/action-setup@v3
49+
- uses: actions/setup-node@v4
5050
with:
51-
node-version: "18.x"
51+
node-version-file: '.nvmrc'
5252
- name: Cache NPM and Cypress 📦
53-
uses: actions/cache@v3
53+
uses: actions/cache@v4
5454
id: cache
5555
with:
5656
path: |
@@ -71,13 +71,13 @@ jobs:
7171
runs-on: ubuntu-latest
7272
needs: cache
7373
steps:
74-
- uses: actions/checkout@v3
75-
- uses: pnpm/action-setup@v2.2.4
76-
- uses: actions/setup-node@v3
74+
- uses: actions/checkout@v4
75+
- uses: pnpm/action-setup@v3
76+
- uses: actions/setup-node@v4
7777
with:
78-
node-version: "18.x"
78+
node-version-file: '.nvmrc'
7979
- name: Cache NPM and Cypress 📦
80-
uses: actions/cache@v3
80+
uses: actions/cache@v4
8181
id: cache
8282
with:
8383
path: |
@@ -108,13 +108,13 @@ jobs:
108108
runs-on: ubuntu-latest
109109
needs: cache
110110
steps:
111-
- uses: actions/checkout@v3
112-
- uses: pnpm/action-setup@v2.2.4
113-
- uses: actions/setup-node@v3
111+
- uses: actions/checkout@v4
112+
- uses: pnpm/action-setup@v3
113+
- uses: actions/setup-node@v4
114114
with:
115-
node-version: "18.x"
115+
node-version-file: '.nvmrc'
116116
- name: Cache NPM and Cypress 📦
117-
uses: actions/cache@v3
117+
uses: actions/cache@v4
118118
id: cache
119119
with:
120120
path: |
@@ -165,15 +165,14 @@ jobs:
165165
needs: [cache, prepare-release]
166166
if: needs.prepare-release.outputs.releases_created
167167
steps:
168-
- uses: actions/checkout@v3
169-
- uses: pnpm/action-setup@v2.2.4
170-
- uses: actions/setup-node@v3
168+
- uses: actions/checkout@v4
169+
- uses: pnpm/action-setup@v3
170+
- uses: actions/setup-node@v4
171171
with:
172-
node-version: "18.x"
172+
node-version-file: '.nvmrc'
173173
registry-url: 'https://registry.npmjs.org'
174-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
175174
- name: Cache NPM and Cypress 📦
176-
uses: actions/cache@v3
175+
uses: actions/cache@v4
177176
id: cache
178177
with:
179178
path: |

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.17.0

.prettierignore

-7
This file was deleted.

eslint.config.mjs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { typescript, javascript } from '@frsource/eslint-config';
2+
import globals from 'globals';
3+
import cypress from 'eslint-plugin-cypress/flat'
4+
5+
/** @type {import("eslint").Linter.Config[]} */
6+
export default [
7+
...javascript,
8+
...typescript,
9+
{ ignores: ['**/dist', '**/coverage', '**/node_modules'] },
10+
{ rules: { '@typescript-eslint/no-invalid-void-type': 'off' } },
11+
{
12+
plugins: { cypress },
13+
files: ['examples/*/cypress/**', 'packages/*/src/**'],
14+
languageOptions: {
15+
globals: {
16+
...globals.es2021,
17+
...globals.node,
18+
...cypress.globals,
19+
},
20+
},
21+
},
22+
];

package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@
2727
"cypress": ">=4.5.0"
2828
},
2929
"devDependencies": {
30-
"@typescript-eslint/eslint-plugin": "7.14.1",
31-
"@typescript-eslint/parser": "7.14.1",
32-
"eslint": "9.6.0",
33-
"eslint-config-prettier": "9.1.0",
34-
"eslint-plugin-cypress": "3.3.0",
35-
"eslint-plugin-eslint-comments": "3.2.0"
30+
"@frsource/eslint-config": "1.15.0",
31+
"eslint": "9.10.0",
32+
"eslint-plugin-cypress": "^3.5.0",
33+
"globals": "15.9.0"
3634
}
3735
}

packages/cypress-plugin-visual-regression-diff/.eslintignore

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
node_modules
2-
dist
2+
**/node_modules
3+
**/coverage
34
coverage
5+
**/dist
6+
pnpm-lock.yaml
47
CHANGELOG.md
5-
.yarnrc.yml
6-
example/.yarnrc.yml
7-
.yarn
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
describe("Cleanup test", () => {
2-
it("Create screenshot to be removed", () => {
3-
cy.visit("/");
1+
describe('Cleanup test', () => {
2+
it('Create screenshot to be removed', () => {
3+
cy.visit('/');
44
cy.get('[data-testid="description"]').matchImage();
55
});
66
});
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { vi } from "vitest";
2-
import { promises as fs } from "fs";
1+
import { vi } from 'vitest';
2+
import { promises as fs } from 'fs';
33

44
export const Cypress = {
55
Promise,
66
};
7-
vi.stubGlobal("Cypress", Cypress);
7+
vi.stubGlobal('Cypress', Cypress);
88

99
export const cy = {
1010
readFile: vi.fn(fs.readFile),
1111
};
12-
vi.stubGlobal("cy", cy);
12+
vi.stubGlobal('cy', cy);
1313

1414
export const before = vi.fn();
15-
vi.stubGlobal("before", before);
15+
vi.stubGlobal('before', before);
1616

1717
export const after = vi.fn();
18-
vi.stubGlobal("after", after);
18+
vi.stubGlobal('after', after);

packages/cypress-plugin-visual-regression-diff/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"cypress": ">=4.5.0"
6565
},
6666
"devDependencies": {
67+
"@frsource/prettier-config": "^1.11.0",
6768
"@types/glob": "8.1.0",
6869
"@types/pixelmatch": "5.2.6",
6970
"@types/pngjs": "6.0.4",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '@frsource/prettier-config';
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { it, expect, describe } from "vitest";
2-
import path from "path";
3-
import { promises as fs, existsSync } from "fs";
1+
import { it, expect, describe } from 'vitest';
2+
import path from 'path';
3+
import { promises as fs, existsSync } from 'fs';
44
import {
55
initAfterScreenshotHook,
66
parseAbsolutePath,
7-
} from "./afterScreenshot.hook";
8-
import { dir, file, setGracefulCleanup } from "tmp-promise";
9-
import { IMAGE_SNAPSHOT_PREFIX, PATH_VARIABLES } from "./constants";
7+
} from './afterScreenshot.hook';
8+
import { dir, file, setGracefulCleanup } from 'tmp-promise';
9+
import { IMAGE_SNAPSHOT_PREFIX, PATH_VARIABLES } from './constants';
1010

1111
setGracefulCleanup();
1212

13-
describe("initAfterScreenshotHook", () => {
14-
it("move file and remove old directories", async () => {
13+
describe('initAfterScreenshotHook', () => {
14+
it('move file and remove old directories', async () => {
1515
const { path: screenshotsFolder } = await dir();
1616
const imagesFolder = path.join(screenshotsFolder, IMAGE_SNAPSHOT_PREFIX);
1717
await fs.mkdir(imagesFolder);
@@ -22,11 +22,11 @@ describe("initAfterScreenshotHook", () => {
2222
screenshotsFolder,
2323
projectRoot,
2424
} as Cypress.PluginConfigOptions)({
25-
name: IMAGE_SNAPSHOT_PREFIX + path.sep + "some_name",
25+
name: IMAGE_SNAPSHOT_PREFIX + path.sep + 'some_name',
2626
path: imgPath,
2727
} as Cypress.ScreenshotDetails);
2828

29-
const expectedNewPath = path.join(projectRoot, "some_name");
29+
const expectedNewPath = path.join(projectRoot, 'some_name');
3030
expect(existsSync(imagesFolder)).toBe(false);
3131
expect(existsSync(imgPath)).toBe(false);
3232
expect(existsSync(expectedNewPath)).toBe(true);
@@ -35,32 +35,32 @@ describe("initAfterScreenshotHook", () => {
3535
});
3636
});
3737

38-
describe("parseAbsolutePath", () => {
39-
const projectRoot = "/its/project/root";
38+
describe('parseAbsolutePath', () => {
39+
const projectRoot = '/its/project/root';
4040

41-
it("resolves relative paths against project root", () => {
41+
it('resolves relative paths against project root', () => {
4242
expect(
43-
parseAbsolutePath({ screenshotPath: "some/path.png", projectRoot })
44-
).toBe("/its/project/root/some/path.png");
43+
parseAbsolutePath({ screenshotPath: 'some/path.png', projectRoot }),
44+
).toBe('/its/project/root/some/path.png');
4545
});
4646

47-
it("builds proper win paths when found", () => {
47+
it('builds proper win paths when found', () => {
4848
expect(
4949
parseAbsolutePath({
5050
screenshotPath: `${PATH_VARIABLES.winSystemRootPath}/D/some/path.png`,
5151
projectRoot,
52-
})
52+
}),
5353
)
5454
// that's expected output accorind to https://stackoverflow.com/a/64135721/8805801
55-
.toBe("D:\\/some/path.png");
55+
.toBe('D:\\/some/path.png');
5656
});
5757

58-
it("resolves relative paths against project root", () => {
58+
it('resolves relative paths against project root', () => {
5959
expect(
6060
parseAbsolutePath({
6161
screenshotPath: `${PATH_VARIABLES.unixSystemRootPath}/some/path.png`,
6262
projectRoot,
63-
})
64-
).toBe("/some/path.png");
63+
}),
64+
).toBe('/some/path.png');
6565
});
6666
});

packages/cypress-plugin-visual-regression-diff/src/afterScreenshot.hook.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import path from "path";
2-
import { promises as fs } from "fs";
3-
import moveFile from "move-file";
4-
import { IMAGE_SNAPSHOT_PREFIX, PATH_VARIABLES } from "./constants";
1+
import path from 'path';
2+
import { promises as fs } from 'fs';
3+
import moveFile from 'move-file';
4+
import { IMAGE_SNAPSHOT_PREFIX, PATH_VARIABLES } from './constants';
55

66
type NotFalsy<T> = T extends false | null | undefined ? never : T;
77

88
const MIMIC_ROOT_WIN_REGEX = new RegExp(
9-
`^${PATH_VARIABLES.winSystemRootPath}\\${path.sep}([A-Z])\\${path.sep}`
9+
`^${PATH_VARIABLES.winSystemRootPath}\\${path.sep}([A-Z])\\${path.sep}`,
1010
);
1111
const MIMIC_ROOT_UNIX_REGEX = new RegExp(
12-
`^${PATH_VARIABLES.unixSystemRootPath}\\${path.sep}`
12+
`^${PATH_VARIABLES.unixSystemRootPath}\\${path.sep}`,
1313
);
1414

1515
const getConfigVariableOrThrow = <K extends keyof Cypress.PluginConfigOptions>(
1616
config: Cypress.PluginConfigOptions,
17-
name: K
17+
name: K,
1818
) => {
1919
if (config[name]) {
2020
return config[name] as NotFalsy<Cypress.PluginConfigOptions[K]>;
@@ -39,7 +39,7 @@ export const parseAbsolutePath = ({
3939
const driveLetter = matchedMimicingWinRoot[1];
4040
newAbsolutePath = path.join(
4141
`${driveLetter}:\\`,
42-
screenshotPath.substring(matchedMimicingWinRoot[0].length)
42+
screenshotPath.substring(matchedMimicingWinRoot[0].length),
4343
);
4444
} else if (matchedMimicingUnixRoot) {
4545
newAbsolutePath =
@@ -53,7 +53,7 @@ export const parseAbsolutePath = ({
5353
export const initAfterScreenshotHook =
5454
(config: Cypress.PluginConfigOptions) =>
5555
(
56-
details: Cypress.ScreenshotDetails
56+
details: Cypress.ScreenshotDetails,
5757
):
5858
| void
5959
| Cypress.AfterScreenshotReturnObject
@@ -64,10 +64,10 @@ export const initAfterScreenshotHook =
6464
/* c8 ignore stop */
6565
const screenshotsFolder = getConfigVariableOrThrow(
6666
config,
67-
"screenshotsFolder"
67+
'screenshotsFolder',
6868
);
6969
const screenshotPath = details.name.substring(
70-
IMAGE_SNAPSHOT_PREFIX.length + path.sep.length
70+
IMAGE_SNAPSHOT_PREFIX.length + path.sep.length,
7171
);
7272
const newAbsolutePath = parseAbsolutePath({
7373
screenshotPath,

0 commit comments

Comments
 (0)