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 type { Device } from '../../boundaries/hap'
|
||||||
import { Logger } from 'homebridge'
|
import type { Logger } from 'homebridge'
|
||||||
|
|
||||||
type Pin = string
|
type Pin = string
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { HapDiscover } from './api'
|
import type { HapDiscover } from './api'
|
||||||
import { HAPNodeJSClient } from 'hap-node-client'
|
import { HAPNodeJSClient } from 'hap-node-client'
|
||||||
import { Device, DeviceBoundary, checkBoundary } from '../../boundaries'
|
import { Device, DeviceBoundary, checkBoundary } from '../../boundaries'
|
||||||
import { Logger } from 'homebridge'
|
import type { Logger } from 'homebridge'
|
||||||
import z from 'zod'
|
import z from 'zod'
|
||||||
|
|
||||||
const MaybeDevices = z.array(z.unknown())
|
const MaybeDevices = z.array(z.unknown())
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { HttpServer } from '../../http'
|
import type { HttpServer } from '../../http'
|
||||||
|
|
||||||
export interface HttpResponse {
|
export interface HttpResponse {
|
||||||
statusCode?: number
|
statusCode?: number
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Fastify, { FastifyReply, FastifyRequest, HookHandlerDoneFunction } from 'fastify'
|
import Fastify, { FastifyReply, FastifyRequest, HookHandlerDoneFunction } from 'fastify'
|
||||||
import { HttpAdapter, HttpResponse } from './api'
|
import type { HttpAdapter, HttpResponse } from './api'
|
||||||
import { HttpServer } from '../../http'
|
import type { HttpServer } from '../../http'
|
||||||
|
|
||||||
function adaptResponseToReply(response: HttpResponse, reply: FastifyReply): void {
|
function adaptResponseToReply(response: HttpResponse, reply: FastifyReply): void {
|
||||||
if (response.statusCode) {
|
if (response.statusCode) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import z from 'zod'
|
import type z from 'zod'
|
||||||
|
|
||||||
type Path = (string | number)[]
|
type Path = (string | number)[]
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { HttpResponse } from './adapters/http/api'
|
import type { HttpResponse } from './adapters/http/api'
|
||||||
import { Metric } from './metrics'
|
import type { Metric } from './metrics'
|
||||||
import { Logger } from 'homebridge'
|
import type { Logger } from 'homebridge'
|
||||||
import { RequestListener, Server } from 'http'
|
import type { RequestListener, Server } from 'http'
|
||||||
|
|
||||||
export interface HttpServer {
|
export interface HttpServer {
|
||||||
port: number
|
port: number
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { API } from 'homebridge'
|
import type { API } from 'homebridge'
|
||||||
|
|
||||||
import { PLATFORM_NAME } from './settings'
|
import { PLATFORM_NAME } from './settings'
|
||||||
import { PrometheusExporterPlatform } from './platform'
|
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 { aggregate } from './metrics'
|
||||||
import { discover } from './adapters/discovery/hap_node_js_client'
|
import { discover } from './adapters/discovery/hap_node_js_client'
|
||||||
import { serve } from './adapters/http/fastify'
|
import { serve } from './adapters/http/fastify'
|
||||||
import { HttpServerController } from './adapters/http/api'
|
import type { HttpServerController } from './adapters/http/api'
|
||||||
import { PrometheusServer } from './prometheus'
|
import { PrometheusServer } from './prometheus'
|
||||||
import { Config, ConfigBoundary, checkBoundary } from './boundaries'
|
import { Config, ConfigBoundary, checkBoundary } from './boundaries'
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Metric } from './metrics'
|
import type { Metric } from './metrics'
|
||||||
import { Logger } from 'homebridge'
|
import type { Logger } from 'homebridge'
|
||||||
import { HttpResponse } from './adapters/http/api'
|
import type { HttpResponse } from './adapters/http/api'
|
||||||
import { HttpServer } from './http'
|
import type { HttpServer } from './http'
|
||||||
|
|
||||||
export class MetricsRenderer {
|
export class MetricsRenderer {
|
||||||
constructor(private readonly prefix: string) {}
|
constructor(private readonly prefix: string) {}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import request from 'supertest'
|
||||||
import { PrometheusServer } from '../../../src/prometheus'
|
import { PrometheusServer } from '../../../src/prometheus'
|
||||||
import { serve } from '../../../src/adapters/http/fastify'
|
import { serve } from '../../../src/adapters/http/fastify'
|
||||||
import { Server, createServer } from 'http'
|
import { Server, createServer } from 'http'
|
||||||
import { HttpServer } from '../../../src/http'
|
import type { HttpServer } from '../../../src/http'
|
||||||
import { Metric } from '../../../src/metrics'
|
import { Metric } from '../../../src/metrics'
|
||||||
|
|
||||||
class TestablePrometheusServer extends PrometheusServer {
|
class TestablePrometheusServer extends PrometheusServer {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"rootDir": "./",
|
"rootDir": "./",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
"importsNotUsedAsValues": "error",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue