Skip to content

Commit 279a65f

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

8 files changed

Lines changed: 75 additions & 265 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import * as fs from 'fs';
33
import * as os from 'os';
44
import * as path from 'path';
55

6-
import {Context} from '@docker/actions-toolkit/lib/context';
6+
import {Context} from '@docker/actions-toolkit/lib/context.js';
77

8-
import * as context from '../src/context';
8+
import * as context from '../src/context.js';
99

1010
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'context-'));
1111
const tmpName = path.join(tmpDir, '.tmpname-vi');

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: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
{
22
"name": "docker-setup-compose",
33
"description": "Set up Docker Compose",
4+
"type": "module",
45
"main": "src/main.ts",
56
"scripts": {
67
"build": "ncc build --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
},
1512
"repository": {
@@ -29,8 +26,6 @@
2926
"@docker/actions-toolkit": "^0.62.1"
3027
},
3128
"devDependencies": {
32-
"@eslint/compat": "^2.0.0",
33-
"@eslint/eslintrc": "^3.3.3",
3429
"@eslint/js": "^9.39.2",
3530
"@types/node": "^20.19.27",
3631
"@typescript-eslint/eslint-plugin": "^8.50.0",
@@ -41,8 +36,8 @@
4136
"eslint": "^9.39.2",
4237
"eslint-config-prettier": "^10.1.8",
4338
"eslint-plugin-prettier": "^5.5.4",
39+
"globals": "^17.3.0",
4440
"prettier": "^3.7.4",
45-
"ts-node": "^10.9.2",
4641
"typescript": "^5.9.3",
4742
"vitest": "^4.0.18"
4843
}

src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as core from '@actions/core';
22
import * as actionsToolkit from '@docker/actions-toolkit';
33

4-
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
5-
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
4+
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
5+
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
66

7-
import * as context from './context';
7+
import * as context from './context.js';
88

99
actionsToolkit.run(
1010
// main

tsconfig.json

Lines changed: 4 additions & 7 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
"strict": true,
77
"newLine": "lf",
88
"outDir": "./lib",
@@ -12,10 +12,7 @@
1212
"resolveJsonModule": true,
1313
"useUnknownInCatchVariables": false,
1414
},
15-
"exclude": [
16-
"./__tests__/**/*",
17-
"./lib/**/*",
18-
"node_modules",
19-
"vitest.config.ts"
15+
"include": [
16+
"src/**/*.ts"
2017
]
2118
}

0 commit comments

Comments
 (0)