Skip to content

Commit 6d927c4

Browse files
committed
switch to ESM and update config/test wiring
Signed-off-by: CrazyMax <[email protected]>
1 parent 4842870 commit 6d927c4

9 files changed

Lines changed: 81 additions & 263 deletions

File tree

.prettierrc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
"singleQuote": true,
77
"trailingComma": "none",
88
"bracketSpacing": false,
9-
"arrowParens": "avoid",
10-
"parser": "typescript"
9+
"arrowParens": "avoid"
1110
}

__tests__/context.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {beforeEach, describe, expect, test} from 'vitest';
22
import * as os from 'os';
33
import * as path from 'path';
44

5-
import * as context from '../src/context';
5+
import * as context from '../src/context.js';
66

77
describe('getInputs', () => {
88
beforeEach(() => {

eslint.config.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import {defineConfig} from 'eslint/config';
2+
import js from '@eslint/js';
3+
import tseslint from '@typescript-eslint/eslint-plugin';
4+
import vitest from '@vitest/eslint-plugin';
5+
import globals from 'globals';
6+
import eslintConfigPrettier from 'eslint-config-prettier/flat';
7+
import eslintPluginPrettier from 'eslint-plugin-prettier';
8+
9+
export default defineConfig([
10+
{
11+
ignores: ['.yarn/**/*', 'coverage/**/*', 'dist/**/*']
12+
},
13+
js.configs.recommended,
14+
...tseslint.configs['flat/recommended'],
15+
eslintConfigPrettier,
16+
{
17+
languageOptions: {
18+
globals: {
19+
...globals.node
20+
}
21+
}
22+
},
23+
{
24+
files: ['__tests__/**'],
25+
...vitest.configs.recommended,
26+
languageOptions: {
27+
globals: {
28+
...globals.node,
29+
...vitest.environments.env.globals
30+
}
31+
},
32+
rules: {
33+
...vitest.configs.recommended.rules,
34+
'vitest/no-conditional-expect': 'error',
35+
'vitest/no-disabled-tests': 0
36+
}
37+
},
38+
{
39+
plugins: {
40+
prettier: eslintPluginPrettier
41+
},
42+
rules: {
43+
'prettier/prettier': 'error',
44+
'@typescript-eslint/no-require-imports': [
45+
'error',
46+
{
47+
allowAsImport: true
48+
}
49+
]
50+
}
51+
}
52+
]);

package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
{
22
"name": "docker-setup-docker",
33
"description": "Set up Docker for use in GitHub Actions by downloading and installing a version of Docker CE",
4-
"main": "lib/main.js",
4+
"type": "module",
5+
"main": "src/main.ts",
56
"scripts": {
67
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
7-
"lint": "yarn run prettier && yarn run eslint",
8-
"format": "yarn run prettier:fix && yarn run eslint:fix",
9-
"eslint": "eslint --max-warnings=0 .",
10-
"eslint:fix": "eslint --fix .",
11-
"prettier": "prettier --check \"./**/*.ts\"",
12-
"prettier:fix": "prettier --write \"./**/*.ts\"",
8+
"lint": "eslint --max-warnings=0 .",
9+
"format": "eslint --fix .",
1310
"test": "vitest run",
1411
"all": "yarn run build && yarn run format && yarn test"
1512
},
@@ -30,8 +27,6 @@
3027
"@docker/actions-toolkit": "^0.71.0"
3128
},
3229
"devDependencies": {
33-
"@eslint/compat": "^2.0.0",
34-
"@eslint/eslintrc": "^3.3.3",
3530
"@eslint/js": "^9.39.2",
3631
"@types/node": "^20.19.27",
3732
"@typescript-eslint/eslint-plugin": "^8.50.0",
@@ -42,8 +37,8 @@
4237
"eslint": "^9.39.2",
4338
"eslint-config-prettier": "^10.1.8",
4439
"eslint-plugin-prettier": "^5.5.4",
40+
"globals": "^17.3.0",
4541
"prettier": "^3.7.4",
46-
"ts-node": "^10.9.2",
4742
"typescript": "^5.9.3",
4843
"vitest": "^4.0.18"
4944
}

src/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import path from 'path';
33
import * as core from '@actions/core';
44
import {parse} from 'csv-parse/sync';
55

6-
import {InstallSource} from '@docker/actions-toolkit/lib/docker/install';
7-
import {Util} from '@docker/actions-toolkit/lib/util';
6+
import {InstallSource} from '@docker/actions-toolkit/lib/docker/install.js';
7+
import {Util} from '@docker/actions-toolkit/lib/util.js';
88

99
export interface Inputs {
1010
source: InstallSource;

src/main.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import * as crypto from 'crypto';
22
import path from 'path';
33
import * as core from '@actions/core';
44
import * as actionsToolkit from '@docker/actions-toolkit';
5-
import {Install} from '@docker/actions-toolkit/lib/docker/install';
6-
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
7-
import {Install as RegclientInstall} from '@docker/actions-toolkit/lib/regclient/install';
8-
import {Install as UndockInstall} from '@docker/actions-toolkit/lib/undock/install';
5+
import {Install} from '@docker/actions-toolkit/lib/docker/install.js';
6+
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
7+
import {Install as RegclientInstall} from '@docker/actions-toolkit/lib/regclient/install.js';
8+
import {Install as UndockInstall} from '@docker/actions-toolkit/lib/undock/install.js';
99

10-
import * as context from './context';
11-
import * as stateHelper from './state-helper';
10+
import * as context from './context.js';
11+
import * as stateHelper from './state-helper.js';
1212

1313
const regctlDefaultVersion = 'v0.8.3';
1414
const undockDefaultVersion = 'v0.10.0';

tsconfig.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
3+
"module": "nodenext",
4+
"moduleResolution": "nodenext",
35
"esModuleInterop": true,
4-
"target": "es6",
5-
"module": "commonjs",
66
"newLine": "lf",
77
"outDir": "./lib",
88
"rootDir": "./src",
@@ -11,9 +11,7 @@
1111
"resolveJsonModule": true,
1212
"useUnknownInCatchVariables": false,
1313
},
14-
"exclude": [
15-
"node_modules",
16-
"**/*.test.ts",
17-
"vitest.config.ts"
14+
"include": [
15+
"src/**/*.ts"
1816
]
1917
}

0 commit comments

Comments
 (0)