From 4d41c3960032ddab738882bc8badcb8a80303d95 Mon Sep 17 00:00:00 2001 From: Chemi Atlow Date: Mon, 15 Jul 2024 08:08:23 +0200 Subject: [PATCH] set type to module (#11) --- .eslintrc.cjs | 16 ++++++++ package.json | 5 ++- src/index.ts | 8 ++-- src/junitParser.ts | 4 +- src/messageBuilder.ts | 6 +-- src/utils.ts | 2 +- tsconfig.json | 2 + yarn.lock | 85 ++++++++++++++++++++++++++++++++++++++++--- 8 files changed, 111 insertions(+), 17 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 2b9ed57..179ead6 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -11,6 +11,7 @@ module.exports = { 'filenames/match-regex': 'off', 'sort-imports': 'off', 'eslint-comments/no-use': 'off', + 'import/extensions': ['error', 'always'], 'import/no-namespace': 'off', 'no-unused-vars': 'off', 'i18n-text/no-en': 'off', @@ -51,4 +52,19 @@ module.exports = { node: true, es6: true, }, + settings: { + 'import/extensions': ['.js', '.ts'], + 'import/parsers': { + '@typescript-eslint/parser': ['.ts'], + }, + 'import/resolver': { + node: { + extensions: ['.js', '.ts'], + extensionAlias: { + '.js': ['.ts'], + '.ts': ['.js'], + } + }, + }, + }, }; diff --git a/package.json b/package.json index 9189168..3f8625a 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "main": "lib/index.js", "author": "atlowChemi ", "license": "MIT", + "type": "module", "scripts": { "type-check": "tsc --noEmit", "build": "esbuild src/index.ts --bundle --platform=node --target=node20 --outfile=lib/index.js --sourcemap", @@ -40,11 +41,11 @@ }, "devDependencies": { "@types/node": "20", - "@typescript-eslint/parser": "^5.52.0", + "@typescript-eslint/parser": "^7.16.0", "esbuild": "^0.23.0", "eslint": "^8.34.0", "eslint-plugin-github": "^4.6.1", "prettier": "^2.8.4", - "typescript": "^4.9.5" + "typescript": "5.3" } } diff --git a/src/index.ts b/src/index.ts index 7e9d747..d677bdf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ -import 'source-map-support/register'; +import 'source-map-support/register.js'; import * as core from '@actions/core'; -import { parseInputs } from './inputParser'; -import { getTestReports } from './junitParser'; -import { publishAnnotations, publishCommentOnPullRequest } from './messageBuilder'; +import { parseInputs } from './inputParser.ts'; +import { getTestReports } from './junitParser.ts'; +import { publishAnnotations, publishCommentOnPullRequest } from './messageBuilder.ts'; export async function run(): Promise { try { diff --git a/src/junitParser.ts b/src/junitParser.ts index 64e4d73..4c39abd 100644 --- a/src/junitParser.ts +++ b/src/junitParser.ts @@ -3,8 +3,8 @@ import * as core from '@actions/core'; import * as glob from '@actions/glob'; import * as github from '@actions/github'; import { XMLParser } from 'fast-xml-parser'; -import { escapeEmoji, retrieve, castArray, parseTestimFailureMessage, getTestStatusesFromPublicAPI } from './utils'; -import type { parseInputs } from './inputParser'; +import { escapeEmoji, retrieve, castArray, parseTestimFailureMessage, getTestStatusesFromPublicAPI } from './utils.ts'; +import type { parseInputs } from './inputParser.ts'; interface InternalTestResult { name?: string; diff --git a/src/messageBuilder.ts b/src/messageBuilder.ts index d11af47..31b603a 100644 --- a/src/messageBuilder.ts +++ b/src/messageBuilder.ts @@ -1,8 +1,8 @@ import * as core from '@actions/core'; import * as github from '@actions/github'; -import type { parseInputs } from './inputParser'; -import type { getTestReports, TestResult } from './junitParser'; -import type { SummaryTableCell, SummaryTableRow } from '@actions/core/lib/summary'; +import type { parseInputs } from './inputParser.ts'; +import type { getTestReports, TestResult } from './junitParser.ts'; +import type { SummaryTableCell, SummaryTableRow } from '@actions/core/lib/summary.js'; async function annotateTestResult(testResult: TestResult, token: string, headSha: string, updateCheck: boolean, jobName: string): Promise { const annotations = testResult.annotations.filter(annotation => annotation.annotation_level !== 'notice'); diff --git a/src/utils.ts b/src/utils.ts index bd612c3..443402e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,6 @@ import * as core from '@actions/core'; import * as http from '@actions/http-client'; -import type { JUnitTestCase } from './junitParser'; +import type { JUnitTestCase } from './junitParser.ts'; export function retrieve(name: string, items: string[], index: number, total: number): string { if (total > 1) { diff --git a/tsconfig.json b/tsconfig.json index 40700e7..923e634 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,8 @@ "noImplicitAny": true, "esModuleInterop": true, "skipLibCheck": true, + "noEmit": true, + "allowImportingTsExtensions": true, }, "exclude": ["node_modules", "**/*.test.ts"] } diff --git a/yarn.lock b/yarn.lock index 79fd6eb..50c5469 100644 --- a/yarn.lock +++ b/yarn.lock @@ -493,7 +493,7 @@ semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/parser@^5.1.0", "@typescript-eslint/parser@^5.52.0": +"@typescript-eslint/parser@^5.1.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.53.0.tgz#a1f2b9ae73b83181098747e96683f1b249ecab52" integrity sha512-MKBw9i0DLYlmdOb3Oq/526+al20AJZpANdT6Ct9ffxcV8nKCHz63t/S0IhlTFNsBIHJv+GY5SFJ0XfqVeydQrQ== @@ -503,6 +503,17 @@ "@typescript-eslint/typescript-estree" "5.53.0" debug "^4.3.4" +"@typescript-eslint/parser@^7.16.0": + version "7.16.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.16.0.tgz#53fae8112f8c912024aea7b499cf7374487af6d8" + integrity sha512-ar9E+k7CU8rWi2e5ErzQiC93KKEFAXA2Kky0scAlPcxYblLt8+XZuHUZwlyfXILyQa95P6lQg+eZgh/dDs3+Vw== + dependencies: + "@typescript-eslint/scope-manager" "7.16.0" + "@typescript-eslint/types" "7.16.0" + "@typescript-eslint/typescript-estree" "7.16.0" + "@typescript-eslint/visitor-keys" "7.16.0" + debug "^4.3.4" + "@typescript-eslint/scope-manager@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.53.0.tgz#42b54f280e33c82939275a42649701024f3fafef" @@ -511,6 +522,14 @@ "@typescript-eslint/types" "5.53.0" "@typescript-eslint/visitor-keys" "5.53.0" +"@typescript-eslint/scope-manager@7.16.0": + version "7.16.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.16.0.tgz#eb0757af5720c9c53c8010d7a0355ae27e17b7e5" + integrity sha512-8gVv3kW6n01Q6TrI1cmTZ9YMFi3ucDT7i7aI5lEikk2ebk1AEjrwX8MDTdaX5D7fPXMBLvnsaa0IFTAu+jcfOw== + dependencies: + "@typescript-eslint/types" "7.16.0" + "@typescript-eslint/visitor-keys" "7.16.0" + "@typescript-eslint/type-utils@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.53.0.tgz#41665449935ba9b4e6a1ba6e2a3f4b2c31d6cf97" @@ -526,6 +545,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.53.0.tgz#f79eca62b97e518ee124086a21a24f3be267026f" integrity sha512-5kcDL9ZUIP756K6+QOAfPkigJmCPHcLN7Zjdz76lQWWDdzfOhZDTj1irs6gPBKiXx5/6O3L0+AvupAut3z7D2A== +"@typescript-eslint/types@7.16.0": + version "7.16.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.16.0.tgz#60a19d7e7a6b1caa2c06fac860829d162a036ed2" + integrity sha512-fecuH15Y+TzlUutvUl9Cc2XJxqdLr7+93SQIbcZfd4XRGGKoxyljK27b+kxKamjRkU7FYC6RrbSCg0ALcZn/xw== + "@typescript-eslint/typescript-estree@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.53.0.tgz#bc651dc28cf18ab248ecd18a4c886c744aebd690" @@ -539,6 +563,20 @@ semver "^7.3.7" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@7.16.0": + version "7.16.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.16.0.tgz#98ac779d526fab2a781e5619c9250f3e33867c09" + integrity sha512-a5NTvk51ZndFuOLCh5OaJBELYc2O3Zqxfl3Js78VFE1zE46J2AaVuW+rEbVkQznjkmlzWsUI15BG5tQMixzZLw== + dependencies: + "@typescript-eslint/types" "7.16.0" + "@typescript-eslint/visitor-keys" "7.16.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + minimatch "^9.0.4" + semver "^7.6.0" + ts-api-utils "^1.3.0" + "@typescript-eslint/utils@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.53.0.tgz#e55eaad9d6fffa120575ffaa530c7e802f13bce8" @@ -561,6 +599,14 @@ "@typescript-eslint/types" "5.53.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@7.16.0": + version "7.16.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.16.0.tgz#a1d99fa7a3787962d6e0efd436575ef840e23b06" + integrity sha512-rMo01uPy9C7XxG7AFsxa8zLnWXTF8N3PYclekWSrurvhwiw1eW88mrKiAYe6s53AUY57nTRz8dJsuuXdkAhzCg== + dependencies: + "@typescript-eslint/types" "7.16.0" + eslint-visitor-keys "^3.4.3" + acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" @@ -681,6 +727,13 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + braces@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" @@ -1171,6 +1224,11 @@ eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== +eslint-visitor-keys@^3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" + integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== + eslint@^8.34.0: version "8.35.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.35.0.tgz#fffad7c7e326bae606f0e8f436a6158566d42323" @@ -1837,6 +1895,13 @@ minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: dependencies: brace-expansion "^1.1.7" +minimatch@^9.0.4: + version "9.0.5" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.5.tgz#d74f9dd6b57d83d8e98cfb82133b03978bc929e5" + integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow== + dependencies: + brace-expansion "^2.0.1" + minimist@^1.2.0, minimist@^1.2.6: version "1.2.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" @@ -2112,6 +2177,11 @@ semver@^7.3.7: dependencies: lru-cache "^6.0.0" +semver@^7.6.0: + version "7.6.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.2.tgz#1e3b34759f896e8f14d6134732ce798aeb0c6e13" + integrity sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w== + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -2227,6 +2297,11 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +ts-api-utils@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.3.0.tgz#4b490e27129f1e8e686b45cc4ab63714dc60eea1" + integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ== + tsconfig-paths@^3.14.1: version "3.14.2" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" @@ -2285,10 +2360,10 @@ typed-array-length@^1.0.4: for-each "^0.3.3" is-typed-array "^1.1.9" -typescript@^4.9.5: - version "4.9.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" - integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== +typescript@5.3: + version "5.3.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" + integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw== unbox-primitive@^1.0.2: version "1.0.2"