Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable @typescript-eslint/consistent-type-imports #756

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"no-shadow": "off",
"default-param-last": "off",
"no-param-reassign": "off",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/class-name-casing": "off",
"node/no-exports-assign": "off",
Expand Down
8 changes: 3 additions & 5 deletions src/batch.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import {
import type {
AwsOptions,
CommonOptions,
faastAws,
faastLocal,
FaastModuleProxy,
LocalOptions,
log,
} from "faastjs";
import { faastAws, faastLocal, log } from "faastjs";
import mergeOptions from "merge-options";
import semver from "semver";
import { assertNonNullable } from "./assert";
import * as compilerFaastFunctions from "./compiler-core";
import { DuckConfig } from "./duckconfig";
import type { DuckConfig } from "./duckconfig";
import { logger } from "./logger";

// change to stdout
Expand Down
14 changes: 9 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Listr from "listr";
import os from "os";
import path from "path";
import pino from "pino";
import { Observable } from "rxjs";
import type { Observable } from "rxjs";
import { map } from "rxjs/operators";
import split from "split2";
import yargs from "yargs";
Expand All @@ -14,13 +14,17 @@ import {
} from "./assert";
import { buildDeps } from "./commands/buildDeps";
import { buildJs, BuildJsCompilationError } from "./commands/buildJs";
import { buildSoy, BuildSoyConfig } from "./commands/buildSoy";
import type { BuildSoyConfig } from "./commands/buildSoy";
import { buildSoy } from "./commands/buildSoy";
import { cleanDeps } from "./commands/cleanDeps";
import { cleanSoy, CleanSoyConfig } from "./commands/cleanSoy";
import type { CleanSoyConfig } from "./commands/cleanSoy";
import { cleanSoy } from "./commands/cleanSoy";
import { serve } from "./commands/serve";
import { DuckConfig, loadConfig } from "./duckconfig";
import type { DuckConfig } from "./duckconfig";
import { loadConfig } from "./duckconfig";
import { setGlobalLogger } from "./logger";
import { ErrorReason, reportTestResults } from "./report";
import type { ErrorReason } from "./report";
import { reportTestResults } from "./report";

assertNodeVersionGte(process.version, 10);

Expand Down
2 changes: 1 addition & 1 deletion src/commands/buildDeps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { promises as fs } from "fs";
import path from "path";
import { resultInfoLogType } from "../cli";
import { DuckConfig } from "../duckconfig";
import type { DuckConfig } from "../duckconfig";
import { generateDepFileTextFromDeps, getDependencies } from "../gendeps";
import { logger } from "../logger";

Expand Down
16 changes: 8 additions & 8 deletions src/commands/buildJs.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import type { FaastModule } from "faastjs";
import { promises as fs } from "fs";
import pSettled from "p-settle";
import path from "path";
import recursive from "recursive-readdir";
import { assertNonNullable, assertString } from "../assert";
import { resultInfoLogType } from "../cli";
import type { CompilerError } from "../compiler";
import {
CompilerError,
compileToJson,
createCompilerOptionsForChunks,
createCompilerOptionsForPage,
} from "../compiler";
import * as compilerCoreFunctions from "../compiler-core";
import { DuckConfig } from "../duckconfig";
import { EntryConfig, loadEntryConfig } from "../entryconfig";
import type * as compilerCoreFunctions from "../compiler-core";
import type { DuckConfig } from "../duckconfig";
import type { EntryConfig } from "../entryconfig";
import { loadEntryConfig } from "../entryconfig";
import { restoreDepsJs } from "../gendeps";
import { logger } from "../logger";
import { CompileErrorItem, ErrorReason } from "../report";
import type { CompileErrorItem, ErrorReason } from "../report";

/**
* @throws If compiler throws errors
Expand All @@ -26,9 +28,7 @@ export async function buildJs(
printConfig = false
): Promise<ErrorReason[]> {
let compileFn = compileToJson;
let faastModule:
| import("faastjs").FaastModule<typeof compilerCoreFunctions>
| null = null;
let faastModule: FaastModule<typeof compilerCoreFunctions> | null = null;
if (config.batch) {
const { getFaastCompiler } = await import("../batch.js");
faastModule = await getFaastCompiler(config);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/buildSoy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import recursive from "recursive-readdir";
import { DuckConfig } from "../duckconfig";
import type { DuckConfig } from "../duckconfig";
import { logger } from "../logger";
import { compileSoy } from "../soy";

Expand Down
2 changes: 1 addition & 1 deletion src/commands/cleanSoy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import rimraf from "rimraf";
import util from "util";
import { assertString } from "../assert";
import { DuckConfig } from "../duckconfig";
import type { DuckConfig } from "../duckconfig";
import { logger } from "../logger";
import { resolveOutputPathFormat } from "../soy";

Expand Down
15 changes: 6 additions & 9 deletions src/commands/serve.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import cors from "@fastify/cors";
import serveStatic from "@fastify/static";
import { stripIndents } from "common-tags";
import fastify, { FastifyInstance, FastifyReply } from "fastify";
import type { FastifyInstance, FastifyReply } from "fastify";
import fastify from "fastify";
import { promises as fs } from "fs";
import type http2 from "http2";
import path from "path";
import pino from "pino";
import { assertNonNullable, assertString } from "../assert";
import type { CompilerOutput } from "../compiler";
import {
CompilerOutput,
compileToJson,
convertChunkInfos,
createCompilerOptionsForChunks,
createCompilerOptionsForPage,
} from "../compiler";
import { DuckConfig } from "../duckconfig";
import {
createDag,
EntryConfig,
loadEntryConfigById,
PlovrMode,
} from "../entryconfig";
import type { DuckConfig } from "../duckconfig";
import type { EntryConfig, PlovrMode } from "../entryconfig";
import { createDag, loadEntryConfigById } from "../entryconfig";
import {
generateDepFileText,
restoreDepsJs,
Expand Down
6 changes: 3 additions & 3 deletions src/compiler-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import fs from "fs";
import { compiler as ClosureCompiler } from "google-closure-compiler";
import { dirname } from "path";
import * as tempy from "tempy";
import { DuckConfig } from "./duckconfig";
import { WarningsWhitelistItem } from "./entryconfig";
import type { DuckConfig } from "./duckconfig";
import type { WarningsWhitelistItem } from "./entryconfig";
import { logger } from "./logger";
import { CompileErrorItem } from "./report";
import type { CompileErrorItem } from "./report";

declare const __non_webpack_require__: NodeRequire;

Expand Down
14 changes: 5 additions & 9 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ import { depGraph } from "google-closure-deps";
import path from "path";
import semver from "semver";
import { assertNonNullable } from "./assert";
import {
import type {
CompilationLevel,
CompilerOptions,
CompilerOptionsFormattingType,
ExtendedCompilerOptions,
} from "./compiler-core";
import { Dag } from "./dag";
import { DuckConfig } from "./duckconfig";
import {
createDag,
EntryConfig,
PlovrMode,
WarningsWhitelistItem,
} from "./entryconfig";
import type { Dag } from "./dag";
import type { DuckConfig } from "./duckconfig";
import type { EntryConfig, WarningsWhitelistItem } from "./entryconfig";
import { createDag, PlovrMode } from "./entryconfig";
import { getClosureLibraryDependencies, getDependencies } from "./gendeps";

export {
Expand Down
3 changes: 2 additions & 1 deletion src/dependency-parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { depGraph, parser } from "google-closure-deps";
import type { depGraph } from "google-closure-deps";
import { parser } from "google-closure-deps";

/**
* Parse a script file including such as `goog.provide` and generate a `Dependency`.
Expand Down
12 changes: 7 additions & 5 deletions src/duckconfig.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { AwsOptions, LocalOptions } from "faastjs";
import path from "path";
import { assertString } from "./assert";
import { toAbsPath, toAbsPathArray } from "./pathutils";
import { JsonReporterOptions } from "./reporters/json-reporter";
import { TextReporterOptions } from "./reporters/text-reporter";
import { XUnitReporterOptions } from "./reporters/xunit-reporter";
import { normalizeSoyOptoins, SoyToJsOptions } from "./soy";
import type { JsonReporterOptions } from "./reporters/json-reporter";
import type { TextReporterOptions } from "./reporters/text-reporter";
import type { XUnitReporterOptions } from "./reporters/xunit-reporter";
import type { SoyToJsOptions } from "./soy";
import { normalizeSoyOptoins } from "./soy";

export interface DuckConfig {
/**
Expand Down Expand Up @@ -76,7 +78,7 @@ export interface DuckConfig {
* Options for faast.js in batch mode.
* @see https://faastjs.org/docs/api/faastjs.awsoptions
*/
batchOptions?: import("faastjs").AwsOptions | import("faastjs").LocalOptions;
batchOptions?: AwsOptions | LocalOptions;
/**
* Reporters (choose from "json", "text" or "xunit")
*/
Expand Down
2 changes: 1 addition & 1 deletion src/gendeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { promises as fs } from "fs";
import { depFile, depGraph, parser } from "google-closure-deps";
import path from "path";
import { DependencyParserWithWorkers } from "./dependency-parser-wrapper";
import { EntryConfig } from "./entryconfig";
import type { EntryConfig } from "./entryconfig";
import { googBaseUrlPath, inputsUrlPath } from "./urls";

const pathToDependencyCache: Map<
Expand Down
2 changes: 1 addition & 1 deletion src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pino from "pino";
import type pino from "pino";

export let logger: pino.Logger;

Expand Down
2 changes: 1 addition & 1 deletion src/report.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DuckConfig } from "./duckconfig";
import type { DuckConfig } from "./duckconfig";
import { JsonReporter } from "./reporters/json-reporter";
import { TextReporter } from "./reporters/text-reporter";
import { XUnitReporter } from "./reporters/xunit-reporter";
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/base-reporter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promises as fs } from "fs";
import path from "path";
import { ErrorReason } from "../report";
import type { ErrorReason } from "../report";

export abstract class BaseReporter {
private stderr: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/json-reporter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "path";
import { ErrorReason } from "../report";
import type { ErrorReason } from "../report";
import { BaseReporter } from "./base-reporter";

export interface JsonReporterOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/text-reporter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompileErrorCase, ErrorReason } from "../report";
import type { CompileErrorCase, ErrorReason } from "../report";
import { BaseReporter } from "./base-reporter";

export interface TextReporterOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/xunit-reporter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import xmlbuilder from "xmlbuilder";
import { CompileErrorCase, ErrorReason } from "../report";
import type { CompileErrorCase, ErrorReason } from "../report";
import { BaseReporter } from "./base-reporter";

export interface XUnitReporterOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/soy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import execa from "execa";
import path from "path";
import { assertString } from "./assert";
import { resultInfoLogType } from "./cli";
import { DuckConfig } from "./duckconfig";
import type { DuckConfig } from "./duckconfig";
import { logger } from "./logger";
import { toAbsPath, toAbsPathArray } from "./pathutils";

Expand Down
2 changes: 1 addition & 1 deletion src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chokidar from "chokidar";
import { promises as fs } from "fs";
import path from "path";
import { clearEntryIdToChunkCache } from "./commands/serve";
import { DuckConfig } from "./duckconfig";
import type { DuckConfig } from "./duckconfig";
import { removeDepCacheByPath } from "./gendeps";
import { logger } from "./logger";
import { calcOutputPath, compileSoy } from "./soy";
Expand Down
5 changes: 3 additions & 2 deletions test/compiler-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import fs from "fs";
import path from "path";
import tempy from "tempy";
import { beforeEach, describe, it } from "vitest";
import { CompilerOutput, compileToJson } from "../src/compiler";
import { CompileErrorItem } from "../src/report";
import type { CompilerOutput } from "../src/compiler";
import { compileToJson } from "../src/compiler";
import type { CompileErrorItem } from "../src/report";

const assertCompileErrorItem = (item: any) => {
assert(typeof item === "object");
Expand Down
4 changes: 2 additions & 2 deletions test/compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
convertToFlagfile,
createCompilerOptionsForPage,
} from "../src/compiler";
import { ExtendedCompilerOptions } from "../src/compiler-core";
import { DuckConfig } from "../src/duckconfig";
import type { ExtendedCompilerOptions } from "../src/compiler-core";
import type { DuckConfig } from "../src/duckconfig";
import { PlovrMode } from "../src/entryconfig";

const emptyDuckConfig: DuckConfig = {} as DuckConfig;
Expand Down
2 changes: 1 addition & 1 deletion types/@samverschueren/stream-to-observable.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// / <reference types="node" />

import { Observable } from "rxjs";
import type { Observable } from "rxjs";

interface Options {
/**
Expand Down
2 changes: 1 addition & 1 deletion types/google-closure-compiler/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChildProcess } from "child_process";
import type { ChildProcess } from "child_process";

/**
* Types for google-closure-compiler
Expand Down