From f06670a90995c216e65527b76280e8e3251a585b Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Fri, 12 Apr 2024 21:55:35 +0700 Subject: [PATCH] test: utilize new flat ESLint configuration (#294) * test: utilize new flat ESLint configuration * test: add TypeScript support to new flat ESLint config * test: fix `@typescript-eslint/consistent-indexed-object-style` lint issue --- .eslintrc.json | 10 ---------- .gitignore | 1 - eslint.config.js | 11 +++++++++++ package.json | 8 ++++---- src/inputs.test.ts | 6 +++--- yarn.lock | 31 +++++++++++++++++++++++++++---- 6 files changed, 45 insertions(+), 22 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.js diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index d16a061..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "root": true, - "extends": ["eslint:recommended"], - "overrides": [ - { - "files": ["**/*.ts"], - "extends": ["plugin:@typescript-eslint/recommended"] - } - ] -} diff --git a/.gitignore b/.gitignore index 6390aca..e9a5aaf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .* !.env.yarn -!.eslint* !.git* node_modules/ diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..99f3dcf --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,11 @@ +import eslint from "@eslint/js"; +import tseslint from "typescript-eslint"; + +export default [ + eslint.configs.recommended, + ...tseslint.configs.recommended, + ...tseslint.configs.stylistic, + { + ignores: [".*", "dist"], + }, +]; diff --git a/package.json b/package.json index 0bf8aad..416c70b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "ncc build src/index.ts", "format": "prettier --write --cache . !dist !README.md", - "lint": "eslint src", + "lint": "eslint .", "test": "jest" }, "dependencies": { @@ -13,17 +13,17 @@ "@actions/exec": "^1.1.1" }, "devDependencies": { + "@eslint/js": "^9.0.0", "@jest/globals": "^29.7.0", "@types/jest": "^29.5.12", "@types/node": "^20.11.30", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", "@vercel/ncc": "^0.38.1", "eslint": "^8.57.0", "jest": "^29.7.0", "prettier": "^3.2.5", "ts-jest": "^29.1.2", - "typescript": "^5.4.5" + "typescript": "^5.4.5", + "typescript-eslint": "^7.6.0" }, "packageManager": "yarn@4.1.1" } diff --git a/src/inputs.test.ts b/src/inputs.test.ts index ac127d9..39a3e17 100644 --- a/src/inputs.test.ts +++ b/src/inputs.test.ts @@ -11,9 +11,9 @@ jest.unstable_mockModule("@actions/core", () => ({ describe("get action inputs", () => { interface TestCase { name: string; - booleanInputs?: { [key: string]: boolean }; - stringInputs?: { [key: string]: string }; - multilineInputs?: { [key: string]: string[] }; + booleanInputs?: Record; + stringInputs?: Record; + multilineInputs?: Record; expectedInputs?: Partial; } diff --git a/yarn.lock b/yarn.lock index 8610991..ea03b6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -493,6 +493,13 @@ __metadata: languageName: node linkType: hard +"@eslint/js@npm:^9.0.0": + version: 9.0.0 + resolution: "@eslint/js@npm:9.0.0" + checksum: 10c0/ec3242a60a2525d2785d96d1e95b8060235f47f3b953aa81626968591ef8c1eb4f7f8b3647db2c97fdfa524eace949a5695be50521f64b8dcc4ed3b493ee409e + languageName: node + linkType: hard + "@fastify/busboy@npm:^2.0.0": version: 2.1.0 resolution: "@fastify/busboy@npm:2.1.0" @@ -1052,7 +1059,7 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^7.6.0": +"@typescript-eslint/eslint-plugin@npm:7.6.0": version: 7.6.0 resolution: "@typescript-eslint/eslint-plugin@npm:7.6.0" dependencies: @@ -1077,7 +1084,7 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/parser@npm:^7.6.0": +"@typescript-eslint/parser@npm:7.6.0": version: 7.6.0 resolution: "@typescript-eslint/parser@npm:7.6.0" dependencies: @@ -3866,17 +3873,17 @@ __metadata: dependencies: "@actions/core": "npm:^1.10.1" "@actions/exec": "npm:^1.1.1" + "@eslint/js": "npm:^9.0.0" "@jest/globals": "npm:^29.7.0" "@types/jest": "npm:^29.5.12" "@types/node": "npm:^20.11.30" - "@typescript-eslint/eslint-plugin": "npm:^7.6.0" - "@typescript-eslint/parser": "npm:^7.6.0" "@vercel/ncc": "npm:^0.38.1" eslint: "npm:^8.57.0" jest: "npm:^29.7.0" prettier: "npm:^3.2.5" ts-jest: "npm:^29.1.2" typescript: "npm:^5.4.5" + typescript-eslint: "npm:^7.6.0" languageName: unknown linkType: soft @@ -4276,6 +4283,22 @@ __metadata: languageName: node linkType: hard +"typescript-eslint@npm:^7.6.0": + version: 7.6.0 + resolution: "typescript-eslint@npm:7.6.0" + dependencies: + "@typescript-eslint/eslint-plugin": "npm:7.6.0" + "@typescript-eslint/parser": "npm:7.6.0" + "@typescript-eslint/utils": "npm:7.6.0" + peerDependencies: + eslint: ^8.56.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 10c0/1950ae59069860cc802de9c1c4f15013099b677b47cabc8dc24200dbe9a4a5a3db5ff9b88e6813658b089e16294d75835b6c17d13a445cf29c954a71eb27ff6f + languageName: node + linkType: hard + "typescript@npm:^5.4.5": version: 5.4.5 resolution: "typescript@npm:5.4.5"