Strict type imports (#17)
When a symbols is only used as a type, require `import type {…}`
This commit is contained in:
parent
58d2683e38
commit
1088a78079
11 changed files with 19 additions and 18 deletions
|
@ -1,5 +1,5 @@
|
|||
import type { Device } from '../../boundaries/hap'
|
||||
import { Logger } from 'homebridge'
|
||||
import type { Logger } from 'homebridge'
|
||||
|
||||
type Pin = string
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { HttpServer } from '../../http'
|
||||
import type { HttpServer } from '../../http'
|
||||
|
||||
export interface HttpResponse {
|
||||
statusCode?: number
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import z from 'zod'
|
||||
import type z from 'zod'
|
||||
|
||||
type Path = (string | number)[]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { API } from 'homebridge'
|
||||
import type { API } from 'homebridge'
|
||||
|
||||
import { PLATFORM_NAME } from './settings'
|
||||
import { PrometheusExporterPlatform } from './platform'
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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) {}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"rootDir": "./",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"importsNotUsedAsValues": "error",
|
||||
"noImplicitAny": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue