Skip to content

Commit 70e1ff8

Browse files
authored
Merge pull request #170 from crazy-max/eslint
dev: switch to eslint
2 parents f169e16 + 0828e0e commit 70e1ff8

16 files changed

+10230
-32448
lines changed

.eslintrc.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es2021": true,
5+
"jest/globals": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended",
10+
"plugin:jest/recommended",
11+
"plugin:prettier/recommended"
12+
],
13+
"parser": "@typescript-eslint/parser",
14+
"parserOptions": {
15+
"ecmaVersion": "latest",
16+
"sourceType": "module"
17+
},
18+
"plugins": [
19+
"@typescript-eslint",
20+
"jest",
21+
"prettier"
22+
]
23+
}

__tests__/docker.test.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as exec from '@actions/exec';
66
process.env['RUNNER_TEMP'] = path.join(__dirname, 'runner');
77

88
test('loginStandard calls exec', async () => {
9+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
910
// @ts-ignore
1011
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
1112
return {
@@ -15,9 +16,9 @@ test('loginStandard calls exec', async () => {
1516
};
1617
});
1718

18-
const username: string = 'dbowie';
19-
const password: string = 'groundcontrol';
20-
const registry: string = 'https://ghcr.io';
19+
const username = 'dbowie';
20+
const password = 'groundcontrol';
21+
const registry = 'https://ghcr.io';
2122

2223
await loginStandard(registry, username, password);
2324

@@ -29,6 +30,7 @@ test('loginStandard calls exec', async () => {
2930
});
3031

3132
test('logout calls exec', async () => {
33+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3234
// @ts-ignore
3335
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
3436
return {
@@ -38,7 +40,7 @@ test('logout calls exec', async () => {
3840
};
3941
});
4042

41-
const registry: string = 'https://ghcr.io';
43+
const registry = 'https://ghcr.io';
4244

4345
await logout(registry);
4446

__tests__/main.test.ts

+12-13
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import * as stateHelper from '../src/state-helper';
88
import * as core from '@actions/core';
99

1010
test('errors without username and password', async () => {
11-
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
12-
11+
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
1312
process.env['INPUT_LOGOUT'] = 'true'; // default value
1413
const coreSpy = jest.spyOn(core, 'setFailed');
1514

@@ -18,21 +17,21 @@ test('errors without username and password', async () => {
1817
});
1918

2019
test('successful with username and password', async () => {
21-
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
20+
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
2221
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
2322
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
2423
const dockerSpy = jest.spyOn(docker, 'login').mockImplementation(jest.fn());
2524

26-
const username: string = 'dbowie';
25+
const username = 'dbowie';
2726
process.env[`INPUT_USERNAME`] = username;
2827

29-
const password: string = 'groundcontrol';
28+
const password = 'groundcontrol';
3029
process.env[`INPUT_PASSWORD`] = password;
3130

32-
const ecr: string = 'auto';
31+
const ecr = 'auto';
3332
process.env['INPUT_ECR'] = ecr;
3433

35-
const logout: boolean = false;
34+
const logout = false;
3635
process.env['INPUT_LOGOUT'] = String(logout);
3736

3837
await run();
@@ -43,25 +42,25 @@ test('successful with username and password', async () => {
4342
});
4443

4544
test('calls docker login', async () => {
46-
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
45+
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
4746
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
4847
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
4948
const dockerSpy = jest.spyOn(docker, 'login');
5049
dockerSpy.mockImplementation(jest.fn());
5150

52-
const username: string = 'dbowie';
51+
const username = 'dbowie';
5352
process.env[`INPUT_USERNAME`] = username;
5453

55-
const password: string = 'groundcontrol';
54+
const password = 'groundcontrol';
5655
process.env[`INPUT_PASSWORD`] = password;
5756

58-
const registry: string = 'ghcr.io';
57+
const registry = 'ghcr.io';
5958
process.env[`INPUT_REGISTRY`] = registry;
6059

61-
const ecr: string = 'auto';
60+
const ecr = 'auto';
6261
process.env['INPUT_ECR'] = ecr;
6362

64-
const logout: boolean = true;
63+
const logout = true;
6564
process.env['INPUT_LOGOUT'] = String(logout);
6665

6766
await run();

dev.Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# syntax=docker/dockerfile:1.3-labs
1+
# syntax=docker/dockerfile:1
22

33
ARG NODE_VERSION=12
4-
ARG DOCKER_VERSION=20.10.10
5-
ARG BUILDX_VERSION=0.7.0
4+
ARG DOCKER_VERSION=20.10.13
5+
ARG BUILDX_VERSION=0.8.1
66

77
FROM node:${NODE_VERSION}-alpine AS base
88
RUN apk add --no-cache cpio findutils git
@@ -57,10 +57,10 @@ RUN --mount=type=bind,target=.,rw \
5757
FROM scratch AS format-update
5858
COPY --from=format /out /
5959

60-
FROM deps AS format-validate
60+
FROM deps AS lint
6161
RUN --mount=type=bind,target=.,rw \
6262
--mount=type=cache,target=/src/node_modules \
63-
yarn run format-check
63+
yarn run lint
6464

6565
FROM docker:${DOCKER_VERSION} as docker
6666
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx

0 commit comments

Comments
 (0)