@anchan828/textlint-rule-decorators
TypeScript icon, indicating that this package has built-in type declarations

0.0.172 • Public • Published

@anchan828/textlint-rule-decorators

Install

npm i @anchan828/textlint-rule-decorators reflect-metadata

Usage

import { createReportModule, TextlintRule, TextlintASTNodeType } from "@anchan828/textlint-rule-decorators";

@TextlintRule()
class MyRule {
  constructor(private context: Readonly<TextlintRuleContext>) {}

  @TextlintASTNodeType(ASTNodeTypes.Str)
  async strReporter(node: TypeofTxtNode<ASTNodeTypes.Str>): Promise<void> {
    if (node.value === "error") {
      const ruleError = new this.context.RuleError(`error`, {
        fix: this.context.fixer.replaceText(node, "valid"),
      });

      this.context.report(node, ruleError);
    }
  }
}

export = createReportModule([MyRule]);

Readme

Keywords

none

Package Sidebar

Install

npm i @anchan828/textlint-rule-decorators

Weekly Downloads

0

Version

0.0.172

License

MIT

Unpacked Size

8.65 kB

Total Files

15

Last publish

Collaborators

  • anchan828