UNPKG

@textlint/kernel

Version:
77 lines 2.79 kB
import type { TextlintFilterRuleContext, TextlintFilterRuleShouldIgnoreFunction, TextlintRulePaddingLocator, TextlintRuleSeverityLevel, TextlintSourceCode } from "@textlint/types"; import { ASTNodeTypes, TxtNode } from "@textlint/ast-node-types"; import { TextlintRuleErrorImpl } from "./TextlintRuleErrorImpl"; /** * Rule context object is passed to each rule as `context` * @param {string} ruleId * @param {TextlintSourceCode} sourceCode * @param {ReportCallback} report * @param {Object|boolean|undefined} ruleOptions * @param {string} [configBaseDir] * @constructor */ export interface TextlintFilterRuleContextArgs { ruleId: string; ignoreReport: TextlintFilterRuleShouldIgnoreFunction; sourceCode: TextlintSourceCode; configBaseDir?: string; severityLevel: TextlintRuleSeverityLevel; } export declare class TextlintFilterRuleContextImpl implements TextlintFilterRuleContext { private _ruleId; private _ignoreReport; private _sourceCode; private _configBaseDir?; private _severityLevel; locator: TextlintRulePaddingLocator; constructor(args: TextlintFilterRuleContextArgs); /** * Rule id * @returns {string} */ get id(): string; get severity(): TextlintRuleSeverityLevel; /** * Node's type values * @type {TextLintNodeType} */ get Syntax(): typeof ASTNodeTypes; /** * CustomError object * @type {RuleError} */ get RuleError(): typeof TextlintRuleErrorImpl; shouldIgnore: (range: [startIndex: number, endIndex: number], optional?: {}) => void; /** * Not use * @returns {() => void} */ get report(): () => never; /** * get file path current processing. */ getFilePath: () => string | undefined; /** * Gets the source code for the given node. * @param {TxtNode=} node The AST node to get the text for. * @param {int=} beforeCount The number of characters before the node to retrieve. * @param {int=} afterCount The number of characters after the node to retrieve. * @returns {string} The text representing the AST node. */ getSource: (node?: TxtNode, beforeCount?: number, afterCount?: number) => string; /** * get config base directory path * config base directory path often is the place of .textlintrc * * e.g.) /path/to/dir/.textlintrc * `getConfigBaseDir()` return `"/path/to/dir/"`. * * When using textlint as module, it is specified by `configBaseDir` * If not found the value, return undefined. * * You can use it for resolving relative path from config dir. * @returns {string|undefined} */ getConfigBaseDir: () => string | undefined; } //# sourceMappingURL=TextlintFilterRuleContextImpl.d.ts.map