Skip to content

Commit

Permalink
chore(website): upgrade typescript eslint and parser manually (#2445)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wellwelwel authored Feb 20, 2024
1 parent db13468 commit a7aecaa
Show file tree
Hide file tree
Showing 7 changed files with 1,662 additions and 1,575 deletions.
3,109 changes: 1,611 additions & 1,498 deletions website/package-lock.json

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"typecheck": "tsc",
"lintcheck": "prettier --check . && eslint . --ext .ts,.tsx",
"lint": "prettier --write . && eslint . --fix",
"test:unit": "npx tsx test/index.ts",
"test": "npm run typecheck && npm run lintcheck && npm run test:unit && npm run clear && npm run build"
"test:unit": "npx poku --parallel test/unit",
"test": "npm run typecheck && npm run lintcheck && npm run test:unit && npm run clear && npm run build",
"update": "npx npu; npm i; npm run lint"
},
"dependencies": {
"@docusaurus/core": "^3.1.1",
Expand All @@ -24,7 +25,7 @@
"@mdx-js/react": "^3.0.1",
"clsx": "^2.1.0",
"docusaurus-plugin-sass": "^0.2.5",
"lucide-react": "^0.323.0",
"lucide-react": "^0.334.0",
"prism-react-renderer": "^2.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -35,16 +36,17 @@
"@docusaurus/module-type-aliases": "^3.1.1",
"@docusaurus/tsconfig": "^3.1.1",
"@docusaurus/types": "^3.1.1",
"@types/node": "^20.11.16",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"eslint": "^8.56.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"packages-update": "^1.2.1",
"poku": "^1.3.1",
"prettier": "^3.2.5",
"tsx": "^4.7.1",
"typescript": "^5.3.3"
Expand Down
16 changes: 0 additions & 16 deletions website/test/index.ts

This file was deleted.

38 changes: 38 additions & 0 deletions website/test/unit/check-extensions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { EOL } from 'node:os';
import { listFiles, assert } from 'poku';

const invalidFiles: string[] = [];
const message = [
'Invalid file types found in restricted directories.',
'Please ensure that files in these directories have one of the following extensions:',
];

const checkExtensions = (
dirs: string[],
allowedExtensions: RegExp,
ignoreList: RegExp = /\.DS_Store/
) => {
dirs.forEach((dir) => {
const files = listFiles(dir, { filter: /\./ });

files.forEach((file) => {
if (!ignoreList.test(file) && !allowedExtensions.test(file)) {
invalidFiles.push(file);
message.push(`${EOL}${String(allowedExtensions)}`);
message.push(`- ${file}`);
}
});
});
};

checkExtensions(['docs', 'i18n'], /\.(mdx|json)$/);
checkExtensions(['helpers', 'plugins'], /\.ts$/);
checkExtensions(['test/unit', 'test/utils'], /\.test\.ts$/);
checkExtensions(['src/components', 'src/pages'], /\.tsx$/);
checkExtensions(['src/css'], /\.scss$/);

assert.deepStrictEqual(
invalidFiles.length,
0,
Array.from(new Set(message)).join(EOL)
);
48 changes: 0 additions & 48 deletions website/test/unit/check-extensions.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import fs from 'node:fs';
import path from 'node:path';
import { assert } from 'poku';
import {
extractMethodContent,
MethodType,
Expand All @@ -20,10 +21,8 @@ const checkResult = (methodName: string, methodType: MethodType) => {
path.resolve(`./test/fixtures/external-code-embed/${methodName}.txt`),
'utf-8'
) !== extractMethodContent(resource, methodName, methodType)
) {
console.log(`❌ ${methodName} example failed`);
process.exit(1);
}
)
assert.fail(`${methodName} example failed`);
};

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

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

0 comments on commit a7aecaa

Please sign in to comment.