Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env node
"use strict";
const getStdin = require("get-stdin");
const logSymbols = require("log-symbols");
const useStdIn = process.argv.indexOf("--stdin") > -1;
const isDebug = process.argv.indexOf("--debug") > -1;
if (isDebug) {
const debug = require("debug");
debug.enable("textlint*");
}
// must do this initialization *before* other requires in order to work
const cli = require("../lib/textlint/src/cli").cli;
const { coreFlags } = require("@textlint/feature-flag");
// it is for --experimental logger
// update state
coreFlags.runningCLI = !module.parent;
/**
* show error message for user
* @param {Error} error
*/
function showError(error) {
console.error(logSymbols.error, "Error");
console.error(`${error.message}\n`);
console.error(logSymbols.error, "Stack trace");
console.error(error.stack);
}
// Always start as promise
Promise.resolve()
.then(function() {
if (useStdIn) {
if (typeof padding === "number") {
_backwardCompatibleIndexValue = padding;
throwIfTesting(`${errorPrefix} This is un-document way:
report(node, new RuleError("message", index);
Please use { index }:
report(node, new RuleError("message", {
index: paddingLineColumn
});
`);
}
// when running from textlint-tester, assert
if (padding.line === undefined && padding.column !== undefined) {
// FIXME: Backward compatible <= textlint.5.5
throwIfTesting(`${errorPrefix} Have to use a sets with "line" and "column".
See FAQ: https://github.com/textlint/textlint/blob/master/docs/faq/line-column-or-index.md
report(node, new RuleError("message", {
line: paddingLineNumber,
column: paddingLineColumn
});
OR use "index" property insteadof only "column".
report(node, new RuleError("message", {
index: paddingLineColumn
});
`);
}
// When either one of {column, line} or {index} is not used, throw error
constructor() {
if (typeof coreFlags === "object") {
coreFlags.runningTester = true;
}
}
addProcessor(Processor: TextlintPluginProcessorConstructor) {
throwIfTesting(
"Use setupPlugins insteadof addProcessor method.`addProcessor` will be removed in the future." +
"For more details, See https://github.com/textlint/textlint/issues/293"
);
this.textlintKernelDescriptor = this.textlintKernelDescriptor.shallowMerge({
plugins: [
{
pluginId: "`${Processor.name}@deprecated`",
plugin: { Processor }
}
].concat(this.defaultPlugins)
});
}