From 0d218a4b7630395712803000c0d63b1a9bff2a9e Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 18 Mar 2021 16:56:46 -0700 Subject: [PATCH] eslint: Enable @typescript-eslint/consistent-type-imports. TypeScript type-only imports will probably become important eventually for reducing our circular import problem. https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export Signed-off-by: Anders Kaseorg --- .eslintrc.json | 3 +++ frontend_tests/puppeteer_lib/common.ts | 3 ++- static/js/blueslip_stacktrace.ts | 2 +- static/js/types/stacktrace-gps/index.d.ts | 4 ++-- tools/debug-require-webpack-plugin.ts | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 47f2eb9854..a858845c69 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -142,17 +142,20 @@ }, "rules": { // Disable base rule to avoid conflict + "no-duplicate-imports": "off", "no-unused-vars": "off", "no-useless-constructor": "off", "@typescript-eslint/array-type": "error", "@typescript-eslint/await-thenable": "error", "@typescript-eslint/consistent-type-assertions": "error", + "@typescript-eslint/consistent-type-imports": "error", "@typescript-eslint/explicit-function-return-type": [ "error", {"allowExpressions": true} ], "@typescript-eslint/member-ordering": "error", + "@typescript-eslint/no-duplicate-imports": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-extraneous-class": "error", "@typescript-eslint/no-non-null-assertion": "off", diff --git a/frontend_tests/puppeteer_lib/common.ts b/frontend_tests/puppeteer_lib/common.ts index 479edadd16..b944eadf58 100644 --- a/frontend_tests/puppeteer_lib/common.ts +++ b/frontend_tests/puppeteer_lib/common.ts @@ -2,7 +2,8 @@ import {strict as assert} from "assert"; import "css.escape"; import path from "path"; -import {Browser, ElementHandle, Page, launch} from "puppeteer"; +import type {Browser, ElementHandle, Page} from "puppeteer"; +import {launch} from "puppeteer"; import {test_credentials} from "../../var/puppeteer/test_credentials"; diff --git a/static/js/blueslip_stacktrace.ts b/static/js/blueslip_stacktrace.ts index b28cc01be6..ea41057cf1 100644 --- a/static/js/blueslip_stacktrace.ts +++ b/static/js/blueslip_stacktrace.ts @@ -1,6 +1,6 @@ import ErrorStackParser from "error-stack-parser"; import $ from "jquery"; -import StackFrame from "stackframe"; +import type StackFrame from "stackframe"; import StackTraceGPS from "stacktrace-gps"; import render_blueslip_stacktrace from "../templates/blueslip_stacktrace.hbs"; diff --git a/static/js/types/stacktrace-gps/index.d.ts b/static/js/types/stacktrace-gps/index.d.ts index 153f06e6a2..0f0c2cfa50 100644 --- a/static/js/types/stacktrace-gps/index.d.ts +++ b/static/js/types/stacktrace-gps/index.d.ts @@ -1,5 +1,5 @@ -import SourceMap from "source-map"; -import StackFrame from "stackframe"; +import type SourceMap from "source-map"; +import type StackFrame from "stackframe"; declare namespace StackTraceGPS { type StackTraceGPSOptions = { diff --git a/tools/debug-require-webpack-plugin.ts b/tools/debug-require-webpack-plugin.ts index e02cf14a03..5c2d278126 100644 --- a/tools/debug-require-webpack-plugin.ts +++ b/tools/debug-require-webpack-plugin.ts @@ -4,7 +4,8 @@ import path from "path"; -import webpack, {Template} from "webpack"; +import type webpack from "webpack"; +import {Template} from "webpack"; export default class DebugRequirePlugin { apply(compiler: webpack.Compiler): void {