Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to ESModule #913

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@
],
"no-console": "error",
"simple-import-sort/imports": "error",
"node/no-missing-import": [
"error",
{
"allowModules": ["@octokit/webhooks-types", "vitest"],
"tryExtensions": [".ts", ".js", ".json", ".node"]
}
],
"node/no-missing-import": ["off"],
"node/no-unpublished-import": [
"error",
{
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "lgtm-action",
"type": "module",
"version": "3.0.0",
"private": true,
"description": "Post image if you comment \"LGTM\"",
Expand All @@ -17,7 +18,7 @@
},
"scripts": {
"prepare": "husky install",
"build": "ncc build src/main.ts -m --license licenses.txt --target es2021",
"build": "ncc build src/main.ts -m --license licenses.txt --target es2022",
"fix": "run-p \"lint:eslint -- --fix\" \"lint:prettier -- --write\"",
"lint": "run-p lint:*",
"lint:eslint": "eslint --ext .ts --ignore-path .gitignore .",
Expand All @@ -37,7 +38,7 @@
},
"devDependencies": {
"@octokit/webhooks-types": "^7.3.1",
"@tsconfig/node16": "^16.1.1",
"@tsconfig/node20": "^20.1.2",
"@tsconfig/strictest": "^2.0.2",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { debug, info, setFailed, warning } from '@actions/core'
import { context } from '@actions/github'

import { getEventWebhook, isSupportedEvent } from './event'
import { getInputParams } from './input-helper'
import { sendCommentAsync } from './send-comment'
import { getEventWebhook, isSupportedEvent } from './event.js'
import { getInputParams } from './input-helper.js'
import { sendCommentAsync } from './send-comment.js'

/** Main entry */
export async function run(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion test/event.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test, vi } from 'vitest'

import { getEventWebhook, isSupportedEvent } from '../src/event'
import { getEventWebhook, isSupportedEvent } from '../src/event.js'

vi.mock('@actions/github', () => ({
context: {
Expand Down
4 changes: 2 additions & 2 deletions test/input-helper.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getInput, getMultilineInput } from '@actions/core'
import { beforeEach, describe, expect, test, vi } from 'vitest'

import { getInputParams } from '../src/input-helper'
import { generateRandomString as random } from './util'
import { getInputParams } from '../src/input-helper.js'
import { generateRandomString as random } from './util.js'

vi.mock('@actions/core')

Expand Down
8 changes: 4 additions & 4 deletions test/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { info, setFailed, warning } from '@actions/core'
import { beforeEach, describe, expect, test, vi } from 'vitest'

import { getEventWebhook, isSupportedEvent } from '../src/event'
import { getInputParams } from '../src/input-helper'
import { run } from '../src/main'
import { sendCommentAsync } from '../src/send-comment'
import { getEventWebhook, isSupportedEvent } from '../src/event.js'
import { getInputParams } from '../src/input-helper.js'
import { run } from '../src/main.js'
import { sendCommentAsync } from '../src/send-comment.js'

vi.mock('@actions/core')
vi.mock('@actions/github', () => ({
Expand Down
4 changes: 2 additions & 2 deletions test/send-comment.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getOctokit } from '@actions/github'
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest'

import { sendCommentAsync } from '../src/send-comment'
import { generateRandomString } from './util'
import { sendCommentAsync } from '../src/send-comment.js'
import { generateRandomString } from './util.js'

vi.mock('@actions/github')

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": [
"@tsconfig/node16/tsconfig.json",
"@tsconfig/node20/tsconfig.json",
"@tsconfig/strictest/tsconfig.json"
],
"compilerOptions": {
Expand Down
Loading