UNPKG

@textlint/kernel

Version:
84 lines 3.05 kB
import { TextlintRuleContext, TextlintRuleContextReportFunction, TextlintRuleError, TextlintRulePaddingLocator, TextlintRuleReportedObject, TextlintRuleSeverityLevel, TextlintSourceCode } from "@textlint/types"; import { ASTNodeTypes, TxtNode } from "@textlint/ast-node-types"; import { TextlintRuleContextFixCommandGeneratorImpl } from "./TextlintRuleContextFixCommandGeneratorImpl"; 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 TextlintRuleContextArgs { ruleId: string; sourceCode: TextlintSourceCode; report: TextlintRuleContextReportFunction; configBaseDir?: string; severityLevel: TextlintRuleSeverityLevel; } export declare class TextlintRuleContextImpl implements TextlintRuleContext { private _ruleId; private _sourceCode; private _report; private _configBaseDir?; private _severityLevel; locator: TextlintRulePaddingLocator; constructor(args: TextlintRuleContextArgs); /** * Rule id * @returns {string} */ get id(): string; /** * severity level */ get severity(): TextlintRuleSeverityLevel; /** * Node's type values * @type {ASTNodeTypes} */ get Syntax(): typeof ASTNodeTypes; /** * CustomError object * @type {RuleError} */ get RuleError(): typeof TextlintRuleErrorImpl; /** * Rule fixer command object * @type {RuleFixer} */ get fixer(): TextlintRuleContextFixCommandGeneratorImpl; /** * report function that is called in a rule */ report: (node: TxtNode, ruleError: TextlintRuleError | TextlintRuleReportedObject, _shouldNotUsed?: never) => void; /** * 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=TextlintRuleContextImpl.d.ts.map