Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@textlint/kernel

Package Overview
Dependencies
Maintainers
2
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@textlint/kernel - npm Package Compare versions

Comparing version 12.0.2 to 12.1.0

lib/tsconfig.tsbuildinfo

4

lib/src/core/source-location.js

@@ -26,3 +26,3 @@ "use strict";

_backwardCompatibleIndexValue = padding;
feature_flag_1.throwIfTesting(`${errorPrefix} This is un-document way:
(0, feature_flag_1.throwIfTesting)(`${errorPrefix} This is un-document way:
report(node, new RuleError("message", index);

@@ -40,3 +40,3 @@

// FIXME: Backward compatible <= textlint.5.5
feature_flag_1.throwIfTesting(`${errorPrefix} Have to use a sets with "line" and "column".
(0, feature_flag_1.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

@@ -43,0 +43,0 @@

@@ -15,3 +15,3 @@ // LICENSE : MIT

const ruleOrFixableRuleDescriptorList = rules.map((rule) => {
if (rule_creator_helper_1.hasFixer(rule.rule)) {
if ((0, rule_creator_helper_1.hasFixer)(rule.rule)) {
return new TextlintFixableRuleDescriptor_1.TextlintFixableRuleDescriptor(rule);

@@ -18,0 +18,0 @@ }

@@ -35,3 +35,3 @@ // LICENSE : MIT

get filter() {
return rule_creator_helper_1.getFilter(this.rule);
return (0, rule_creator_helper_1.getFilter)(this.rule);
}

@@ -60,3 +60,3 @@ /**

return (this.rule === descriptor.rule &&
deep_equal_1.default(this.normalizedOptions, descriptor.normalizedOptions, {
(0, deep_equal_1.default)(this.normalizedOptions, descriptor.normalizedOptions, {
strict: true

@@ -63,0 +63,0 @@ }));

@@ -41,3 +41,3 @@ // LICENSE : MIT

// remove last duplicated item
const newDescriptorList = DescriptorUtil_1.filterDuplicateDescriptor(this.ruleDescriptorList);
const newDescriptorList = (0, DescriptorUtil_1.filterDuplicateDescriptor)(this.ruleDescriptorList);
return new TextlintFilterRuleDescriptors(newDescriptorList);

@@ -44,0 +44,0 @@ }

@@ -18,3 +18,3 @@ // LICENSE : MIT

get fixer() {
return rule_creator_helper_1.getFixer(this.rule);
return (0, rule_creator_helper_1.getFixer)(this.rule);
}

@@ -21,0 +21,0 @@ }

@@ -8,5 +8,5 @@ "use strict";

this.args = args;
this.rule = DescriptorsFactory_1.createTextlintRuleDescriptors(args.rules);
this.filterRule = DescriptorsFactory_1.createTextlintFilterRuleDescriptors(args.filterRules);
this.plugin = DescriptorsFactory_1.createTextlintPluginDescriptors(args.plugins);
this.rule = (0, DescriptorsFactory_1.createTextlintRuleDescriptors)(args.rules);
this.filterRule = (0, DescriptorsFactory_1.createTextlintFilterRuleDescriptors)(args.filterRules);
this.plugin = (0, DescriptorsFactory_1.createTextlintPluginDescriptors)(args.plugins);
}

@@ -13,0 +13,0 @@ /**

@@ -17,3 +17,3 @@ // LICENSE : MIT

this.textlintKernelRule = textlintKernelRule;
rule_creator_helper_1.assertRuleShape(textlintKernelRule.rule, textlintKernelRule.ruleId);
(0, rule_creator_helper_1.assertRuleShape)(textlintKernelRule.rule, textlintKernelRule.ruleId);
}

@@ -40,3 +40,3 @@ get id() {

get linter() {
return rule_creator_helper_1.getLinter(this.rule);
return (0, rule_creator_helper_1.getLinter)(this.rule);
}

@@ -65,3 +65,3 @@ /**

return (this.rule === descriptor.rule &&
deep_equal_1.default(this.normalizedOptions, descriptor.normalizedOptions, {
(0, deep_equal_1.default)(this.normalizedOptions, descriptor.normalizedOptions, {
strict: true

@@ -68,0 +68,0 @@ }));

@@ -73,3 +73,3 @@ "use strict";

return (this.plugin.plugin === target.plugin.plugin &&
deep_equal_1.default(this.plugin.options, target.plugin.options, {
(0, deep_equal_1.default)(this.plugin.options, target.plugin.options, {
strict: true

@@ -76,0 +76,0 @@ }));

@@ -48,3 +48,3 @@ "use strict";

withoutDuplicated() {
const newDescriptorList = DescriptorUtil_1.filterDuplicateDescriptor(this.pluginDescriptorList);
const newDescriptorList = (0, DescriptorUtil_1.filterDuplicateDescriptor)(this.pluginDescriptorList);
return new TextlintPluginDescriptors(newDescriptorList);

@@ -51,0 +51,0 @@ }

@@ -57,3 +57,3 @@ // LICENSE : MIT

withoutDuplicated() {
const newDescriptorList = DescriptorUtil_1.filterDuplicateDescriptor(this.ruleDescriptorList);
const newDescriptorList = (0, DescriptorUtil_1.filterDuplicateDescriptor)(this.ruleDescriptorList);
return new TextlintRuleDescriptors(newDescriptorList);

@@ -60,0 +60,0 @@ }

@@ -22,2 +22,11 @@ // LICENSE : MIT

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -34,3 +43,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const isPluginParsedObject_1 = require("../util/isPluginParsedObject");
const debug = debug_1.default("textlint:fixer-processor");
const debug = (0, debug_1.default)("textlint:fixer-processor");
class FixerProcessor {

@@ -69,6 +78,6 @@ /**

const fixerProcessList = ruleDescriptors.fixableDescriptors.map((ruleDescriptor) => {
return (sourceText) => {
return (sourceText) => __awaiter(this, void 0, void 0, function* () {
// create new SourceCode object
const preProcessResult = preProcess(sourceText, sourceCode.filePath);
const isParsedObject = isPluginParsedObject_1.isPluginParsedObject(preProcessResult);
const preProcessResult = yield Promise.resolve(preProcess(sourceText, sourceCode.filePath));
const isParsedObject = (0, isPluginParsedObject_1.isPluginParsedObject)(preProcessResult);
const textForAST = isParsedObject ? preProcessResult.text : sourceText;

@@ -90,4 +99,4 @@ const ast = isParsedObject ? preProcessResult.ast : preProcessResult;

});
return task_runner_1.default.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
return yield task_runner_1.default.process(task).then((messages) => __awaiter(this, void 0, void 0, function* () {
const result = yield Promise.resolve(postProcess(messages, sourceCode.filePath));
const filteredResult = {

@@ -99,3 +108,3 @@ messages: this.messageProcessManager.process(result.messages),

resultFilePath = filteredResult.filePath;
const applied = source_code_fixer_1.applyFixesToSourceCode(newSourceCode, filteredResult.messages);
const applied = (0, source_code_fixer_1.applyFixesToSourceCode)(newSourceCode, filteredResult.messages);
// add messages

@@ -111,4 +120,4 @@ Array.prototype.push.apply(applyingMessages, applied.applyingMessages);

return applied.output;
});
};
}));
});
});

@@ -115,0 +124,0 @@ const promiseTask = fixerProcessList.reduce((promise, fixerProcess) => {

@@ -22,2 +22,11 @@ // LICENSE : MIT

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -52,4 +61,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

});
return task_runner_1.default.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
return task_runner_1.default.process(task).then((messages) => __awaiter(this, void 0, void 0, function* () {
const result = yield Promise.resolve(postProcess(messages, sourceCode.filePath));
result.messages = this.messageProcessManager.process(result.messages);

@@ -61,3 +70,3 @@ if (result.filePath == null) {

return result;
});
}));
}

@@ -64,0 +73,0 @@ }

@@ -12,3 +12,3 @@ // LICENSE : MIT

const debug_1 = __importDefault(require("debug"));
const debug = debug_1.default("textlint:TextLintCoreTask");
const debug = (0, debug_1.default)("textlint:TextLintCoreTask");
class TextLintCoreTask extends textlint_core_task_1.default {

@@ -36,3 +36,3 @@ constructor({ config, configBaseDir, fixableRuleDescriptor, filterRuleDescriptors, sourceCode }) {

ruleId: this.fixableRuleDescriptor.id,
severityLevel: rule_severity_1.getSeverity(this.fixableRuleDescriptor.normalizedOptions),
severityLevel: (0, rule_severity_1.getSeverity)(this.fixableRuleDescriptor.normalizedOptions),
sourceCode,

@@ -48,3 +48,3 @@ report,

ruleId: filterRuleDescriptor.id,
severityLevel: rule_severity_1.getSeverity(filterRuleDescriptor.normalizedOptions),
severityLevel: (0, rule_severity_1.getSeverity)(filterRuleDescriptor.normalizedOptions),
sourceCode,

@@ -51,0 +51,0 @@ ignoreReport,

@@ -36,3 +36,3 @@ // LICENSE : MIT

ruleId: ruleDescriptor.id,
severityLevel: rule_severity_1.getSeverity(ruleOptions),
severityLevel: (0, rule_severity_1.getSeverity)(ruleOptions),
sourceCode,

@@ -51,3 +51,3 @@ report,

configBaseDir: this.configBaseDir,
severityLevel: rule_severity_1.getSeverity(filterDescriptor.normalizedOptions)
severityLevel: (0, rule_severity_1.getSeverity)(filterDescriptor.normalizedOptions)
});

@@ -54,0 +54,0 @@ this.tryToAddListenRule(filterDescriptor.filter, ruleContext, filterDescriptor.normalizedOptions);

@@ -38,3 +38,3 @@ // LICENSE : MIT

const traverseController = new ast_traverse_1.Controller();
const debug = debug_1.default("textlint:core-task");
const debug = (0, debug_1.default)("textlint:core-task");
class RuleTypeEmitter extends promise_event_emitter_1.PromiseEventEmitter {

@@ -75,3 +75,3 @@ }

// This ruleId should be normalized, because the user can report any value
ignoringRuleId: optional.ruleId ? utils_1.normalizeTextlintKeyPath(optional.ruleId) : "*"
ignoringRuleId: optional.ruleId ? (0, utils_1.normalizeTextlintKeyPath)(optional.ruleId) : "*"
};

@@ -157,3 +157,5 @@ this.emit(TextLintCoreTask.events.message, message);

catch (error) {
error.message = `Error while loading rule '${ruleContext.id}': ${error.message}`;
if (error instanceof Error) {
error.message = `Error while loading rule '${ruleContext.id}': ${error.message}`;
}
throw error;

@@ -170,3 +172,5 @@ }

catch (error) {
error.message = `Error while loading filter rule '${ruleContext.id}': ${error.message}`;
if (error instanceof Error) {
error.message = `Error while loading filter rule '${ruleContext.id}': ${error.message}`;
}
throw error;

@@ -173,0 +177,0 @@ }

@@ -21,2 +21,11 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -45,3 +54,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const debug_1 = __importDefault(require("debug"));
const debug = debug_1.default("textlint:kernel");
const debug = (0, debug_1.default)("textlint:kernel");
/**

@@ -86,3 +95,3 @@ * add fileName to trailing of error message

// filter by severity
this.messageProcessManager.add(filter_severity_process_1.default(this.config));
this.messageProcessManager.add((0, filter_severity_process_1.default)(this.config));
this.messageProcessManager.add(sort_messages_process_1.default);

@@ -141,21 +150,22 @@ }

_parallelProcess({ descriptor, text, options }) {
const { ext, filePath, configBaseDir } = options;
const plugin = descriptor.findPluginDescriptorWithExt(ext);
debug("available extensions: %o", descriptor.availableExtensions);
if (plugin === undefined) {
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", `${plugin.id} processor should implements {preProcess, postProcess}`);
const preProcessResult = preProcess(text, filePath);
// { text, ast } or ast
const isParsedObject = isPluginParsedObject_1.isPluginParsedObject(preProcessResult);
const textForAST = isParsedObject ? preProcessResult.text : text;
const ast = isParsedObject ? preProcessResult.ast : preProcessResult;
assert.ok(typeof textForAST === "string", `${plugin.id} processor should return correct text`);
assert.ok(typeof ast === "object", `${plugin.id} processor should return correct AST object`);
if (feature_flag_1.coreFlags.runningTester) {
assert.ok(ast_tester_1.isTxtAST(ast), `${plugin.id} processor return invalid AST object. Please check out @textlint/ast-tester.
return __awaiter(this, void 0, void 0, function* () {
const { ext, filePath, configBaseDir } = options;
const plugin = descriptor.findPluginDescriptorWithExt(ext);
debug("available extensions: %o", descriptor.availableExtensions);
if (plugin === undefined) {
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", `${plugin.id} processor should implements {preProcess, postProcess}`);
const preProcessResult = yield Promise.resolve(preProcess(text, filePath));
// { text, ast } or ast
const isParsedObject = (0, isPluginParsedObject_1.isPluginParsedObject)(preProcessResult);
const textForAST = isParsedObject ? preProcessResult.text : text;
const ast = isParsedObject ? preProcessResult.ast : preProcessResult;
assert.ok(typeof textForAST === "string", `${plugin.id} processor should return correct text`);
assert.ok(typeof ast === "object", `${plugin.id} processor should return correct AST object`);
if (feature_flag_1.coreFlags.runningTester) {
assert.ok((0, ast_tester_1.isTxtAST)(ast), `${plugin.id} processor return invalid AST object. Please check out @textlint/ast-tester.

@@ -165,22 +175,23 @@ You can check the validation result with "DEBUG=textlint*" env

See https://textlint.github.io/docs/plugin.html`);
}
const sourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
text: textForAST,
ast,
ext,
filePath
}
const sourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
text: textForAST,
ast,
ext,
filePath
});
const linterProcessor = new linter_processor_1.default(processor, this.messageProcessManager);
return yield linterProcessor
.process({
config: this.config,
ruleDescriptors: descriptor.rule,
filterRuleDescriptors: descriptor.filterRule,
sourceCode,
configBaseDir
})
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
});
const linterProcessor = new linter_processor_1.default(processor, this.messageProcessManager);
return linterProcessor
.process({
config: this.config,
ruleDescriptors: descriptor.rule,
filterRuleDescriptors: descriptor.filterRule,
sourceCode,
configBaseDir
})
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
}

@@ -197,21 +208,22 @@ /**

_sequenceProcess({ descriptor, text, options }) {
const { ext, filePath, configBaseDir } = options;
const plugin = descriptor.findPluginDescriptorWithExt(ext);
debug("available extensions: %o", descriptor.availableExtensions);
if (plugin === undefined) {
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", `${plugin.id} processor should implements {preProcess, postProcess}`);
const preProcessResult = preProcess(text, filePath);
// { text, ast } or ast
const isParsedObject = isPluginParsedObject_1.isPluginParsedObject(preProcessResult);
const textForAST = isParsedObject ? preProcessResult.text : text;
const ast = isParsedObject ? preProcessResult.ast : preProcessResult;
assert.ok(typeof textForAST === "string", `${plugin.id} processor should return correct text`);
assert.ok(typeof ast === "object", `${plugin.id} processor should return correct AST object`);
if (feature_flag_1.coreFlags.runningTester) {
assert.ok(ast_tester_1.isTxtAST(ast), `${plugin.id} processor return invalid AST object. Please check out @textlint/ast-tester.
return __awaiter(this, void 0, void 0, function* () {
const { ext, filePath, configBaseDir } = options;
const plugin = descriptor.findPluginDescriptorWithExt(ext);
debug("available extensions: %o", descriptor.availableExtensions);
if (plugin === undefined) {
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", `${plugin.id} processor should implements {preProcess, postProcess}`);
const preProcessResult = yield Promise.resolve(preProcess(text, filePath));
// { text, ast } or ast
const isParsedObject = (0, isPluginParsedObject_1.isPluginParsedObject)(preProcessResult);
const textForAST = isParsedObject ? preProcessResult.text : text;
const ast = isParsedObject ? preProcessResult.ast : preProcessResult;
assert.ok(typeof textForAST === "string", `${plugin.id} processor should return correct text`);
assert.ok(typeof ast === "object", `${plugin.id} processor should return correct AST object`);
if (feature_flag_1.coreFlags.runningTester) {
assert.ok((0, ast_tester_1.isTxtAST)(ast), `${plugin.id} processor return invalid AST object. Please check out @textlint/ast-tester.

@@ -221,22 +233,23 @@ You can check the validation result with "DEBUG=textlint*" env

See https://textlint.github.io/docs/plugin.html`);
}
const sourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
text: textForAST,
ast,
ext,
filePath
}
const sourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
text: textForAST,
ast,
ext,
filePath
});
const fixerProcessor = new fixer_processor_1.default(processor, this.messageProcessManager);
return yield fixerProcessor
.process({
config: this.config,
ruleDescriptors: descriptor.rule,
filterRules: descriptor.filterRule,
sourceCode,
configBaseDir
})
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
});
const fixerProcessor = new fixer_processor_1.default(processor, this.messageProcessManager);
return fixerProcessor
.process({
config: this.config,
ruleDescriptors: descriptor.rule,
filterRules: descriptor.filterRule,
sourceCode,
configBaseDir
})
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
}

@@ -243,0 +256,0 @@ }

// LICENSE : MIT
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as assert from "assert";

@@ -44,5 +53,5 @@ import FixerTask from "../task/fixer-task";

const fixerProcessList = ruleDescriptors.fixableDescriptors.map((ruleDescriptor) => {
return (sourceText) => {
return (sourceText) => __awaiter(this, void 0, void 0, function* () {
// create new SourceCode object
const preProcessResult = preProcess(sourceText, sourceCode.filePath);
const preProcessResult = yield Promise.resolve(preProcess(sourceText, sourceCode.filePath));
const isParsedObject = isPluginParsedObject(preProcessResult);

@@ -65,4 +74,4 @@ const textForAST = isParsedObject ? preProcessResult.text : sourceText;

});
return TaskRunner.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
return yield TaskRunner.process(task).then((messages) => __awaiter(this, void 0, void 0, function* () {
const result = yield Promise.resolve(postProcess(messages, sourceCode.filePath));
const filteredResult = {

@@ -85,4 +94,4 @@ messages: this.messageProcessManager.process(result.messages),

return applied.output;
});
};
}));
});
});

@@ -89,0 +98,0 @@ const promiseTask = fixerProcessList.reduce((promise, fixerProcess) => {

// LICENSE : MIT
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as assert from "assert";

@@ -28,4 +37,4 @@ import LinterTask from "../task/linter-task";

});
return TaskRunner.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
return TaskRunner.process(task).then((messages) => __awaiter(this, void 0, void 0, function* () {
const result = yield Promise.resolve(postProcess(messages, sourceCode.filePath));
result.messages = this.messageProcessManager.process(result.messages);

@@ -37,5 +46,5 @@ if (result.filePath == null) {

return result;
});
}));
}
}
//# sourceMappingURL=linter-processor.js.map

@@ -132,3 +132,5 @@ // LICENSE : MIT

catch (error) {
error.message = `Error while loading rule '${ruleContext.id}': ${error.message}`;
if (error instanceof Error) {
error.message = `Error while loading rule '${ruleContext.id}': ${error.message}`;
}
throw error;

@@ -145,3 +147,5 @@ }

catch (error) {
error.message = `Error while loading filter rule '${ruleContext.id}': ${error.message}`;
if (error instanceof Error) {
error.message = `Error while loading filter rule '${ruleContext.id}': ${error.message}`;
}
throw error;

@@ -148,0 +152,0 @@ }

@@ -0,1 +1,10 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
// MIT © 2017- azu

@@ -113,21 +122,22 @@ import * as assert from "assert";

_parallelProcess({ descriptor, text, options }) {
const { ext, filePath, configBaseDir } = options;
const plugin = descriptor.findPluginDescriptorWithExt(ext);
debug("available extensions: %o", descriptor.availableExtensions);
if (plugin === undefined) {
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", `${plugin.id} processor should implements {preProcess, postProcess}`);
const preProcessResult = preProcess(text, filePath);
// { text, ast } or ast
const isParsedObject = isPluginParsedObject(preProcessResult);
const textForAST = isParsedObject ? preProcessResult.text : text;
const ast = isParsedObject ? preProcessResult.ast : preProcessResult;
assert.ok(typeof textForAST === "string", `${plugin.id} processor should return correct text`);
assert.ok(typeof ast === "object", `${plugin.id} processor should return correct AST object`);
if (coreFlags.runningTester) {
assert.ok(isTxtAST(ast), `${plugin.id} processor return invalid AST object. Please check out @textlint/ast-tester.
return __awaiter(this, void 0, void 0, function* () {
const { ext, filePath, configBaseDir } = options;
const plugin = descriptor.findPluginDescriptorWithExt(ext);
debug("available extensions: %o", descriptor.availableExtensions);
if (plugin === undefined) {
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", `${plugin.id} processor should implements {preProcess, postProcess}`);
const preProcessResult = yield Promise.resolve(preProcess(text, filePath));
// { text, ast } or ast
const isParsedObject = isPluginParsedObject(preProcessResult);
const textForAST = isParsedObject ? preProcessResult.text : text;
const ast = isParsedObject ? preProcessResult.ast : preProcessResult;
assert.ok(typeof textForAST === "string", `${plugin.id} processor should return correct text`);
assert.ok(typeof ast === "object", `${plugin.id} processor should return correct AST object`);
if (coreFlags.runningTester) {
assert.ok(isTxtAST(ast), `${plugin.id} processor return invalid AST object. Please check out @textlint/ast-tester.

@@ -137,22 +147,23 @@ You can check the validation result with "DEBUG=textlint*" env

See https://textlint.github.io/docs/plugin.html`);
}
const sourceCode = new TextlintSourceCodeImpl({
text: textForAST,
ast,
ext,
filePath
}
const sourceCode = new TextlintSourceCodeImpl({
text: textForAST,
ast,
ext,
filePath
});
const linterProcessor = new LinterProcessor(processor, this.messageProcessManager);
return yield linterProcessor
.process({
config: this.config,
ruleDescriptors: descriptor.rule,
filterRuleDescriptors: descriptor.filterRule,
sourceCode,
configBaseDir
})
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
});
const linterProcessor = new LinterProcessor(processor, this.messageProcessManager);
return linterProcessor
.process({
config: this.config,
ruleDescriptors: descriptor.rule,
filterRuleDescriptors: descriptor.filterRule,
sourceCode,
configBaseDir
})
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
}

@@ -169,21 +180,22 @@ /**

_sequenceProcess({ descriptor, text, options }) {
const { ext, filePath, configBaseDir } = options;
const plugin = descriptor.findPluginDescriptorWithExt(ext);
debug("available extensions: %o", descriptor.availableExtensions);
if (plugin === undefined) {
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", `${plugin.id} processor should implements {preProcess, postProcess}`);
const preProcessResult = preProcess(text, filePath);
// { text, ast } or ast
const isParsedObject = isPluginParsedObject(preProcessResult);
const textForAST = isParsedObject ? preProcessResult.text : text;
const ast = isParsedObject ? preProcessResult.ast : preProcessResult;
assert.ok(typeof textForAST === "string", `${plugin.id} processor should return correct text`);
assert.ok(typeof ast === "object", `${plugin.id} processor should return correct AST object`);
if (coreFlags.runningTester) {
assert.ok(isTxtAST(ast), `${plugin.id} processor return invalid AST object. Please check out @textlint/ast-tester.
return __awaiter(this, void 0, void 0, function* () {
const { ext, filePath, configBaseDir } = options;
const plugin = descriptor.findPluginDescriptorWithExt(ext);
debug("available extensions: %o", descriptor.availableExtensions);
if (plugin === undefined) {
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", `${plugin.id} processor should implements {preProcess, postProcess}`);
const preProcessResult = yield Promise.resolve(preProcess(text, filePath));
// { text, ast } or ast
const isParsedObject = isPluginParsedObject(preProcessResult);
const textForAST = isParsedObject ? preProcessResult.text : text;
const ast = isParsedObject ? preProcessResult.ast : preProcessResult;
assert.ok(typeof textForAST === "string", `${plugin.id} processor should return correct text`);
assert.ok(typeof ast === "object", `${plugin.id} processor should return correct AST object`);
if (coreFlags.runningTester) {
assert.ok(isTxtAST(ast), `${plugin.id} processor return invalid AST object. Please check out @textlint/ast-tester.

@@ -193,24 +205,25 @@ You can check the validation result with "DEBUG=textlint*" env

See https://textlint.github.io/docs/plugin.html`);
}
const sourceCode = new TextlintSourceCodeImpl({
text: textForAST,
ast,
ext,
filePath
}
const sourceCode = new TextlintSourceCodeImpl({
text: textForAST,
ast,
ext,
filePath
});
const fixerProcessor = new FixerProcessor(processor, this.messageProcessManager);
return yield fixerProcessor
.process({
config: this.config,
ruleDescriptors: descriptor.rule,
filterRules: descriptor.filterRule,
sourceCode,
configBaseDir
})
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
});
const fixerProcessor = new FixerProcessor(processor, this.messageProcessManager);
return fixerProcessor
.process({
config: this.config,
ruleDescriptors: descriptor.rule,
filterRules: descriptor.filterRule,
sourceCode,
configBaseDir
})
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
}
}
//# sourceMappingURL=textlint-kernel.js.map
{
"name": "@textlint/kernel",
"version": "12.0.2",
"version": "12.1.0",
"description": "textlint kernel is core logic by pure JavaScript.",

@@ -39,10 +39,10 @@ "keywords": [

"dependencies": {
"@textlint/ast-node-types": "^12.0.0",
"@textlint/ast-tester": "^12.0.2",
"@textlint/ast-traverse": "^12.0.2",
"@textlint/feature-flag": "^12.0.2",
"@textlint/source-code-fixer": "^12.0.2",
"@textlint/types": "^12.0.2",
"@textlint/utils": "^12.0.2",
"debug": "^4.3.2",
"@textlint/ast-node-types": "^12.1.0",
"@textlint/ast-tester": "^12.1.0",
"@textlint/ast-traverse": "^12.1.0",
"@textlint/feature-flag": "^12.1.0",
"@textlint/source-code-fixer": "^12.1.0",
"@textlint/types": "^12.1.0",
"@textlint/utils": "^12.1.0",
"debug": "^4.3.3",
"deep-equal": "^1.1.1",

@@ -52,7 +52,7 @@ "structured-source": "^3.0.2"

"devDependencies": {
"@textlint/markdown-to-ast": "^12.0.2",
"@types/debug": "^4.1.6",
"@textlint/markdown-to-ast": "^12.1.0",
"@types/debug": "^4.1.7",
"@types/deep-equal": "^1.0.1",
"@types/mocha": "^8.2.3",
"@types/node": "^14.17.5",
"@types/node": "^14.17.34",
"@types/structured-source": "^3.0.0",

@@ -65,7 +65,7 @@ "cpx": "^1.5.0",

"shelljs": "^0.8.4",
"ts-node": "^9.1.1",
"ts-node-test-register": "^9.0.1",
"typescript": "~4.2.4"
"ts-node": "^10.4.0",
"ts-node-test-register": "^10.0.0",
"typescript": "~4.4.4"
},
"gitHead": "a7826f57258ee6bf68197d983bf5ec71c1b5f565"
"gitHead": "a393919e9c77078db47dc14d1baf3ab3a8e1bfcd"
}

@@ -69,5 +69,5 @@ // LICENSE : MIT

const fixerProcessList = ruleDescriptors.fixableDescriptors.map((ruleDescriptor) => {
return (sourceText: string): Promise<string> => {
return async (sourceText: string): Promise<string> => {
// create new SourceCode object
const preProcessResult = preProcess(sourceText, sourceCode.filePath);
const preProcessResult = await Promise.resolve(preProcess(sourceText, sourceCode.filePath));
const isParsedObject = isPluginParsedObject(preProcessResult);

@@ -91,4 +91,4 @@ const textForAST = isParsedObject ? preProcessResult.text : sourceText;

return TaskRunner.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
return await TaskRunner.process(task).then(async (messages) => {
const result = await Promise.resolve(postProcess(messages, sourceCode.filePath));
const filteredResult = {

@@ -95,0 +95,0 @@ messages: this.messageProcessManager.process(result.messages),

@@ -55,4 +55,4 @@ // LICENSE : MIT

});
return TaskRunner.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
return TaskRunner.process(task).then(async (messages) => {
const result = await Promise.resolve(postProcess(messages, sourceCode.filePath));
result.messages = this.messageProcessManager.process(result.messages);

@@ -59,0 +59,0 @@ if (result.filePath == null) {

@@ -190,3 +190,5 @@ // LICENSE : MIT

} catch (error) {
error.message = `Error while loading rule '${ruleContext.id}': ${error.message}`;
if (error instanceof Error) {
error.message = `Error while loading rule '${ruleContext.id}': ${error.message}`;
}
throw error;

@@ -207,3 +209,5 @@ }

} catch (error) {
error.message = `Error while loading filter rule '${ruleContext.id}': ${error.message}`;
if (error instanceof Error) {
error.message = `Error while loading filter rule '${ruleContext.id}': ${error.message}`;
}
throw error;

@@ -210,0 +214,0 @@ }

@@ -123,3 +123,3 @@ // MIT © 2017- azu

*/
private _parallelProcess({
private async _parallelProcess({
descriptor,

@@ -146,3 +146,3 @@ text,

);
const preProcessResult = preProcess(text, filePath);
const preProcessResult = await Promise.resolve(preProcess(text, filePath));
// { text, ast } or ast

@@ -171,3 +171,3 @@ const isParsedObject = isPluginParsedObject(preProcessResult);

const linterProcessor = new LinterProcessor(processor, this.messageProcessManager);
return linterProcessor
return await linterProcessor
.process({

@@ -195,3 +195,3 @@ config: this.config,

*/
private _sequenceProcess({
private async _sequenceProcess({
descriptor,

@@ -218,3 +218,3 @@ text,

);
const preProcessResult = preProcess(text, filePath);
const preProcessResult = await Promise.resolve(preProcess(text, filePath));
// { text, ast } or ast

@@ -243,3 +243,3 @@ const isParsedObject = isPluginParsedObject(preProcessResult);

const fixerProcessor = new FixerProcessor(processor, this.messageProcessManager);
return fixerProcessor
return await fixerProcessor
.process({

@@ -246,0 +246,0 @@ config: this.config,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc