Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function (context) {
const helper = new RuleHelper(context);
const {Syntax, getSource, RuleError, report} = context;
return {
/*
# Header
Todo: quick fix this.
*/
[Syntax.Str](node) {
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote])) {
return;
}
// get text from node
const text = getSource(node);
// does text contain "todo:"?
const match = text.match(/todo:/i);
if (match) {
report(node, new RuleError(`Found TODO: '${text}'`, {
function reporter(context, options = {}) {
const opts = Object.assign({}, DEFAULT_OPTIONS, options);
const rules = getDict(opts.defaultWords, opts.words, opts.exclude);
const helper = new RuleHelper(context);
const { Syntax, RuleError, report, fixer, getSource } = context;
return {
[Syntax.Str](node) {
if (helper.isChildNode(node, opts.skip.map(rule => Syntax[rule]))) {
return false;
}
return new Promise(resolve => {
const text = getSource(node);
for (const [word, alternative] of rules) {
const regExp = getRegExp(word);
let match;
// eslint-disable-next-line no-cond-assign
while ((match = regExp.exec(text))) {
function reporter(context, options = {}) {
const { Syntax, getSource, report, RuleError, fixer, getFilePath } = context;
const helper = new RuleHelper(context);
const ruleOptions = { ...DEFAULT_OPTIONS, ...options };
const isAliveURI = createCheckAliveURL(ruleOptions);
// 30sec memorized
const memorizedIsAliveURI = pMemoize(isAliveURI, {
maxAge: 30 * 1000,
});
/**
* Checks a given URI's availability and report if it is dead.
* @param {TextLintNode} node TextLintNode the URI belongs to.
* @param {string} uri a URI string to be linted.
* @param {number} index column number the URI is located at.
* @param {number} maxRetryCount retry count of linting
*/
const lint = async ({ node, uri, index }, maxRetryCount) => {
if (isIgnored(uri, ruleOptions.ignore)) {
return;
function reporter(context) {
var helper = new RuleHelper(context);
var exports = {};
var fixer = context.fixer;
var Syntax = context.Syntax;
exports[context.Syntax.Str] = function (node) {
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
return;
}
var text = context.getSource(node);
var results = spellCheck(text);
results.forEach(function (/*SpellCheckResult*/result) {
// line, column
var fixCommand = fixer.replaceTextRange([
result.paddingIndex, result.paddingIndex + result.actual.length
], result.expected);
context.report(node, new context.RuleError(result.actual + " => " + result.expected, {
index: result.paddingIndex,
export function checkPair(context, { left, right }) {
assert(left);
assert(right);
let { Syntax, RuleError, report, getSource } = context;
let helper = new RuleHelper(context);
let isInParagraph = false;
let currentStrInParagraph = [];
/**
* `Str` nodeの配列を受け取り、pairが見つからないnodeを返す
* @param {Object} currentStrInParagraph
* @returns {{node, index}[]}
*/
const foundMissingPairNodes = currentStrInParagraph => {
let foundLeft = false;
let matchParentheses = [];
currentStrInParagraph.forEach(node => {
const text = getSource(node);
// left を探す
let leftIndex = -1;
if (!foundLeft) {
leftIndex = text.indexOf(left);
function reporter(context, options = {}) {
const opts = Object.assign({}, DEFAULT_OPTIONS, options);
const terms = getTerms(opts.defaultTerms, opts.terms, opts.exclude);
const rules = getExactMatchRegExps(terms);
// Regexp for all possible mistakes
const allMistakes = rules.map(rule => rule[0]);
const regExp = getRegExp(allMistakes);
const helper = new RuleHelper(context);
const { Syntax, RuleError, report, fixer, getSource } = context;
return {
[Syntax.Str](node) {
if (helper.isChildNode(node, opts.skip.map(rule => Syntax[rule]))) {
return false;
}
return new Promise(resolve => {
const text = getSource(node);
let match;
// eslint-disable-next-line no-cond-assign
while ((match = regExp.exec(text))) {
const index = match.index;
const matched = match[0];
const rule = getRuleForMatch(rules, matched);
function reporter(context, options = {}) {
const { Syntax, getSource, report, RuleError } = context;
const helper = new RuleHelper(context);
return {
[Syntax.Str](node) {
if (helper.isChildNode(node, [Syntax.BlockQuote])) {
return;
}
const text = getSource(node);
const suggestions = writeGood(text, options);
suggestions.forEach((suggestion) => {
const { index, reason: message } = suggestion;
report(node, new RuleError(message, { index }));
});
},
export function isUserWrittenNode(node, context) {
let helper = new RuleHelper(context);
let Syntax = context.Syntax;
return !helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis]);
}
module.exports = function(context) {
const helper = new RuleHelper(context);
const { Syntax, report, getSource, RuleError } = context;
return {
[Syntax.Str](node) {
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
return;
}
const text = getSource(node);
return kuromojin(text).then(tokens => {
tokens.forEach(token => {
if (isKoreru(token)) {
report(
node,
new RuleError("ら抜き言葉を使用しています。", {
index: token.word_position
})
);