Commit fb50aa45 authored by BSKY's avatar BSKY Committed by Josh Gross
Browse files

Add initial eslint setup (#88)

parent 31508256
Loading
Loading
Loading
Loading
+16
Changes for .eslintrc.json: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
  "env": { "node": true, "jest": true },
  "parser": "@typescript-eslint/parser",
  "parserOptions": { "ecmaVersion": 2020, "sourceType": "module" },
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:import/typescript",
    "plugin:prettier/recommended",
    "prettier/@typescript-eslint"
  ],
  "plugins": ["@typescript-eslint", "jest"]
}
+8
Changes for .github/workflows/workflow.yml: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
name: Tests

on:
  pull_request:
    branches:
@@ -14,9 +15,11 @@ on:
jobs:
  test:
    name: Test on ${{ matrix.os }}

    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]

    runs-on: ${{ matrix.os }}

    steps:
@@ -29,7 +32,12 @@ jobs:
    - run: npm ci

    - name: Prettier Format Check
      if: matrix.os == 'ubuntu-latest'
      run: npm run format-check

    - name: ESLint Check
      if: matrix.os == 'ubuntu-latest'
      run: npm run lint

    - name: Build & Test
      run: npm run test
+5 −7
Changes for __tests__/restore.test.ts: 5 added lines, 7 removed lines.
Original line number Diff line number Diff line
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as io from "@actions/io";

import * as path from "path";

import * as cacheHttpClient from "../src/cacheHttpClient";
import { Inputs } from "../src/constants";
import { ArtifactCacheEntry } from "../src/contracts";
@@ -107,7 +105,7 @@ test("restore with no cache found", async () => {
    const stateMock = jest.spyOn(core, "saveState");

    const clientMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
    clientMock.mockImplementation(_ => {
    clientMock.mockImplementation(() => {
        return Promise.resolve(null);
    });

@@ -134,7 +132,7 @@ test("restore with server error should fail", async () => {
    const stateMock = jest.spyOn(core, "saveState");

    const clientMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
    clientMock.mockImplementation(_ => {
    clientMock.mockImplementation(() => {
        throw new Error("HTTP Error Occurred");
    });

@@ -168,7 +166,7 @@ test("restore with restore keys and no cache found", async () => {
    const stateMock = jest.spyOn(core, "saveState");

    const clientMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
    clientMock.mockImplementation(_ => {
    clientMock.mockImplementation(() => {
        return Promise.resolve(null);
    });

@@ -202,7 +200,7 @@ test("restore with cache found", async () => {
        archiveLocation: "www.actionscache.test/download"
    };
    const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
    getCacheMock.mockImplementation(_ => {
    getCacheMock.mockImplementation(() => {
        return Promise.resolve(cacheEntry);
    });
    const tempPath = "/foo/bar";
@@ -278,7 +276,7 @@ test("restore with cache found for restore key", async () => {
        archiveLocation: "www.actionscache.test/download"
    };
    const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
    getCacheMock.mockImplementation(_ => {
    getCacheMock.mockImplementation(() => {
        return Promise.resolve(cacheEntry);
    });
    const tempPath = "/foo/bar";
+10 −9
Changes for jest.config.js: 10 added lines, 9 removed lines.
Original line number Diff line number Diff line
require('nock').disableNetConnect();
require("nock").disableNetConnect();

module.exports = {
    clearMocks: true,
  moduleFileExtensions: ['js', 'ts'],
  testEnvironment: 'node',
  testMatch: ['**/*.test.ts'],
  testRunner: 'jest-circus/runner',
    moduleFileExtensions: ["js", "ts"],
    testEnvironment: "node",
    testMatch: ["**/*.test.ts"],
    testRunner: "jest-circus/runner",
    transform: {
    '^.+\\.ts$': 'ts-jest'
        "^.+\\.ts$": "ts-jest"
    },
    verbose: true
}
};

const processStdoutWrite = process.stdout.write.bind(process.stdout)
const processStdoutWrite = process.stdout.write.bind(process.stdout);
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
process.stdout.write = (str, encoding, cb) => {
    // Core library will directly call process.stdout.write for commands
    // We don't want :: commands to be executed by the runner during tests
    if (!str.match(/^::/)) {
        return processStdoutWrite(str, encoding, cb);
    }
}
 No newline at end of file
};
+924

File changed.

Preview size limit exceeded, changes collapsed.

Loading