Skip to content

Commit 5d5f14d

Browse files
VIA-579 AJ Add supported browsers list to warn when using old apis
1 parent 7f8cfb1 commit 5d5f14d

File tree

5 files changed

+188
-54
lines changed

5 files changed

+188
-54
lines changed

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
/public/*
55
/scripts/*
66
/**/*.md
7-
/**/*.mjs
87
project.code-workspace
98
/**/.terraform/*
109
/package-lock.json

esbuild.config.mjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ const copyExtraFiles = async () => {
1414
// there is an issue with esbuild putting a warning for xhr-sync-worker.js file being external
1515
// at runtime, lambda complains that the file is not present
1616
// DOMPurify apparently depends on this file
17-
fs.copyFile("./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js", `${OUTPUT_DIR}/xhr-sync-worker.js`, (err) => {
18-
if (err) throw err;
19-
console.log("Copied xhr-sync-worker.js (workaround)");
20-
});
17+
fs.copyFile(
18+
"./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js",
19+
`${OUTPUT_DIR}/xhr-sync-worker.js`,
20+
(err) => {
21+
if (err) throw err;
22+
console.log("Copied xhr-sync-worker.js (workaround)");
23+
},
24+
);
2125
};
2226

2327
const buildLambda = async () => {
@@ -29,7 +33,7 @@ const buildLambda = async () => {
2933
jsx: "automatic",
3034
target: "node22",
3135
external: ["./xhr-sync-worker.js"],
32-
outfile: `${OUTPUT_DIR}/lambda.js`
36+
outfile: `${OUTPUT_DIR}/lambda.js`,
3337
});
3438
};
3539

eslint.config.mjs

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { FlatCompat } from "@eslint/eslintrc";
2+
import compat_plugin from "eslint-plugin-compat";
13
import { dirname } from "path";
24
import { fileURLToPath } from "url";
3-
import { FlatCompat } from "@eslint/eslintrc";
45

56
const __filename = fileURLToPath(import.meta.url);
67
const __dirname = dirname(__filename);
@@ -9,32 +10,45 @@ const compat = new FlatCompat({
910
baseDirectory: __dirname,
1011
});
1112

12-
const eslintConfig = [{
13-
ignores: [
14-
"node_modules/**",
15-
".next/**",
16-
"out/**",
17-
"build/**",
18-
"next-env.d.ts",
19-
"public/**",
20-
"dist/**",
21-
"docs/**",
22-
"coverage/**",
23-
"**/.terraform/**",
24-
".open-next/**",
25-
"playwright-report/**",
26-
"pact/**",
27-
"performance/report",
28-
]
29-
}, ...compat.extends(
30-
"next/core-web-vitals",
31-
"next/typescript",
32-
"prettier",
33-
"next",
34-
), {
35-
"rules": {
36-
"@typescript-eslint/no-unused-vars": "error",
37-
}
38-
}];
13+
const eslintConfig = [
14+
{
15+
ignores: [
16+
"node_modules/**",
17+
".next/**",
18+
"out/**",
19+
"build/**",
20+
"next-env.d.ts",
21+
"public/**",
22+
"dist/**",
23+
"docs/**",
24+
"coverage/**",
25+
"**/.terraform/**",
26+
".open-next/**",
27+
"playwright-report/**",
28+
"pact/**",
29+
"performance/report",
30+
],
31+
},
32+
...compat.extends("next/core-web-vitals", "next/typescript", "prettier", "next"),
33+
compat_plugin.configs["flat/recommended"],
34+
{
35+
rules: {
36+
"@typescript-eslint/no-unused-vars": "error",
37+
38+
// nhsuk-frontend: https://github.com/nhsuk/nhsuk-frontend/blob/main/docs/contributing/browser-support.md
39+
// Ref: https://github.com/nhsuk/nhsuk-frontend/blob/main/packages/nhsuk-frontend/.browserslistrc
40+
// supported browsers are listed in package.json
41+
"compat/compat": "warn",
42+
},
43+
},
44+
45+
// Override for test files: turn off compat
46+
{
47+
files: ["**/*.test.{js,jsx,ts,tsx}", "**/*.spec.{js,jsx,ts,tsx}", "test-data/**"],
48+
rules: {
49+
"compat/compat": "off",
50+
},
51+
},
52+
];
3953

4054
export default eslintConfig;

package-lock.json

Lines changed: 124 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88
"doc": "docs",
99
"test": "tests"
1010
},
11+
"browserslist": [
12+
"> 0.1% in GB and not dead",
13+
"last 6 Chrome versions",
14+
"last 6 Firefox versions",
15+
"last 6 Edge versions",
16+
"last 2 Samsung versions",
17+
"Firefox ESR",
18+
"Safari >= 11",
19+
"iOS >= 11",
20+
"IE 11"
21+
],
1122
"scripts": {
1223
"dev": "next dev --turbopack --experimental-https",
1324
"app": "npm run build && npm run start",
@@ -56,10 +67,12 @@
5667
"@types/node": "^24.10.1",
5768
"@types/react": "^19.2.7",
5869
"@types/react-dom": "^19.2.3",
70+
"es-check": "^9.5.2",
5971
"esbuild": "0.27.1",
6072
"eslint": "^9.39.1",
6173
"eslint-config-next": "15.5.7",
6274
"eslint-config-prettier": "^10.1.8",
75+
"eslint-plugin-compat": "^6.0.2",
6376
"jest": "^30.2.0",
6477
"jest-environment-jsdom": "^30.2.0",
6578
"jest-pact": "^0.13.0",

0 commit comments

Comments
 (0)