From 6c471ae9f6c1cffc47f49cf2cc5f8fb9df4e6ad2 Mon Sep 17 00:00:00 2001 From: BSKY Date: Wed, 18 Mar 2020 22:35:13 +0900 Subject: [PATCH] Add eslint-plugin-simple-import-sort (#219) * Add eslint-plugin-simple-import-sort * Update .eslintrc.json * eslint --fix --- .eslintrc.json | 9 ++++++++- __tests__/restore.test.ts | 1 + __tests__/save.test.ts | 1 + __tests__/tar.test.ts | 1 + package-lock.json | 6 ++++++ package.json | 1 + src/cacheHttpClient.ts | 5 +++-- src/restore.ts | 1 + src/save.ts | 1 + 9 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index ccaf1a6..7a40259 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,5 +12,12 @@ "plugin:prettier/recommended", "prettier/@typescript-eslint" ], - "plugins": ["@typescript-eslint", "jest"] + "plugins": ["@typescript-eslint", "simple-import-sort", "jest"], + "rules": { + "import/first": "error", + "import/newline-after-import": "error", + "import/no-duplicates": "error", + "simple-import-sort/sort": "error", + "sort-imports": "off" + } } diff --git a/__tests__/restore.test.ts b/__tests__/restore.test.ts index 05fed55..212ec30 100644 --- a/__tests__/restore.test.ts +++ b/__tests__/restore.test.ts @@ -1,5 +1,6 @@ import * as core from "@actions/core"; import * as path from "path"; + import * as cacheHttpClient from "../src/cacheHttpClient"; import { Events, Inputs } from "../src/constants"; import { ArtifactCacheEntry } from "../src/contracts"; diff --git a/__tests__/save.test.ts b/__tests__/save.test.ts index 2c297bd..daab665 100644 --- a/__tests__/save.test.ts +++ b/__tests__/save.test.ts @@ -1,5 +1,6 @@ import * as core from "@actions/core"; import * as path from "path"; + import * as cacheHttpClient from "../src/cacheHttpClient"; import { Events, Inputs } from "../src/constants"; import { ArtifactCacheEntry } from "../src/contracts"; diff --git a/__tests__/tar.test.ts b/__tests__/tar.test.ts index 55ff4c7..c931471 100644 --- a/__tests__/tar.test.ts +++ b/__tests__/tar.test.ts @@ -1,5 +1,6 @@ import * as exec from "@actions/exec"; import * as io from "@actions/io"; + import * as tar from "../src/tar"; jest.mock("@actions/exec"); diff --git a/package-lock.json b/package-lock.json index 3320d39..8b8dd01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2298,6 +2298,12 @@ "prettier-linter-helpers": "^1.0.0" } }, + "eslint-plugin-simple-import-sort": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-5.0.2.tgz", + "integrity": "sha512-YPEGo7DbMANQ01d2OXlREcaHRszsW8LoUQ9mIjI7gXSdwpnWKfogtzL6FiBfDf1teCBx+AdcjcfDXSKpmhTWeA==", + "dev": true + }, "eslint-scope": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", diff --git a/package.json b/package.json index 66952be..4788803 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "eslint-plugin-import": "^2.18.2", "eslint-plugin-jest": "^23.0.3", "eslint-plugin-prettier": "^3.1.1", + "eslint-plugin-simple-import-sort": "^5.0.2", "jest": "^24.8.0", "jest-circus": "^24.7.1", "nock": "^11.7.0", diff --git a/src/cacheHttpClient.ts b/src/cacheHttpClient.ts index 62ae2c1..90284d4 100644 --- a/src/cacheHttpClient.ts +++ b/src/cacheHttpClient.ts @@ -1,12 +1,13 @@ import * as core from "@actions/core"; -import * as fs from "fs"; -import { BearerCredentialHandler } from "@actions/http-client/auth"; import { HttpClient, HttpCodes } from "@actions/http-client"; +import { BearerCredentialHandler } from "@actions/http-client/auth"; import { IHttpClientResponse, IRequestOptions, ITypedResponse } from "@actions/http-client/interfaces"; +import * as fs from "fs"; + import { ArtifactCacheEntry, CommitCacheRequest, diff --git a/src/restore.ts b/src/restore.ts index f180c2b..721a8e3 100644 --- a/src/restore.ts +++ b/src/restore.ts @@ -1,5 +1,6 @@ import * as core from "@actions/core"; import * as path from "path"; + import * as cacheHttpClient from "./cacheHttpClient"; import { Events, Inputs, State } from "./constants"; import { extractTar } from "./tar"; diff --git a/src/save.ts b/src/save.ts index de03856..8cb5115 100644 --- a/src/save.ts +++ b/src/save.ts @@ -1,5 +1,6 @@ import * as core from "@actions/core"; import * as path from "path"; + import * as cacheHttpClient from "./cacheHttpClient"; import { Events, Inputs, State } from "./constants"; import { createTar } from "./tar";