feat: migrate to ESM and update dependencies (#949)

* feat: migrate to ESM and update dependencies

- Migrated the project to ESM to support the latest `@actions/*` package versions.
- Updated dependencies to their latest versions, including `@actions/core`, `@actions/github`, and others.
- Replaced `.prettierrc.js` with `.prettierrc.json` for configuration.
- Updated ESLint configuration to use ESM and added new rules.
- Refactored test files to use `jest` with ESM imports.
- Removed deprecated files and updated import paths to use `.js` extensions.
- Added new files for improved configuration and removed unnecessary mocks.
- Updated README to reflect breaking changes in version 7.

* docs: update README to clarify ESM migration details and adjust TypeScript configuration
This commit is contained in:
Chiranjib Swain
2026-07-16 11:04:03 -05:00
committed by GitHub
parent b8dd2d9be0
commit bf12e9b00b
60 changed files with 15081 additions and 16281 deletions
+25 -9
View File
@@ -1,5 +1,24 @@
import {
ChangedFilesMatchConfig,
import {jest, describe, it, expect} from '@jest/globals';
import type {ChangedFilesMatchConfig} from '../src/changedFiles.js';
jest.unstable_mockModule('@actions/core', () => ({
debug: jest.fn(),
info: jest.fn(),
warning: jest.fn(),
error: jest.fn()
}));
jest.unstable_mockModule('@actions/github', () => ({
context: {
payload: {
pull_request: {number: 123, head: {ref: 'head'}, base: {ref: 'base'}}
},
repo: {owner: 'monalisa', repo: 'helloworld'}
},
getOctokit: jest.fn()
}));
const {
checkAllChangedFiles,
checkAnyChangedFiles,
toChangedFilesMatchConfig,
@@ -7,10 +26,7 @@ import {
checkIfAllGlobsMatchAnyFile,
checkIfAnyGlobMatchesAllFiles,
checkIfAllGlobsMatchAllFiles
} from '../src/changedFiles';
jest.mock('@actions/core');
jest.mock('@actions/github');
} = await import('../src/changedFiles.js');
describe('checkAllChangedFiles', () => {
const changedFiles = ['foo.txt', 'bar.txt'];
@@ -92,7 +108,7 @@ describe('toChangedFilesMatchConfig', () => {
it('returns an empty object', () => {
const result = toChangedFilesMatchConfig(config);
expect(result).toEqual<ChangedFilesMatchConfig>({});
expect(result).toEqual({});
});
});
@@ -129,7 +145,7 @@ describe('toChangedFilesMatchConfig', () => {
it('sets the value in the config object', () => {
const result = toChangedFilesMatchConfig(config);
expect(result).toEqual<ChangedFilesMatchConfig>({
expect(result).toEqual({
changedFiles: [{anyGlobToAnyFile: ['testing']}]
});
});
@@ -140,7 +156,7 @@ describe('toChangedFilesMatchConfig', () => {
it(`sets the string as an array in the config object`, () => {
const result = toChangedFilesMatchConfig(config);
expect(result).toEqual<ChangedFilesMatchConfig>({
expect(result).toEqual({
changedFiles: [{anyGlobToAnyFile: ['testing']}]
});
});