Skip to content

Commit a7aecaa

Browse files
authored
chore(website): upgrade typescript eslint and parser manually (#2445)
* chore(website): upgrade eslint parser manually * chore(website): update test files to `.test.ts` * ci(website): simplify tests * ci(website): improve tests and its outputs
1 parent db13468 commit a7aecaa

File tree

7 files changed

+1662
-1575
lines changed

7 files changed

+1662
-1575
lines changed

website/package-lock.json

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

website/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"typecheck": "tsc",
1515
"lintcheck": "prettier --check . && eslint . --ext .ts,.tsx",
1616
"lint": "prettier --write . && eslint . --fix",
17-
"test:unit": "npx tsx test/index.ts",
18-
"test": "npm run typecheck && npm run lintcheck && npm run test:unit && npm run clear && npm run build"
17+
"test:unit": "npx poku --parallel test/unit",
18+
"test": "npm run typecheck && npm run lintcheck && npm run test:unit && npm run clear && npm run build",
19+
"update": "npx npu; npm i; npm run lint"
1920
},
2021
"dependencies": {
2122
"@docusaurus/core": "^3.1.1",
@@ -24,7 +25,7 @@
2425
"@mdx-js/react": "^3.0.1",
2526
"clsx": "^2.1.0",
2627
"docusaurus-plugin-sass": "^0.2.5",
27-
"lucide-react": "^0.323.0",
28+
"lucide-react": "^0.334.0",
2829
"prism-react-renderer": "^2.3.1",
2930
"react": "^18.2.0",
3031
"react-dom": "^18.2.0",
@@ -35,16 +36,17 @@
3536
"@docusaurus/module-type-aliases": "^3.1.1",
3637
"@docusaurus/tsconfig": "^3.1.1",
3738
"@docusaurus/types": "^3.1.1",
38-
"@types/node": "^20.11.16",
39-
"@typescript-eslint/eslint-plugin": "^6.21.0",
40-
"@typescript-eslint/parser": "^6.21.0",
39+
"@types/node": "^20.11.19",
40+
"@typescript-eslint/eslint-plugin": "^7.0.2",
41+
"@typescript-eslint/parser": "^7.0.2",
4142
"eslint": "^8.56.0",
4243
"eslint-import-resolver-typescript": "^3.6.1",
4344
"eslint-plugin-import": "^2.29.1",
4445
"eslint-plugin-react": "^7.33.2",
4546
"eslint-plugin-react-hooks": "^4.6.0",
4647
"eslint-plugin-react-refresh": "^0.4.5",
4748
"packages-update": "^1.2.1",
49+
"poku": "^1.3.1",
4850
"prettier": "^3.2.5",
4951
"tsx": "^4.7.1",
5052
"typescript": "^5.3.3"

website/test/index.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { EOL } from 'node:os';
2+
import { listFiles, assert } from 'poku';
3+
4+
const invalidFiles: string[] = [];
5+
const message = [
6+
'Invalid file types found in restricted directories.',
7+
'Please ensure that files in these directories have one of the following extensions:',
8+
];
9+
10+
const checkExtensions = (
11+
dirs: string[],
12+
allowedExtensions: RegExp,
13+
ignoreList: RegExp = /\.DS_Store/
14+
) => {
15+
dirs.forEach((dir) => {
16+
const files = listFiles(dir, { filter: /\./ });
17+
18+
files.forEach((file) => {
19+
if (!ignoreList.test(file) && !allowedExtensions.test(file)) {
20+
invalidFiles.push(file);
21+
message.push(`${EOL}${String(allowedExtensions)}`);
22+
message.push(`- ${file}`);
23+
}
24+
});
25+
});
26+
};
27+
28+
checkExtensions(['docs', 'i18n'], /\.(mdx|json)$/);
29+
checkExtensions(['helpers', 'plugins'], /\.ts$/);
30+
checkExtensions(['test/unit', 'test/utils'], /\.test\.ts$/);
31+
checkExtensions(['src/components', 'src/pages'], /\.tsx$/);
32+
checkExtensions(['src/css'], /\.scss$/);
33+
34+
assert.deepStrictEqual(
35+
invalidFiles.length,
36+
0,
37+
Array.from(new Set(message)).join(EOL)
38+
);

website/test/unit/check-extensions.ts

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

website/test/unit/external-code-embed.ts renamed to website/test/unit/external-code-embed.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import fs from 'node:fs';
66
import path from 'node:path';
7+
import { assert } from 'poku';
78
import {
89
extractMethodContent,
910
MethodType,
@@ -20,10 +21,8 @@ const checkResult = (methodName: string, methodType: MethodType) => {
2021
path.resolve(`./test/fixtures/external-code-embed/${methodName}.txt`),
2122
'utf-8'
2223
) !== extractMethodContent(resource, methodName, methodType)
23-
) {
24-
console.log(`❌ ${methodName} example failed`);
25-
process.exit(1);
26-
}
24+
)
25+
assert.fail(`${methodName} example failed`);
2726
};
2827

2928
// Valid methods
@@ -36,8 +35,7 @@ checkResult('handler', 'function');
3635

3736
// Invalid method
3837
if (resource !== extractMethodContent(resource, 'invalidMethod', 'function')) {
39-
console.log(
40-
`❌ Invalid method example failed. It should return the original content when it didn't find the requested method.`
38+
assert.fail(
39+
"Invalid method example failed. It should return the original content when it didn't find the requested method."
4140
);
42-
process.exit(1);
4341
}

0 commit comments

Comments
 (0)