From 851cb82f9c4071d245dbd6d822cd1008d11fc2c0 Mon Sep 17 00:00:00 2001 From: monkey0722 Date: Fri, 3 Jan 2025 11:32:30 +0900 Subject: [PATCH 1/3] refactor: remove redundant comments in Bellman-Ford search implementation --- algorithms/dp/{coinChange => coin-change}/coinChange.test.ts | 0 algorithms/dp/{coinChange => coin-change}/coinChange.ts | 0 algorithms/search/bellman-ford-search/bellmanFordSearch.ts | 2 -- 3 files changed, 2 deletions(-) rename algorithms/dp/{coinChange => coin-change}/coinChange.test.ts (100%) rename algorithms/dp/{coinChange => coin-change}/coinChange.ts (100%) diff --git a/algorithms/dp/coinChange/coinChange.test.ts b/algorithms/dp/coin-change/coinChange.test.ts similarity index 100% rename from algorithms/dp/coinChange/coinChange.test.ts rename to algorithms/dp/coin-change/coinChange.test.ts diff --git a/algorithms/dp/coinChange/coinChange.ts b/algorithms/dp/coin-change/coinChange.ts similarity index 100% rename from algorithms/dp/coinChange/coinChange.ts rename to algorithms/dp/coin-change/coinChange.ts diff --git a/algorithms/search/bellman-ford-search/bellmanFordSearch.ts b/algorithms/search/bellman-ford-search/bellmanFordSearch.ts index 88c1765..f1d03ce 100644 --- a/algorithms/search/bellman-ford-search/bellmanFordSearch.ts +++ b/algorithms/search/bellman-ford-search/bellmanFordSearch.ts @@ -16,10 +16,8 @@ export class BellmanFord { * @throws {Error} If the input parameters are invalid. */ static findShortestPaths(vertices: number, edges: Edge[], source: number): number[] | null { - // Validate input this.validateInput(vertices, edges, source); - // Initialize distances const distances = new Array(vertices).fill(Infinity); distances[source] = 0; From 69a35ae9fa46088b4af9f3fb61d9ecb750fbf034 Mon Sep 17 00:00:00 2001 From: monkey0722 Date: Fri, 3 Jan 2025 11:40:46 +0900 Subject: [PATCH 2/3] chore: update .gitignore, eslint config, and package.json for improved linting and TypeScript support --- .gitignore | 14 +++++++++----- eslint.config.js | 37 ++++++++++++++++++++----------------- package.json | 12 +++++------- tsconfig.json | 2 +- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 12507b1..e46cf05 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ -# npm yarn -/node_modules -/npm-debug.log -package-lock.json -yarn-*.log +# OSX +# +.DS_Store + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log diff --git a/eslint.config.js b/eslint.config.js index 4ad8df1..908af4f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,32 +1,35 @@ -const parser = require("@typescript-eslint/parser"); -const typescriptPlugin = require("@typescript-eslint/eslint-plugin"); +const parser = require('@typescript-eslint/parser'); +const typescriptPlugin = require('@typescript-eslint/eslint-plugin'); module.exports = [ { - files: ["**/*.ts"], + files: ['**/*.ts'], languageOptions: { parser: parser, parserOptions: { - sourceType: "module", - project: "./tsconfig.json", + sourceType: 'module', + project: './tsconfig.json', tsconfigRootDir: __dirname, }, }, plugins: { - "@typescript-eslint": typescriptPlugin, + '@typescript-eslint': typescriptPlugin, }, rules: { - "no-extra-semi": "off", - "no-irregular-whitespace": ["error", { skipTemplates: true }], - "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/no-useless-constructor": "error", - "@typescript-eslint/explicit-function-return-type": ["warn", { - allowExpressions: true, - allowTypedFunctionExpressions: true, - }], - "@typescript-eslint/no-floating-promises": "error", - "@typescript-eslint/await-thenable": "error", - "eqeqeq": ["error", "always", { null: "ignore" }], + 'no-extra-semi': 'off', + 'no-irregular-whitespace': ['error', {skipTemplates: true}], + '@typescript-eslint/no-unused-vars': 'error', + '@typescript-eslint/no-useless-constructor': 'error', + '@typescript-eslint/explicit-function-return-type': [ + 'warn', + { + allowExpressions: true, + allowTypedFunctionExpressions: true, + }, + ], + '@typescript-eslint/no-floating-promises': 'error', + '@typescript-eslint/await-thenable': 'error', + eqeqeq: ['error', 'always', {null: 'ignore'}], }, }, ]; diff --git a/package.json b/package.json index f60cc8b..fdf6f37 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,14 @@ { "name": "computer-science", "version": "1.0.0", - "description": "", + "description": "Computer Science in TypeScript", "main": "", "scripts": { "test": "jest", "typecheck": "tsc --noEmit --skipLibCheck", "lint": "eslint ./**/*.ts", "lint-fix": "eslint --fix ./**/*.ts", - "prettier": "prettier --write \"./**/*.{ts,tsx}\" --ignore-path \".gitignore\"" - }, - "dependencies": { - "typescript": "^5.7.2" + "prettier": "prettier --write './**/*.{js,ts,tsx}' --ignore-path '.gitignore'" }, "devDependencies": { "@types/jest": "^29.5.14", @@ -23,7 +20,8 @@ "lint-staged": "^15.2.11", "prettier": "^3.4.2", "ts-jest": "^29.2.5", - "ts-node": "^10.9.2" + "ts-node": "^10.9.2", + "typescript": "^5.7.2" }, "lint-staged": { "*.{ts,tsx}": [ @@ -34,7 +32,7 @@ }, "jest": { "transform": { - "^.+\\.tsx?$": "ts-jest" + "^.+\\.tsx?$": ["ts-jest", { "tsconfig": "tsconfig.json" }] } }, "repository": { diff --git a/tsconfig.json b/tsconfig.json index b6b9153..28d94a6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "NodeNext", - "target": "ES2023", + "target": "ESNext", "lib": ["ES2023", "DOM"], "sourceMap": true, "allowJs": true, From 90eb2a10b7d314a4d3e5311e9c159224f73669b4 Mon Sep 17 00:00:00 2001 From: monkey0722 Date: Fri, 3 Jan 2025 11:48:56 +0900 Subject: [PATCH 3/3] fix: update base path in tsconfig.json for correct module resolution --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 28d94a6..f5ab718 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,7 @@ "forceConsistentCasingInFileNames": true, "baseUrl": ".", "paths": { - "~": ["/"] + "~": ["./"] } }, "include": [