diff --git a/eslint.config.mjs b/eslint.config.js similarity index 100% rename from eslint.config.mjs rename to eslint.config.js diff --git a/jest.config.js b/jest.config.js index 7cf1c26f..f6a60fb2 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,9 @@ -module.exports = { - preset: 'ts-jest', +/** @type {import('ts-jest').JestConfigWithTsJest} */ +export default { + preset: 'ts-jest/presets/default-esm', clearMocks: true, - testEnvironment: 'node', - testMatch: ['**/*.test.ts'], - verbose: true + // https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/ + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, } diff --git a/package.json b/package.json index 7d033a22..60b4b450 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "build": "ncc build --source-map --license licenses.txt src/main.ts", "test": "jest" }, + "type": "module", "dependencies": { "@actions/core": "1.10.1", "@actions/exec": "1.1.1", diff --git a/src/comment.ts b/src/comment.ts index 84e96a07..eb1ae6ba 100644 --- a/src/comment.ts +++ b/src/comment.ts @@ -1,5 +1,5 @@ import * as core from '@actions/core' -import { GitHubContext } from './github' +import { GitHubContext } from './github.js' type Comment = { body: string diff --git a/src/format.ts b/src/format.ts index a872f581..cce78087 100644 --- a/src/format.ts +++ b/src/format.ts @@ -1,5 +1,5 @@ import * as core from '@actions/core' -import { Diff } from './diff' +import { Diff } from './diff.js' type CommentOptions = { header: string diff --git a/src/label.ts b/src/label.ts index 38509eef..9f51214b 100644 --- a/src/label.ts +++ b/src/label.ts @@ -1,5 +1,5 @@ import * as core from '@actions/core' -import { GitHubContext } from './github' +import { GitHubContext } from './github.js' export const addLabels = async (github: GitHubContext, labels: string[]): Promise => { if (labels.length < 1) { diff --git a/src/main.ts b/src/main.ts index 7c0540f3..f6898253 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ import * as core from '@actions/core' -import { run } from './run' -import { getGitHubContext } from './github' -import { UpdateIfExistsType } from './comment' +import { run } from './run.js' +import { getGitHubContext } from './github.js' +import { UpdateIfExistsType } from './comment.js' const main = async (): Promise => { const outputs = await run(getGitHubContext(core.getInput('token', { required: true })), { diff --git a/src/run.ts b/src/run.ts index ed6e247d..f3ae9388 100644 --- a/src/run.ts +++ b/src/run.ts @@ -1,9 +1,9 @@ import * as core from '@actions/core' -import { GitHubContext } from './github' -import { computeDiff, showColorDiff } from './diff' -import { addLabels, removeLabels } from './label' -import { UpdateIfExistsType, addComment } from './comment' -import { formatComment } from './format' +import { GitHubContext } from './github.js' +import { computeDiff, showColorDiff } from './diff.js' +import { addLabels, removeLabels } from './label.js' +import { UpdateIfExistsType, addComment } from './comment.js' +import { formatComment } from './format.js' type Inputs = { base: string diff --git a/tests/diff.test.ts b/tests/diff.test.ts index 1688c656..69302741 100644 --- a/tests/diff.test.ts +++ b/tests/diff.test.ts @@ -1,4 +1,4 @@ -import { computeDiff } from '../src/diff' +import { computeDiff } from '../src/diff.js' test('diff', async () => { const diffs = await computeDiff(`${__dirname}/fixtures/base`, `${__dirname}/fixtures/head`) diff --git a/tests/format.test.ts b/tests/format.test.ts index 8925822f..b913c76e 100644 --- a/tests/format.test.ts +++ b/tests/format.test.ts @@ -1,4 +1,4 @@ -import { formatComment } from '../src/format' +import { formatComment } from '../src/format.js' test('formatComment', () => { const comment = formatComment( diff --git a/tsconfig.json b/tsconfig.json index 1adf1fe2..92ebc1fd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,4 @@ { - "extends": "@tsconfig/node20/tsconfig.json", - "compilerOptions": { - "outDir": "./lib" - } + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@tsconfig/node20/tsconfig.json" }