@textlint/kernel
Advanced tools
Comparing version
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createPaddingLocator = exports.isTextlintRuleErrorPaddingLocation = exports.isTextlintRuleErrorPaddingLocRange = exports.isTextlintRuleErrorPaddingLocObject = void 0; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const isTextlintRuleErrorPaddingLocObject = (loc) => { | ||
@@ -18,2 +19,3 @@ return (typeof loc === "object" && | ||
exports.isTextlintRuleErrorPaddingLocObject = isTextlintRuleErrorPaddingLocObject; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const isTextlintRuleErrorPaddingLocRange = (range) => { | ||
@@ -23,2 +25,3 @@ return Array.isArray(range) && range.length === 2; | ||
exports.isTextlintRuleErrorPaddingLocRange = isTextlintRuleErrorPaddingLocRange; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const isTextlintRuleErrorPaddingLocation = (o) => { | ||
@@ -25,0 +28,0 @@ return (typeof o === "object" && |
@@ -5,3 +5,3 @@ import type { TextlintRuleContextReportFunctionArgs, TextlintRuleError, TextlintRuleErrorPaddingLocation, TextlintSourceCode } from "@textlint/types"; | ||
ruleId: string; | ||
node: any; | ||
node: TxtNode; | ||
severity: number; | ||
@@ -8,0 +8,0 @@ ruleError: TextlintRuleError; |
@@ -9,3 +9,3 @@ import { Descriptor } from "./Descriptor.js"; | ||
*/ | ||
export declare const filterDuplicateDescriptor: <T extends Descriptor<any>>(descriptors: T[]) => T[]; | ||
export declare const filterDuplicateDescriptor: <T extends Descriptor<unknown>>(descriptors: T[]) => T[]; | ||
//# sourceMappingURL=DescriptorUtil.d.ts.map |
@@ -7,11 +7,11 @@ import type { TextlintFilterRuleReporter, TextlintRuleReporter } from "@textlint/types"; | ||
*/ | ||
export declare function hasLinter(ruleCreator: any): boolean; | ||
export declare function hasLinter(ruleCreator: unknown): boolean; | ||
/** | ||
* get linter function from ruleCreator | ||
* if not found, throw error | ||
* @param {Function|Object|any} ruleCreator | ||
* @returns {Function} linter function | ||
* @param {((...args: any[]) => any)|Object|any} ruleCreator | ||
* @returns {(...args: any[]) => any} linter function | ||
* @throws | ||
*/ | ||
export declare function getLinter(ruleCreator: Function | object | any): TextlintRuleReporter; | ||
export declare function getLinter(ruleCreator: unknown): TextlintRuleReporter; | ||
/** | ||
@@ -22,11 +22,11 @@ * detect that ruleCreator has fixer function | ||
*/ | ||
export declare function hasFixer(ruleCreator: any): boolean; | ||
export declare function hasFixer(ruleCreator: unknown): boolean; | ||
/** | ||
* get fixer function from ruleCreator | ||
* if not found, throw error | ||
* @param {Function|Object|any} ruleCreator | ||
* @returns {Function} fixer function | ||
* @param {((...args: any[]) => any)|Object|any} ruleCreator | ||
* @returns {(...args: any[]) => any} fixer function | ||
* @throws | ||
*/ | ||
export declare function getFixer(ruleCreator: Function | object | any): TextlintRuleReporter; | ||
export declare function getFixer(ruleCreator: unknown): TextlintRuleReporter; | ||
/** | ||
@@ -37,3 +37,3 @@ * RuleModule should has either linter or fixer. | ||
**/ | ||
export declare function isRuleModule(ruleCreator: any): boolean; | ||
export declare function isRuleModule(ruleCreator: unknown): boolean; | ||
/** | ||
@@ -46,3 +46,3 @@ * Validate rule module. | ||
*/ | ||
export declare function assertRuleShape(ruleModule: any, key?: string): void; | ||
export declare function assertRuleShape(ruleModule: unknown, key?: string): void; | ||
/** | ||
@@ -52,6 +52,6 @@ * get linter function from ruleCreator | ||
* @param {*} ruleCreator | ||
* @returns {Function} linter function | ||
* @returns {(...args: any[]) => any} linter function | ||
* @throws | ||
*/ | ||
export declare function getFilter(ruleCreator: any): TextlintFilterRuleReporter; | ||
export declare function getFilter(ruleCreator: unknown): TextlintFilterRuleReporter; | ||
//# sourceMappingURL=rule-creator-helper.d.ts.map |
@@ -10,2 +10,12 @@ "use strict"; | ||
exports.getFilter = getFilter; | ||
// Type guards | ||
function isObjectWithProperty(obj, property) { | ||
return typeof obj === "object" && obj !== null && property in obj; | ||
} | ||
function hasLinterProperty(obj) { | ||
return isObjectWithProperty(obj, "linter"); | ||
} | ||
function hasFixerProperty(obj) { | ||
return isObjectWithProperty(obj, "fixer"); | ||
} | ||
/** | ||
@@ -17,3 +27,3 @@ * detect that ruleCreator has linter function | ||
function hasLinter(ruleCreator) { | ||
if (typeof ruleCreator.linter === "function") { | ||
if (hasLinterProperty(ruleCreator) && typeof ruleCreator.linter === "function") { | ||
return true; | ||
@@ -29,8 +39,8 @@ } | ||
* if not found, throw error | ||
* @param {Function|Object|any} ruleCreator | ||
* @returns {Function} linter function | ||
* @param {((...args: any[]) => any)|Object|any} ruleCreator | ||
* @returns {(...args: any[]) => any} linter function | ||
* @throws | ||
*/ | ||
function getLinter(ruleCreator) { | ||
if (typeof ruleCreator.linter === "function") { | ||
if (hasLinterProperty(ruleCreator) && typeof ruleCreator.linter === "function") { | ||
return ruleCreator.linter; | ||
@@ -49,3 +59,3 @@ } | ||
function hasFixer(ruleCreator) { | ||
return typeof ruleCreator.fixer === "function" && hasLinter(ruleCreator); | ||
return hasFixerProperty(ruleCreator) && typeof ruleCreator.fixer === "function" && hasLinter(ruleCreator); | ||
} | ||
@@ -55,4 +65,4 @@ /** | ||
* if not found, throw error | ||
* @param {Function|Object|any} ruleCreator | ||
* @returns {Function} fixer function | ||
* @param {((...args: any[]) => any)|Object|any} ruleCreator | ||
* @returns {(...args: any[]) => any} fixer function | ||
* @throws | ||
@@ -64,3 +74,3 @@ */ | ||
} | ||
if (hasFixer(ruleCreator)) { | ||
if (hasFixerProperty(ruleCreator) && typeof ruleCreator.fixer === "function") { | ||
return ruleCreator.fixer; | ||
@@ -107,3 +117,3 @@ } | ||
* @param {*} ruleCreator | ||
* @returns {Function} linter function | ||
* @returns {(...args: any[]) => any} linter function | ||
* @throws | ||
@@ -110,0 +120,0 @@ */ |
@@ -54,6 +54,3 @@ import { TextlintKernelFilterRule, TextlintKernelOptions, TextlintKernelPlugin, TextlintKernelRule } from "../textlint-kernel-interface.js"; | ||
id: string; | ||
options: { | ||
[index: string]: any; | ||
severity?: import("@textlint/types").TextlintRuleSeverityLevelKey; | ||
}; | ||
options: import("@textlint/types").TextlintRuleOptions; | ||
}[]; | ||
@@ -60,0 +57,0 @@ filterRule: { |
@@ -37,8 +37,5 @@ import { TextlintKernelRule } from "../textlint-kernel-interface.js"; | ||
id: string; | ||
options: { | ||
[index: string]: any; | ||
severity?: import("@textlint/types").TextlintRuleSeverityLevelKey; | ||
}; | ||
options: TextlintRuleOptions; | ||
}; | ||
} | ||
//# sourceMappingURL=TextlintLintableRuleDescriptor.d.ts.map |
@@ -38,8 +38,5 @@ import { TextlintKernelRule } from "../textlint-kernel-interface.js"; | ||
id: string; | ||
options: { | ||
[index: string]: any; | ||
severity?: import("@textlint/types").TextlintRuleSeverityLevelKey; | ||
}; | ||
options: import("@textlint/types").TextlintRuleOptions; | ||
}[]; | ||
} | ||
//# sourceMappingURL=TextlintRuleDescriptors.d.ts.map |
@@ -75,4 +75,6 @@ // LICENSE : MIT | ||
const messages = await task_runner_js_1.default.process(task); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const result = await postProcess(messages, sourceCode.filePath); | ||
const filteredResult = { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
messages: this.messageProcessManager.process(result.messages), | ||
@@ -79,0 +81,0 @@ filePath: result.filePath ? result.filePath : `<Unknown{sourceCode.ext}>` |
@@ -33,3 +33,5 @@ // LICENSE : MIT | ||
const messages = await task_runner_js_1.default.process(task); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const result = await postProcess(messages, sourceCode.filePath); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
result.messages = this.messageProcessManager.process(result.messages); | ||
@@ -36,0 +38,0 @@ if (result.filePath == null) { |
@@ -19,5 +19,5 @@ import type { TextlintMessage } from "@textlint/types"; | ||
* @param {Config} config | ||
* @returns {Function} filter function for messages | ||
* @returns {(...args: any[]) => any} filter function for messages | ||
*/ | ||
export default function createSeverityFilter(config: TextlintKernelConstructorOptions): (messages: TextlintMessage[]) => TextlintMessage[]; | ||
//# sourceMappingURL=filter-severity-process.d.ts.map |
@@ -30,3 +30,3 @@ // LICENSE : MIT | ||
* @param {Config} config | ||
* @returns {Function} filter function for messages | ||
* @returns {(...args: any[]) => any} filter function for messages | ||
*/ | ||
@@ -33,0 +33,0 @@ function createSeverityFilter(config) { |
@@ -1,6 +0,6 @@ | ||
export type Listener = (...args: any[]) => void; | ||
export type Listener = (...args: unknown[]) => void; | ||
export declare class EventEmitter<T extends Listener = Listener> { | ||
#private; | ||
on(type: string, listener: T): void; | ||
emit(type: string, ...args: any[]): void; | ||
emit(type: string, ...args: unknown[]): void; | ||
off(type: string, listener: T): void; | ||
@@ -15,5 +15,5 @@ removeAllListeners(): void; | ||
listenerCount(type: string): number; | ||
on(event: string, listener: (...args: any[]) => Promise<void> | void): void; | ||
emit(event: string, ...args: any[]): Promise<void[]>; | ||
on(event: string, listener: (...args: unknown[]) => Promise<void> | void): void; | ||
emit(event: string, ...args: unknown[]): Promise<void[]>; | ||
} | ||
//# sourceMappingURL=promise-event-emitter.d.ts.map |
@@ -63,3 +63,3 @@ import { EventEmitter } from "./promise-event-emitter.js"; | ||
* add all the node types as listeners of the rule | ||
* @param {Function} ruleCreator | ||
* @param {(...args: any[]) => any} ruleCreator | ||
* @param {Readonly<RuleContext>|Readonly<FilterRuleContext>} ruleContext | ||
@@ -66,0 +66,0 @@ * @param {Object|boolean|undefined} ruleOptions |
@@ -165,3 +165,3 @@ // LICENSE : MIT | ||
* add all the node types as listeners of the rule | ||
* @param {Function} ruleCreator | ||
* @param {(...args: any[]) => any} ruleCreator | ||
* @param {Readonly<RuleContext>|Readonly<FilterRuleContext>} ruleContext | ||
@@ -168,0 +168,0 @@ * @param {Object|boolean|undefined} ruleOptions |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export declare function invariant(condition: any, message?: string): asserts condition; | ||
export declare function invariant(condition: unknown, message?: string): asserts condition; | ||
//# sourceMappingURL=invariant.d.ts.map |
@@ -7,6 +7,6 @@ /** | ||
export default class Logger { | ||
static log(...message: Array<any>): void; | ||
static warn(...message: Array<any>): void; | ||
static error(...message: Array<any>): void; | ||
static log(...message: Array<unknown>): void; | ||
static warn(...message: Array<unknown>): void; | ||
static error(...message: Array<unknown>): void; | ||
} | ||
//# sourceMappingURL=logger.d.ts.map |
declare const _default: { | ||
time: (key: string, fn: Function) => (...args: any[]) => Promise<void>; | ||
time: <T extends unknown[]>(key: string, fn: (...args: T) => unknown) => (...args: T) => Promise<void>; | ||
enabled: boolean; | ||
@@ -4,0 +4,0 @@ }; |
@@ -48,3 +48,3 @@ /** | ||
let total = 0; | ||
const rows = Object.keys(data) | ||
const sortedData = Object.keys(data) | ||
.map(function (key) { | ||
@@ -59,5 +59,7 @@ const time = data[key]; | ||
.slice(0, 10); | ||
const rows = [...sortedData]; | ||
rows.forEach(function (row) { | ||
row.push(`${((row[1] * 100) / total).toFixed(1)}%`); | ||
row[1] = row[1].toFixed(3); | ||
const time = row[1]; | ||
row.push(`${((time * 100) / total).toFixed(1)}%`); | ||
row[1] = time.toFixed(3); | ||
}); | ||
@@ -68,3 +70,3 @@ rows.unshift(HEADERS); | ||
for (let i = 0; i < row.length; i++) { | ||
const n = row[i].length; | ||
const n = String(row[i]).length; | ||
if (!widths[i] || n > widths[i]) { | ||
@@ -78,3 +80,3 @@ widths[i] = n; | ||
.map(function (cell, index) { | ||
return ALIGN[index](cell, widths[index]); | ||
return ALIGN[index](String(cell), widths[index]); | ||
}) | ||
@@ -99,4 +101,4 @@ .join(" | "); | ||
* @param {*} key key from the data object | ||
* @param {Function} fn function to be called | ||
* @returns {Function} function to be executed | ||
* @param {(...args: any[]) => any} fn function to be called | ||
* @returns {(...args: any[]) => any} function to be executed | ||
* @private | ||
@@ -103,0 +105,0 @@ */ |
{ | ||
"name": "@textlint/kernel", | ||
"version": "15.1.0", | ||
"version": "15.1.1", | ||
"description": "textlint kernel is core logic by pure JavaScript.", | ||
@@ -40,9 +40,9 @@ "keywords": [ | ||
"dependencies": { | ||
"@textlint/ast-node-types": "15.1.0", | ||
"@textlint/ast-tester": "15.1.0", | ||
"@textlint/ast-traverse": "15.1.0", | ||
"@textlint/feature-flag": "15.1.0", | ||
"@textlint/source-code-fixer": "15.1.0", | ||
"@textlint/types": "15.1.0", | ||
"@textlint/utils": "15.1.0", | ||
"@textlint/ast-node-types": "15.1.1", | ||
"@textlint/ast-tester": "15.1.1", | ||
"@textlint/ast-traverse": "15.1.1", | ||
"@textlint/feature-flag": "15.1.1", | ||
"@textlint/source-code-fixer": "15.1.1", | ||
"@textlint/types": "15.1.1", | ||
"@textlint/utils": "15.1.1", | ||
"debug": "^4.4.1", | ||
@@ -53,3 +53,3 @@ "fast-equals": "^4.0.3", | ||
"devDependencies": { | ||
"@textlint/markdown-to-ast": "15.1.0", | ||
"@textlint/markdown-to-ast": "15.1.1", | ||
"@types/debug": "^4.1.12", | ||
@@ -64,3 +64,3 @@ "@types/node": "^18.19.112", | ||
}, | ||
"gitHead": "86a95c9f2ebfca072699aa93cf1a965f23765ec9" | ||
"gitHead": "1b3a571938c6bd73aac938266ef3315058077c81" | ||
} |
@@ -8,2 +8,3 @@ import { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const isTextlintRuleErrorPaddingLocObject = (loc: any): loc is TextlintRuleErrorPaddingLocationLoc => { | ||
@@ -24,5 +25,7 @@ return ( | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const isTextlintRuleErrorPaddingLocRange = (range: any): range is TextlintRuleErrorPaddingLocationRange => { | ||
return Array.isArray(range) && range.length === 2; | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const isTextlintRuleErrorPaddingLocation = (o: any): o is TextlintRuleErrorPaddingLocation => { | ||
@@ -29,0 +32,0 @@ return ( |
@@ -15,3 +15,3 @@ import type { | ||
ruleId: string; | ||
node: any; | ||
node: TxtNode; | ||
severity: number; | ||
@@ -18,0 +18,0 @@ ruleError: TextlintRuleError; |
@@ -10,3 +10,3 @@ import { Descriptor } from "./Descriptor.js"; | ||
*/ | ||
export const filterDuplicateDescriptor = <T extends Descriptor<any>>(descriptors: T[]) => { | ||
export const filterDuplicateDescriptor = <T extends Descriptor<unknown>>(descriptors: T[]) => { | ||
const newDescriptorList: T[] = []; | ||
@@ -13,0 +13,0 @@ descriptors.forEach((descriptor) => { |
import type { TextlintFilterRuleReporter, TextlintRuleReporter } from "@textlint/types"; | ||
// Type guards | ||
function isObjectWithProperty(obj: unknown, property: string): obj is Record<string, unknown> { | ||
return typeof obj === "object" && obj !== null && property in obj; | ||
} | ||
function hasLinterProperty(obj: unknown): obj is { linter: unknown } { | ||
return isObjectWithProperty(obj, "linter"); | ||
} | ||
function hasFixerProperty(obj: unknown): obj is { fixer: unknown } { | ||
return isObjectWithProperty(obj, "fixer"); | ||
} | ||
/** | ||
@@ -8,4 +21,4 @@ * detect that ruleCreator has linter function | ||
*/ | ||
export function hasLinter(ruleCreator: any): boolean { | ||
if (typeof ruleCreator.linter === "function") { | ||
export function hasLinter(ruleCreator: unknown): boolean { | ||
if (hasLinterProperty(ruleCreator) && typeof ruleCreator.linter === "function") { | ||
return true; | ||
@@ -22,12 +35,12 @@ } | ||
* if not found, throw error | ||
* @param {Function|Object|any} ruleCreator | ||
* @returns {Function} linter function | ||
* @param {((...args: any[]) => any)|Object|any} ruleCreator | ||
* @returns {(...args: any[]) => any} linter function | ||
* @throws | ||
*/ | ||
export function getLinter(ruleCreator: Function | object | any): TextlintRuleReporter { | ||
if (typeof ruleCreator.linter === "function") { | ||
return ruleCreator.linter; | ||
export function getLinter(ruleCreator: unknown): TextlintRuleReporter { | ||
if (hasLinterProperty(ruleCreator) && typeof ruleCreator.linter === "function") { | ||
return ruleCreator.linter as TextlintRuleReporter; | ||
} | ||
if (typeof ruleCreator === "function") { | ||
return ruleCreator; | ||
return ruleCreator as TextlintRuleReporter; | ||
} | ||
@@ -42,4 +55,4 @@ throw new Error("Not found linter function in the ruleCreator"); | ||
*/ | ||
export function hasFixer(ruleCreator: any): boolean { | ||
return typeof ruleCreator.fixer === "function" && hasLinter(ruleCreator); | ||
export function hasFixer(ruleCreator: unknown): boolean { | ||
return hasFixerProperty(ruleCreator) && typeof ruleCreator.fixer === "function" && hasLinter(ruleCreator); | ||
} | ||
@@ -50,12 +63,12 @@ | ||
* if not found, throw error | ||
* @param {Function|Object|any} ruleCreator | ||
* @returns {Function} fixer function | ||
* @param {((...args: any[]) => any)|Object|any} ruleCreator | ||
* @returns {(...args: any[]) => any} fixer function | ||
* @throws | ||
*/ | ||
export function getFixer(ruleCreator: Function | object | any): TextlintRuleReporter { | ||
export function getFixer(ruleCreator: unknown): TextlintRuleReporter { | ||
if (!hasLinter(ruleCreator)) { | ||
throw new Error("fixer module should have also linter function."); | ||
} | ||
if (hasFixer(ruleCreator)) { | ||
return ruleCreator.fixer; | ||
if (hasFixerProperty(ruleCreator) && typeof ruleCreator.fixer === "function") { | ||
return ruleCreator.fixer as TextlintRuleReporter; | ||
} | ||
@@ -70,3 +83,3 @@ throw new Error("Not found fixer function in the ruleCreator"); | ||
**/ | ||
export function isRuleModule(ruleCreator: any): boolean { | ||
export function isRuleModule(ruleCreator: unknown): boolean { | ||
return hasLinter(ruleCreator) || hasFixer(ruleCreator); | ||
@@ -82,3 +95,3 @@ } | ||
*/ | ||
export function assertRuleShape(ruleModule: any, key: string = "") { | ||
export function assertRuleShape(ruleModule: unknown, key: string = "") { | ||
if (ruleModule === undefined) { | ||
@@ -106,10 +119,10 @@ throw new Error(`Definition of rule '${key}' was not found.`); | ||
* @param {*} ruleCreator | ||
* @returns {Function} linter function | ||
* @returns {(...args: any[]) => any} linter function | ||
* @throws | ||
*/ | ||
export function getFilter(ruleCreator: any): TextlintFilterRuleReporter { | ||
export function getFilter(ruleCreator: unknown): TextlintFilterRuleReporter { | ||
if (typeof ruleCreator === "function") { | ||
return ruleCreator; | ||
return ruleCreator as TextlintFilterRuleReporter; | ||
} | ||
throw new Error("Not found filter function in the ruleCreator"); | ||
} |
@@ -97,5 +97,7 @@ // LICENSE : MIT | ||
const messages = await TaskRunner.process(task); | ||
const result = await postProcess(messages, sourceCode.filePath); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const result = await postProcess(messages as any, sourceCode.filePath); | ||
const filteredResult = { | ||
messages: this.messageProcessManager.process(result.messages), | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
messages: this.messageProcessManager.process(result.messages as any), | ||
filePath: result.filePath ? result.filePath : `<Unknown{sourceCode.ext}>` | ||
@@ -102,0 +104,0 @@ }; |
@@ -56,4 +56,6 @@ // LICENSE : MIT | ||
const messages = await TaskRunner.process(task); | ||
const result = await postProcess(messages, sourceCode.filePath); | ||
result.messages = this.messageProcessManager.process(result.messages); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const result = await postProcess(messages as any, sourceCode.filePath); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
result.messages = this.messageProcessManager.process(result.messages as any); | ||
if (result.filePath == null) { | ||
@@ -60,0 +62,0 @@ result.filePath = `<Unknown{sourceCode.ext}>`; |
@@ -31,3 +31,3 @@ // LICENSE : MIT | ||
* @param {Config} config | ||
* @returns {Function} filter function for messages | ||
* @returns {(...args: any[]) => any} filter function for messages | ||
*/ | ||
@@ -34,0 +34,0 @@ export default function createSeverityFilter( |
@@ -6,3 +6,3 @@ // LICENSE : MIT | ||
const isSeverityLevelValue = (type: any): type is TextlintRuleSeverityLevel => { | ||
const isSeverityLevelValue = (type: unknown): type is TextlintRuleSeverityLevel => { | ||
if (type === undefined) { | ||
@@ -9,0 +9,0 @@ throw new Error(`Please set following value to severity: |
@@ -6,3 +6,3 @@ // MIT © 2017 azu | ||
export type Listener = (...args: any[]) => void; | ||
export type Listener = (...args: unknown[]) => void; | ||
@@ -19,3 +19,3 @@ export class EventEmitter<T extends Listener = Listener> { | ||
emit(type: string, ...args: any[]): void { | ||
emit(type: string, ...args: unknown[]): void { | ||
const listenerSet = this.#listeners.get(type); | ||
@@ -56,3 +56,3 @@ if (!listenerSet) { | ||
export class PromiseEventEmitter { | ||
private events: EventEmitter<(...args: any[]) => Promise<void> | void>; | ||
private events: EventEmitter<(...args: unknown[]) => Promise<void> | void>; | ||
@@ -67,7 +67,7 @@ constructor() { | ||
on(event: string, listener: (...args: any[]) => Promise<void> | void) { | ||
on(event: string, listener: (...args: unknown[]) => Promise<void> | void) { | ||
return this.events.on(event, listener); | ||
} | ||
emit(event: string, ...args: any[]): Promise<void[]> { | ||
emit(event: string, ...args: unknown[]): Promise<void[]> { | ||
const promises: (Promise<void> | void)[] = []; | ||
@@ -74,0 +74,0 @@ |
@@ -19,3 +19,3 @@ // LICENSE : MIT | ||
task.on(CoreTask.events.message, (message) => { | ||
messages.push(message); | ||
messages.push(message as LintReportedMessage | IgnoreReportedMessage); | ||
}); | ||
@@ -22,0 +22,0 @@ task.on(CoreTask.events.error, (error) => { |
@@ -158,3 +158,3 @@ // LICENSE : MIT | ||
const data = ruleError; | ||
(message as any).data = data; | ||
(message as LintReportedMessage & { data: unknown }).data = data; | ||
} | ||
@@ -239,3 +239,3 @@ this.emit(TextLintCoreTask.events.message, message); | ||
* add all the node types as listeners of the rule | ||
* @param {Function} ruleCreator | ||
* @param {(...args: any[]) => any} ruleCreator | ||
* @param {Readonly<RuleContext>|Readonly<FilterRuleContext>} ruleContext | ||
@@ -242,0 +242,0 @@ * @param {Object|boolean|undefined} ruleOptions |
@@ -8,4 +8,4 @@ /** | ||
*/ | ||
export function invariant(condition: any, message?: string): asserts condition { | ||
export function invariant(condition: unknown, message?: string): asserts condition { | ||
if (!condition) throw new Error(message); | ||
} |
@@ -12,11 +12,11 @@ // LICENSE : MIT | ||
export default class Logger { | ||
static log(...message: Array<any>) { | ||
static log(...message: Array<unknown>) { | ||
console.log(...message); | ||
} | ||
static warn(...message: Array<any>) { | ||
static warn(...message: Array<unknown>) { | ||
console.warn(...message); | ||
} | ||
static error(...message: Array<any>) { | ||
static error(...message: Array<unknown>) { | ||
console.error(...message); | ||
@@ -23,0 +23,0 @@ } |
@@ -47,9 +47,9 @@ /** | ||
*/ | ||
function display(data: any) { | ||
function display(data: Record<string, number>) { | ||
let total = 0; | ||
const rows = Object.keys(data) | ||
const sortedData = Object.keys(data) | ||
.map(function (key) { | ||
const time = data[key]; | ||
total += time; | ||
return [key, time] as any; | ||
return [key, time] as [string, number]; | ||
}) | ||
@@ -60,9 +60,12 @@ .sort(function (a: [string, number], b: [string, number]) { | ||
.slice(0, 10); | ||
const rows: (string | number)[][] = [...sortedData]; | ||
rows.forEach(function (row: any) { | ||
row.push(`${((row[1] * 100) / total).toFixed(1)}%`); | ||
row[1] = row[1].toFixed(3); | ||
rows.forEach(function (row: (string | number)[]) { | ||
const time = row[1] as number; | ||
row.push(`${((time * 100) / total).toFixed(1)}%`); | ||
row[1] = time.toFixed(3); | ||
}); | ||
rows.unshift(HEADERS); | ||
rows.unshift(HEADERS as (string | number)[]); | ||
@@ -72,3 +75,3 @@ const widths: Array<number> = []; | ||
for (let i = 0; i < row.length; i++) { | ||
const n = row[i].length; | ||
const n = String(row[i]).length; | ||
if (!widths[i] || n > widths[i]) { | ||
@@ -82,4 +85,4 @@ widths[i] = n; | ||
return row | ||
.map(function (cell: any, index: number) { | ||
return ALIGN[index](cell, widths[index]); | ||
.map(function (cell: string | number, index: number) { | ||
return ALIGN[index](String(cell), widths[index]); | ||
}) | ||
@@ -112,7 +115,7 @@ .join(" | "); | ||
* @param {*} key key from the data object | ||
* @param {Function} fn function to be called | ||
* @returns {Function} function to be executed | ||
* @param {(...args: any[]) => any} fn function to be called | ||
* @returns {(...args: any[]) => any} function to be executed | ||
* @private | ||
*/ | ||
function time(key: string, fn: Function) { | ||
function time<T extends unknown[]>(key: string, fn: (...args: T) => unknown) { | ||
if (typeof data[key] === "undefined") { | ||
@@ -122,3 +125,3 @@ data[key] = 0; | ||
return async function (...args: any[]) { | ||
return async function (...args: T) { | ||
let t = process.hrtime(); | ||
@@ -125,0 +128,0 @@ await fn(...args); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
396840
0.85%7769
0.37%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated