Strict type imports (#17)

When a symbols is only used as a type, require `import type {…}`
This commit is contained in:
Lars Strojny 2022-11-10 13:00:45 +01:00 committed by GitHub
parent 58d2683e38
commit 1088a78079
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 19 additions and 18 deletions

View file

@ -1,5 +1,5 @@
import type { Device } from '../../boundaries/hap'
import { Logger } from 'homebridge'
import type { Logger } from 'homebridge'
type Pin = string

View file

@ -1,7 +1,7 @@
import type { HapDiscover } from './api'
import { HAPNodeJSClient } from 'hap-node-client'
import { Device, DeviceBoundary, checkBoundary } from '../../boundaries'
import { Logger } from 'homebridge'
import type { Logger } from 'homebridge'
import z from 'zod'
const MaybeDevices = z.array(z.unknown())

View file

@ -1,4 +1,4 @@
import { HttpServer } from '../../http'
import type { HttpServer } from '../../http'
export interface HttpResponse {
statusCode?: number

View file

@ -1,6 +1,6 @@
import Fastify, { FastifyReply, FastifyRequest, HookHandlerDoneFunction } from 'fastify'
import { HttpAdapter, HttpResponse } from './api'
import { HttpServer } from '../../http'
import type { HttpAdapter, HttpResponse } from './api'
import type { HttpServer } from '../../http'
function adaptResponseToReply(response: HttpResponse, reply: FastifyReply): void {
if (response.statusCode) {

View file

@ -1,4 +1,4 @@
import z from 'zod'
import type z from 'zod'
type Path = (string | number)[]

View file

@ -1,7 +1,7 @@
import { HttpResponse } from './adapters/http/api'
import { Metric } from './metrics'
import { Logger } from 'homebridge'
import { RequestListener, Server } from 'http'
import type { HttpResponse } from './adapters/http/api'
import type { Metric } from './metrics'
import type { Logger } from 'homebridge'
import type { RequestListener, Server } from 'http'
export interface HttpServer {
port: number

View file

@ -1,4 +1,4 @@
import { API } from 'homebridge'
import type { API } from 'homebridge'
import { PLATFORM_NAME } from './settings'
import { PrometheusExporterPlatform } from './platform'

View file

@ -1,9 +1,9 @@
import { API, IndependentPlatformPlugin, Logger, PlatformConfig } from 'homebridge'
import type { API, IndependentPlatformPlugin, Logger, PlatformConfig } from 'homebridge'
import { aggregate } from './metrics'
import { discover } from './adapters/discovery/hap_node_js_client'
import { serve } from './adapters/http/fastify'
import { HttpServerController } from './adapters/http/api'
import type { HttpServerController } from './adapters/http/api'
import { PrometheusServer } from './prometheus'
import { Config, ConfigBoundary, checkBoundary } from './boundaries'

View file

@ -1,7 +1,7 @@
import { Metric } from './metrics'
import { Logger } from 'homebridge'
import { HttpResponse } from './adapters/http/api'
import { HttpServer } from './http'
import type { Metric } from './metrics'
import type { Logger } from 'homebridge'
import type { HttpResponse } from './adapters/http/api'
import type { HttpServer } from './http'
export class MetricsRenderer {
constructor(private readonly prefix: string) {}

View file

@ -3,7 +3,7 @@ import request from 'supertest'
import { PrometheusServer } from '../../../src/prometheus'
import { serve } from '../../../src/adapters/http/fastify'
import { Server, createServer } from 'http'
import { HttpServer } from '../../../src/http'
import type { HttpServer } from '../../../src/http'
import { Metric } from '../../../src/metrics'
class TestablePrometheusServer extends PrometheusServer {

View file

@ -10,6 +10,7 @@
"rootDir": "./",
"strict": true,
"esModuleInterop": true,
"importsNotUsedAsValues": "error",
"noImplicitAny": true,
"resolveJsonModule": true
},