diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3fc35045bf..bac684470d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,3 +34,9 @@ jobs: - name: Lint JS snippets in docs run: npm run lint:docs + + - name: Lint Tests + run: npm run lint:tests + + - name: Lint Typings + run: npm run lint:typings diff --git a/package.json b/package.json index db5d001441..fa36f4e633 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ "lint": "npm run lint:docs && npm run lint:code", "lint:code": "eslint index.js promise.js index.d.ts promise.d.ts \"typings/**/*.ts\" \"lib/**/*.js\" \"test/**/*.{js,ts}\" \"benchmarks/**/*.js\"", "lint:docs": "eslint Contributing.md README.md", + "lint:typings": "npx prettier --check ./typings", + "lint:tests": "npx prettier --check ./test", "test": "poku --debug --include=\"test/esm,test/unit,test/integration\"", "test:bun": "poku --debug --platform=\"bun\" --include=\"test/esm,test/unit,test/integration\"", "test:tsc-build": "cd \"test/tsc-build\" && npx tsc -p \"tsconfig.json\"", diff --git a/test/esm/integration/test-pool.test.mjs b/test/esm/integration/test-pool.test.mjs index 3c42eb5bd7..d10362d379 100644 --- a/test/esm/integration/test-pool.test.mjs +++ b/test/esm/integration/test-pool.test.mjs @@ -1,6 +1,6 @@ import { assert, test, describe } from 'poku'; import mysql from '../../../index.js'; -import {describeOptions} from '../../common.test.cjs'; +import { describeOptions } from '../../common.test.cjs'; const poolConfig = {}; // config: { connectionConfig: {} }; diff --git a/test/tsc-build/mysql/createPoolCluster/getConnection.test.ts b/test/tsc-build/mysql/createPoolCluster/getConnection.test.ts index 33c89dce17..5ccfaa3583 100644 --- a/test/tsc-build/mysql/createPoolCluster/getConnection.test.ts +++ b/test/tsc-build/mysql/createPoolCluster/getConnection.test.ts @@ -1,5 +1,11 @@ import { mysql } from '../../index.test.js'; -import { access, uriAccess, sql, sqlPS, values } from '../baseConnection.test.js'; +import { + access, + uriAccess, + sql, + sqlPS, + values, +} from '../baseConnection.test.js'; const poolCluster = mysql.createPoolCluster(); diff --git a/test/tsc-build/mysql/createPoolCluster/of/getConnection.test.ts b/test/tsc-build/mysql/createPoolCluster/of/getConnection.test.ts index 2ee50ccdc8..79e1e1f267 100644 --- a/test/tsc-build/mysql/createPoolCluster/of/getConnection.test.ts +++ b/test/tsc-build/mysql/createPoolCluster/of/getConnection.test.ts @@ -1,5 +1,11 @@ import { mysql } from '../../../index.test.js'; -import { access, uriAccess, sql, sqlPS, values } from '../../baseConnection.test.js'; +import { + access, + uriAccess, + sql, + sqlPS, + values, +} from '../../baseConnection.test.js'; const poolCluster = mysql.createPoolCluster(); diff --git a/test/tsc-build/mysql/createPoolCluster/of/of.test.ts b/test/tsc-build/mysql/createPoolCluster/of/of.test.ts index 936e8c73ea..bdeb98fde1 100644 --- a/test/tsc-build/mysql/createPoolCluster/of/of.test.ts +++ b/test/tsc-build/mysql/createPoolCluster/of/of.test.ts @@ -1,5 +1,11 @@ import { mysql } from '../../../index.test.js'; -import { access, uriAccess, sql, sqlPS, values } from '../../baseConnection.test.js'; +import { + access, + uriAccess, + sql, + sqlPS, + values, +} from '../../baseConnection.test.js'; const poolCluster = mysql.createPoolCluster(); diff --git a/test/tsc-build/promise/createPoolCluster/getConnection.test.ts b/test/tsc-build/promise/createPoolCluster/getConnection.test.ts index 1aecf17c98..878fd0901e 100644 --- a/test/tsc-build/promise/createPoolCluster/getConnection.test.ts +++ b/test/tsc-build/promise/createPoolCluster/getConnection.test.ts @@ -1,5 +1,11 @@ import { mysqlp as mysql } from '../../index.test.js'; -import { access, uriAccess, sql, sqlPS, values } from '../baseConnection.test.js'; +import { + access, + uriAccess, + sql, + sqlPS, + values, +} from '../baseConnection.test.js'; const poolCluster = mysql.createPoolCluster(); diff --git a/test/tsc-build/promise/createPoolCluster/of/getConnection.test.ts b/test/tsc-build/promise/createPoolCluster/of/getConnection.test.ts index 88debbfac1..c2341c99a8 100644 --- a/test/tsc-build/promise/createPoolCluster/of/getConnection.test.ts +++ b/test/tsc-build/promise/createPoolCluster/of/getConnection.test.ts @@ -1,5 +1,11 @@ import { mysqlp as mysql } from '../../../index.test.js'; -import { access, uriAccess, sql, sqlPS, values } from '../../baseConnection.test.js'; +import { + access, + uriAccess, + sql, + sqlPS, + values, +} from '../../baseConnection.test.js'; const poolCluster = mysql.createPoolCluster(); diff --git a/test/tsc-build/promise/createPoolCluster/of/of.test.ts b/test/tsc-build/promise/createPoolCluster/of/of.test.ts index 2c73078b46..2ab60f8144 100644 --- a/test/tsc-build/promise/createPoolCluster/of/of.test.ts +++ b/test/tsc-build/promise/createPoolCluster/of/of.test.ts @@ -1,5 +1,11 @@ import { mysqlp as mysql } from '../../../index.test.js'; -import { access, uriAccess, sql, sqlPS, values } from '../../baseConnection.test.js'; +import { + access, + uriAccess, + sql, + sqlPS, + values, +} from '../../baseConnection.test.js'; const poolCluster = mysql.createPoolCluster(); diff --git a/test/tsc-build/tsconfig.json b/test/tsc-build/tsconfig.json index d08e47e051..8c01d8dc9d 100644 --- a/test/tsc-build/tsconfig.json +++ b/test/tsc-build/tsconfig.json @@ -1,5 +1,11 @@ { - "include": ["index.test.ts", "helpers.test.ts", "mysql", "promise", "strict-checks"], + "include": [ + "index.test.ts", + "helpers.test.ts", + "mysql", + "promise", + "strict-checks" + ], "compilerOptions": { "target": "ES2016", "module": "CommonJS", diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index b7fd83a90c..7dafa9cbf3 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -62,14 +62,14 @@ export function format( sql: string, values: any[], stringifyObjects?: boolean, - timeZone?: string + timeZone?: string, ): string; export function format( sql: string, values: any, stringifyObjects?: boolean, - timeZone?: string + timeZone?: string, ): string; export function raw(sql: string): { diff --git a/typings/mysql/lib/Auth.d.ts b/typings/mysql/lib/Auth.d.ts index bfb32bdba6..13374a9485 100644 --- a/typings/mysql/lib/Auth.d.ts +++ b/typings/mysql/lib/Auth.d.ts @@ -5,7 +5,7 @@ export type AuthPlugin = (pluginMetadata: { connection: Connection; command: string; }) => ( - pluginData: Buffer + pluginData: Buffer, ) => Promise | string | Buffer | Promise | null; type AuthPluginDefinition = (pluginOptions?: T) => AuthPlugin; diff --git a/typings/mysql/lib/Pool.d.ts b/typings/mysql/lib/Pool.d.ts index 90ed5e9bad..042495e71f 100644 --- a/typings/mysql/lib/Pool.d.ts +++ b/typings/mysql/lib/Pool.d.ts @@ -43,14 +43,14 @@ declare class Pool extends QueryableBase(ExecutableBase(EventEmitter)) { getConnection( callback: ( err: NodeJS.ErrnoException | null, - connection: PoolConnection - ) => any + connection: PoolConnection, + ) => any, ): void; releaseConnection(connection: PoolConnection | PromisePoolConnection): void; end( - callback?: (err: NodeJS.ErrnoException | null, ...args: any[]) => any + callback?: (err: NodeJS.ErrnoException | null, ...args: any[]) => any, ): void; on(event: string, listener: (...args: any[]) => void): this; diff --git a/typings/mysql/lib/PoolCluster.d.ts b/typings/mysql/lib/PoolCluster.d.ts index 476d3de493..2be0be860c 100644 --- a/typings/mysql/lib/PoolCluster.d.ts +++ b/typings/mysql/lib/PoolCluster.d.ts @@ -6,7 +6,7 @@ import { QueryableBase as QueryableBaseClass } from './protocol/sequences/Querya // Expose class interfaces declare class QueryableAndExecutableBase extends QueryableBaseClass( - ExecutableBaseClass(EventEmitter) + ExecutableBaseClass(EventEmitter), ) {} export interface PoolClusterOptions { @@ -40,8 +40,8 @@ export interface PoolNamespace extends QueryableAndExecutableBase { getConnection( callback: ( err: NodeJS.ErrnoException | null, - connection: PoolConnection - ) => any + connection: PoolConnection, + ) => any, ): void; } @@ -57,23 +57,23 @@ declare class PoolCluster extends EventEmitter { getConnection( callback: ( err: NodeJS.ErrnoException | null, - connection: PoolConnection - ) => void + connection: PoolConnection, + ) => void, ): void; getConnection( group: string, callback: ( err: NodeJS.ErrnoException | null, - connection: PoolConnection - ) => void + connection: PoolConnection, + ) => void, ): void; getConnection( group: string, selector: string, callback: ( err: NodeJS.ErrnoException | null, - connection: PoolConnection - ) => void + connection: PoolConnection, + ) => void, ): void; of(pattern: string, selector?: string): PoolNamespace; diff --git a/typings/mysql/lib/protocol/packets/FieldPacket.d.ts b/typings/mysql/lib/protocol/packets/FieldPacket.d.ts index 316c44ed77..7e886691ef 100644 --- a/typings/mysql/lib/protocol/packets/FieldPacket.d.ts +++ b/typings/mysql/lib/protocol/packets/FieldPacket.d.ts @@ -17,7 +17,7 @@ declare interface FieldPacket { protocol41?: boolean; table: string; type?: number; - columnType?: number + columnType?: number; zerofill?: boolean; typeName?: string; encoding?: string; diff --git a/typings/mysql/lib/protocol/packets/ProcedurePacket.d.ts b/typings/mysql/lib/protocol/packets/ProcedurePacket.d.ts index 47e51fd4b5..ff5efb63ed 100644 --- a/typings/mysql/lib/protocol/packets/ProcedurePacket.d.ts +++ b/typings/mysql/lib/protocol/packets/ProcedurePacket.d.ts @@ -7,7 +7,7 @@ declare type ProcedureCallPacket< > = T extends RowDataPacket[] ? [T, ResultSetHeader] : T extends ResultSetHeader | OkPacket - ? ResultSetHeader - : [RowDataPacket[], ResultSetHeader] | ResultSetHeader; + ? ResultSetHeader + : [RowDataPacket[], ResultSetHeader] | ResultSetHeader; export { ProcedureCallPacket }; diff --git a/typings/mysql/lib/protocol/sequences/ExecutableBase.d.ts b/typings/mysql/lib/protocol/sequences/ExecutableBase.d.ts index 5242b03a70..ba37c2efe1 100644 --- a/typings/mysql/lib/protocol/sequences/ExecutableBase.d.ts +++ b/typings/mysql/lib/protocol/sequences/ExecutableBase.d.ts @@ -1,7 +1,4 @@ -import { - FieldPacket, - QueryResult, -} from '../packets/index.js'; +import { FieldPacket, QueryResult } from '../packets/index.js'; import { Query, QueryError, @@ -10,34 +7,34 @@ import { } from './Query.js'; export declare function ExecutableBase( - Base?: T + Base?: T, ): { new (...args: any[]): { execute( sql: string, callback?: | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any) - | undefined + | undefined, ): Query; execute( sql: string, values: any, callback?: | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any) - | undefined + | undefined, ): Query; execute( options: QueryOptions, callback?: | ((err: QueryError | null, result: T, fields?: FieldPacket[]) => any) - | undefined + | undefined, ): Query; execute( options: QueryOptions, values: any, callback?: | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any) - | undefined + | undefined, ): Query; }; } & T; diff --git a/typings/mysql/lib/protocol/sequences/Prepare.d.ts b/typings/mysql/lib/protocol/sequences/Prepare.d.ts index ef13801611..bdd91a0930 100644 --- a/typings/mysql/lib/protocol/sequences/Prepare.d.ts +++ b/typings/mysql/lib/protocol/sequences/Prepare.d.ts @@ -16,10 +16,14 @@ export class PrepareStatementInfo { | RowDataPacket[] | OkPacket | OkPacket[] - | ResultSetHeader + | ResultSetHeader, >( parameters: any | any[] | { [param: string]: any }, - callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any + callback?: ( + err: QueryError | null, + result: T, + fields: FieldPacket[], + ) => any, ): Query; } @@ -53,11 +57,11 @@ declare class Prepare extends Sequence { on(event: 'error', listener: (err: QueryError) => any): this; on( event: 'fields', - listener: (fields: FieldPacket, index: number) => any + listener: (fields: FieldPacket, index: number) => any, ): this; on( event: 'result', - listener: (result: RowDataPacket | OkPacket, index: number) => any + listener: (result: RowDataPacket | OkPacket, index: number) => any, ): this; on(event: 'end', listener: () => any): this; } diff --git a/typings/mysql/lib/protocol/sequences/QueryableBase.d.ts b/typings/mysql/lib/protocol/sequences/QueryableBase.d.ts index 935d948229..2c2060d285 100644 --- a/typings/mysql/lib/protocol/sequences/QueryableBase.d.ts +++ b/typings/mysql/lib/protocol/sequences/QueryableBase.d.ts @@ -1,7 +1,4 @@ -import { - FieldPacket, - QueryResult, -} from '../packets/index.js'; +import { FieldPacket, QueryResult } from '../packets/index.js'; import { Query, QueryError, @@ -10,34 +7,34 @@ import { } from './Query.js'; export declare function QueryableBase( - Base?: T + Base?: T, ): { new (...args: any[]): { query( sql: string, callback?: | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any) - | undefined + | undefined, ): Query; query( sql: string, values: any, callback?: | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any) - | undefined + | undefined, ): Query; query( options: QueryOptions, callback?: | ((err: QueryError | null, result: T, fields?: FieldPacket[]) => any) - | undefined + | undefined, ): Query; query( options: QueryOptions, values: any, callback?: | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any) - | undefined + | undefined, ): Query; }; } & T; diff --git a/typings/mysql/lib/protocol/sequences/promise/ExecutableBase.d.ts b/typings/mysql/lib/protocol/sequences/promise/ExecutableBase.d.ts index 17de50b8be..aec027b5ae 100644 --- a/typings/mysql/lib/protocol/sequences/promise/ExecutableBase.d.ts +++ b/typings/mysql/lib/protocol/sequences/promise/ExecutableBase.d.ts @@ -1,26 +1,21 @@ -import { - FieldPacket, - QueryResult, -} from '../../packets/index.js'; +import { FieldPacket, QueryResult } from '../../packets/index.js'; import { QueryOptions, QueryableConstructor } from '../Query.js'; export declare function ExecutableBase( - Base?: T + Base?: T, ): { new (...args: any[]): { - execute( - sql: string - ): Promise<[T, FieldPacket[]]>; + execute(sql: string): Promise<[T, FieldPacket[]]>; execute( sql: string, - values: any + values: any, ): Promise<[T, FieldPacket[]]>; execute( - options: QueryOptions + options: QueryOptions, ): Promise<[T, FieldPacket[]]>; execute( options: QueryOptions, - values: any + values: any, ): Promise<[T, FieldPacket[]]>; }; } & T; diff --git a/typings/mysql/lib/protocol/sequences/promise/QueryableBase.d.ts b/typings/mysql/lib/protocol/sequences/promise/QueryableBase.d.ts index c578627cb1..0240431041 100644 --- a/typings/mysql/lib/protocol/sequences/promise/QueryableBase.d.ts +++ b/typings/mysql/lib/protocol/sequences/promise/QueryableBase.d.ts @@ -1,26 +1,21 @@ -import { - FieldPacket, - QueryResult, -} from '../../packets/index.js'; +import { FieldPacket, QueryResult } from '../../packets/index.js'; import { QueryOptions, QueryableConstructor } from '../Query.js'; export declare function QueryableBase( - Base?: T + Base?: T, ): { new (...args: any[]): { - query( - sql: string - ): Promise<[T, FieldPacket[]]>; + query(sql: string): Promise<[T, FieldPacket[]]>; query( sql: string, - values: any + values: any, ): Promise<[T, FieldPacket[]]>; query( - options: QueryOptions + options: QueryOptions, ): Promise<[T, FieldPacket[]]>; query( options: QueryOptions, - values: any + values: any, ): Promise<[T, FieldPacket[]]>; }; } & T;