Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
}
constructor(ruleNames, ruleOptions, format) {
this.ruleNames = ruleNames;
this.ruleOptions = ruleOptions;
this.format = format || "txt";
this.textlint = new TextLintCore();
this.loadingPromise = null;
}
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;
}, {});