How to use the textlint.TextLintCore function in textlint

To help you get started, we’ve selected a few textlint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github textlint / textlint / packages / textlint-tester / src / textlint-tester.ts View on Github external
testValidPattern(name: string, param: TextlintRuleModule | TestConfig, valid: TesterValid) {
        const text = typeof valid === "object" ? valid.text : valid;
        const inputPath = typeof valid === "object" ? valid.inputPath : undefined;
        const ext = typeof valid === "object" && valid.ext !== undefined ? valid.ext : ".md";
        const textlint = new TextLintCore();
        if (isTestConfig(param)) {
            const testRuleSet = createTestRuleSet(param.rules);
            textlint.setupRules(testRuleSet.rules, testRuleSet.rulesOptions);
            if (param.plugins !== undefined) {
                const testPluginSet = createTestPluginSet(param.plugins);
                textlint.setupPlugins(testPluginSet.plugins, testPluginSet.pluginOptions);
            }
        } else {
            const options =
                typeof valid === "object"
                    ? valid.options
                    : // just enable
                      true;
            textlint.setupRules(
                {
                    [name]: param
github textlint / textlint / packages / textlint-tester / src / textlint-tester.ts View on Github external
testInvalidPattern(name: string, param: TextlintRuleModule | TestConfig, invalid: TesterInvalid) {
        const errors = invalid.errors;
        const inputPath = invalid.inputPath;
        const text = invalid.text;
        const ext = invalid.ext !== undefined ? invalid.ext : ".md";
        const textlint = new TextLintCore();
        if (isTestConfig(param)) {
            const testRuleSet = createTestRuleSet(param.rules);
            textlint.setupRules(testRuleSet.rules, testRuleSet.rulesOptions);
            if (Array.isArray(param.plugins)) {
                const testPluginSet = createTestPluginSet(param.plugins);
                textlint.setupPlugins(testPluginSet.plugins, testPluginSet.pluginOptions);
            }
        } else {
            const options = invalid.options;
            textlint.setupRules(
                {
                    [name]: param
                },
                {
                    [name]: options
                }
github io-monad / textlint-chrome-extension / app / scripts / lib / textlint / textlint-wrapper.js View on Github external
constructor(ruleNames, ruleOptions, format) {
    this.ruleNames = ruleNames;
    this.ruleOptions = ruleOptions;
    this.format = format || "txt";
    this.textlint = new TextLintCore();
    this.loadingPromise = null;
  }
github textlint / playground / src / components / TextlintDemo / TextlintEditor.js View on Github external
import {TextLintCore} from "textlint"
require("codemirror/addon/mode/overlay.js");
require("codemirror/mode/xml/xml.js");
require("codemirror/mode/markdown/markdown.js");
require("codemirror/mode/gfm/gfm.js");
require("codemirror/mode/javascript/javascript.js");
require("codemirror/mode/css/css.js");
require("codemirror/mode/htmlmixed/htmlmixed.js");
require("codemirror/mode/clike/clike.js");
require("codemirror/mode/meta.js");
require("codemirror/addon/edit/continuelist.js");
require("codemirror/addon/lint/lint.js");
require("codemirror/lib/codemirror.css");
require("codemirror/addon/lint/lint.css");
const createValidator = require("codemirror-textlint");
const textlint = new TextLintCore();
const onChange = (dispatch) => {
    return (text) => {
        const value = text;
        textlint.lintMarkdown(value).then(result => {
            dispatch(updateRuleErrors(result.messages));
            return result;
        });
    }
};
export default {
    render({props, dispatch}){
        const {enabledRules} = props;
        const rules = enabledRules.reduce((rules, rule) => {
            rules[rule.name] = rule.rule;
            return rules;
        }, {});

textlint

The pluggable linting tool for text and markdown.

MIT
Latest version published 2 months ago

Package Health Score

83 / 100
Full package analysis