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

@textlint/kernel

Package Overview
Dependencies
Maintainers
5
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.0-beta.0 to 12.0.0-beta.1

115

lib/src/context/TextlintFilterRuleContextImpl.js

@@ -23,11 +23,9 @@ "use strict";

exports.TextlintFilterRuleContextImpl = void 0;
var assert = __importStar(require("assert"));
var TextlintRuleErrorImpl_1 = require("./TextlintRuleErrorImpl");
var TextlintFilterRuleContextImpl = /** @class */ (function () {
function TextlintFilterRuleContextImpl(args) {
var _this = this;
this.shouldIgnore = function (range, optional) {
if (optional === void 0) { optional = {}; }
const assert = __importStar(require("assert"));
const TextlintRuleErrorImpl_1 = require("./TextlintRuleErrorImpl");
class TextlintFilterRuleContextImpl {
constructor(args) {
this.shouldIgnore = (range, optional = {}) => {
assert.ok(Array.isArray(range) && typeof range[0] === "number" && typeof range[1] === "number", "shouldIgnore([number, number]); accept range.");
_this._ignoreReport({ ruleId: _this._ruleId, range: range, optional: optional });
this._ignoreReport({ ruleId: this._ruleId, range, optional });
};

@@ -37,4 +35,4 @@ /**

*/
this.getFilePath = function () {
return _this._sourceCode.getFilePath();
this.getFilePath = () => {
return this._sourceCode.getFilePath();
};

@@ -48,4 +46,4 @@ /**

*/
this.getSource = function (node, beforeCount, afterCount) {
return _this._sourceCode.getSource(node, beforeCount, afterCount);
this.getSource = (node, beforeCount, afterCount) => {
return this._sourceCode.getSource(node, beforeCount, afterCount);
};

@@ -65,4 +63,4 @@ /**

*/
this.getConfigBaseDir = function () {
return _this._configBaseDir;
this.getConfigBaseDir = () => {
return this._configBaseDir;
};

@@ -76,58 +74,37 @@ this._ruleId = args.ruleId;

}
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "id", {
/**
* Rule id
* @returns {string}
*/
get: function () {
return this._ruleId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "severity", {
get: function () {
return this._severityLevel;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "Syntax", {
/**
* Node's type values
* @type {TextLintNodeType}
*/
get: function () {
return this._sourceCode.getSyntax();
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "RuleError", {
/**
* CustomError object
* @type {RuleError}
*/
get: function () {
return TextlintRuleErrorImpl_1.TextlintRuleErrorImpl;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "report", {
/**
* Not use
* @returns {() => void}
*/
get: function () {
return function () {
throw new Error("Filter rule can not report");
};
},
enumerable: false,
configurable: true
});
return TextlintFilterRuleContextImpl;
}());
/**
* Rule id
* @returns {string}
*/
get id() {
return this._ruleId;
}
get severity() {
return this._severityLevel;
}
/**
* Node's type values
* @type {TextLintNodeType}
*/
get Syntax() {
return this._sourceCode.getSyntax();
}
/**
* CustomError object
* @type {RuleError}
*/
get RuleError() {
return TextlintRuleErrorImpl_1.TextlintRuleErrorImpl;
}
/**
* Not use
* @returns {() => void}
*/
get report() {
return () => {
throw new Error("Filter rule can not report");
};
}
}
exports.TextlintFilterRuleContextImpl = TextlintFilterRuleContextImpl;
//# sourceMappingURL=TextlintFilterRuleContextImpl.js.map

51

lib/src/context/TextlintRuleContextFixCommandGeneratorImpl.js

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

exports.TextlintRuleContextFixCommandGeneratorImpl = void 0;
var assert = __importStar(require("assert"));
const assert = __importStar(require("assert"));
/**

@@ -36,3 +36,3 @@ * Creates a fix command that inserts text at the specified index in the source text.

range: [index, index],
text: text,
text,
isAbsolute: false

@@ -52,3 +52,3 @@ };

range: [index, index],
text: text,
text,
isAbsolute: true

@@ -64,5 +64,3 @@ };

*/
var TextlintRuleContextFixCommandGeneratorImpl = /** @class */ (function () {
function TextlintRuleContextFixCommandGeneratorImpl() {
}
class TextlintRuleContextFixCommandGeneratorImpl {
/**

@@ -75,5 +73,5 @@ * Creates a fix command that inserts text after the given node or token.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.insertTextAfter = function (node, text) {
insertTextAfter(node, text) {
return insertTextAtAbsolute(node.range[1], text);
};
}
/**

@@ -88,5 +86,5 @@ * Creates a fix command that inserts text after the specified range in the source text.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.insertTextAfterRange = function (range, text) {
insertTextAfterRange(range, text) {
return insertTextAt(range[1], text);
};
}
/**

@@ -99,5 +97,5 @@ * Creates a fix command that inserts text before the given node or token.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.insertTextBefore = function (node, text) {
insertTextBefore(node, text) {
return insertTextAtAbsolute(node.range[0], text);
};
}
/**

@@ -112,5 +110,5 @@ * Creates a fix command that inserts text before the specified range in the source text.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.insertTextBeforeRange = function (range, text) {
insertTextBeforeRange(range, text) {
return insertTextAt(range[0], text);
};
}
/**

@@ -123,9 +121,9 @@ * Creates a fix command that replaces text at the node or token.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.replaceText = function (node, text) {
replaceText(node, text) {
return {
range: node.range,
text: text,
text,
isAbsolute: true
};
};
}
/**

@@ -140,9 +138,9 @@ * Creates a fix command that replaces text at the specified range in the source text.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.replaceTextRange = function (range, text) {
replaceTextRange(range, text) {
return {
range: range,
text: text,
range,
text,
isAbsolute: false
};
};
}
/**

@@ -154,5 +152,5 @@ * Creates a fix command that removes the node or token from the source.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.remove = function (node) {
remove(node) {
return this.replaceText(node, "");
};
}
/**

@@ -166,8 +164,7 @@ * Creates a fix command that removes the specified range of text from the source.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.removeRange = function (range) {
removeRange(range) {
return this.replaceTextRange(range, "");
};
return TextlintRuleContextFixCommandGeneratorImpl;
}());
}
}
exports.TextlintRuleContextFixCommandGeneratorImpl = TextlintRuleContextFixCommandGeneratorImpl;
//# sourceMappingURL=TextlintRuleContextFixCommandGeneratorImpl.js.map

@@ -7,14 +7,13 @@ "use strict";

exports.TextlintRuleContextImpl = void 0;
var assert_1 = __importDefault(require("assert"));
var TextlintRuleContextFixCommandGeneratorImpl_1 = require("./TextlintRuleContextFixCommandGeneratorImpl");
var TextlintRuleSeverityLevelKeys_1 = require("./TextlintRuleSeverityLevelKeys");
var TextlintRuleErrorImpl_1 = require("./TextlintRuleErrorImpl");
var ruleFixer = new TextlintRuleContextFixCommandGeneratorImpl_1.TextlintRuleContextFixCommandGeneratorImpl();
var TextlintRuleContextImpl = /** @class */ (function () {
function TextlintRuleContextImpl(args) {
var _this = this;
const assert_1 = __importDefault(require("assert"));
const TextlintRuleContextFixCommandGeneratorImpl_1 = require("./TextlintRuleContextFixCommandGeneratorImpl");
const TextlintRuleSeverityLevelKeys_1 = require("./TextlintRuleSeverityLevelKeys");
const TextlintRuleErrorImpl_1 = require("./TextlintRuleErrorImpl");
const ruleFixer = new TextlintRuleContextFixCommandGeneratorImpl_1.TextlintRuleContextFixCommandGeneratorImpl();
class TextlintRuleContextImpl {
constructor(args) {
/**
* report function that is called in a rule
*/
this.report = function (node, ruleError, _shouldNotUsed) {
this.report = (node, ruleError, _shouldNotUsed) => {
assert_1.default.ok(!(node instanceof TextlintRuleErrorImpl_1.TextlintRuleErrorImpl), "1st argument should be node. Usage: `report(node, ruleError);`");

@@ -24,9 +23,9 @@ assert_1.default.ok(_shouldNotUsed === undefined, "3rd argument should not be used. Usage: `report(node, ruleError);`");

// severity come from `.textlintrc` option like `{ "<rule-name>" : { serverity: "warning" } } `
_this._report({ ruleId: _this._ruleId, node: node, severity: _this._severityLevel, ruleError: ruleError });
this._report({ ruleId: this._ruleId, node, severity: this._severityLevel, ruleError });
}
else {
var ruleReportedObject = ruleError;
const ruleReportedObject = ruleError;
// severity come from report arguments like `report(node, { severity: 1 })`
var level = ruleReportedObject.severity || TextlintRuleSeverityLevelKeys_1.TextlintRuleSeverityLevelKeys.error;
_this._report({ ruleId: _this._ruleId, node: node, severity: level, ruleError: ruleReportedObject });
const level = ruleReportedObject.severity || TextlintRuleSeverityLevelKeys_1.TextlintRuleSeverityLevelKeys.error;
this._report({ ruleId: this._ruleId, node, severity: level, ruleError: ruleReportedObject });
}

@@ -37,4 +36,4 @@ };

*/
this.getFilePath = function () {
return _this._sourceCode.getFilePath();
this.getFilePath = () => {
return this._sourceCode.getFilePath();
};

@@ -48,4 +47,4 @@ /**

*/
this.getSource = function (node, beforeCount, afterCount) {
return _this._sourceCode.getSource(node, beforeCount, afterCount);
this.getSource = (node, beforeCount, afterCount) => {
return this._sourceCode.getSource(node, beforeCount, afterCount);
};

@@ -65,4 +64,4 @@ /**

*/
this.getConfigBaseDir = function () {
return _this._configBaseDir;
this.getConfigBaseDir = () => {
return this._configBaseDir;
};

@@ -76,59 +75,38 @@ this._ruleId = args.ruleId;

}
Object.defineProperty(TextlintRuleContextImpl.prototype, "id", {
/**
* Rule id
* @returns {string}
*/
get: function () {
return this._ruleId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleContextImpl.prototype, "severity", {
/**
* severity level
*/
get: function () {
return this._severityLevel;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleContextImpl.prototype, "Syntax", {
/**
* Node's type values
* @type {ASTNodeTypes}
*/
get: function () {
return this._sourceCode.getSyntax();
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleContextImpl.prototype, "RuleError", {
/**
* CustomError object
* @type {RuleError}
*/
get: function () {
return TextlintRuleErrorImpl_1.TextlintRuleErrorImpl;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleContextImpl.prototype, "fixer", {
/**
* Rule fixer command object
* @type {RuleFixer}
*/
get: function () {
return ruleFixer;
},
enumerable: false,
configurable: true
});
return TextlintRuleContextImpl;
}());
/**
* Rule id
* @returns {string}
*/
get id() {
return this._ruleId;
}
/**
* severity level
*/
get severity() {
return this._severityLevel;
}
/**
* Node's type values
* @type {ASTNodeTypes}
*/
get Syntax() {
return this._sourceCode.getSyntax();
}
/**
* CustomError object
* @type {RuleError}
*/
get RuleError() {
return TextlintRuleErrorImpl_1.TextlintRuleErrorImpl;
}
/**
* Rule fixer command object
* @type {RuleFixer}
*/
get fixer() {
return ruleFixer;
}
}
exports.TextlintRuleContextImpl = TextlintRuleContextImpl;
//# sourceMappingURL=TextlintRuleContextImpl.js.map

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

exports.TextlintRuleErrorImpl = void 0;
var TextlintRuleErrorImpl = /** @class */ (function () {
class TextlintRuleErrorImpl {
/**

@@ -14,3 +14,3 @@ * RuleError is like Error object.

*/
function TextlintRuleErrorImpl(message, paddingLocation) {
constructor(message, paddingLocation) {
this.message = message;

@@ -45,3 +45,3 @@ if (typeof paddingLocation === "object") {

}
TextlintRuleErrorImpl.prototype.toString = function () {
toString() {
return JSON.stringify({

@@ -54,6 +54,5 @@ message: this.message,

});
};
return TextlintRuleErrorImpl;
}());
}
}
exports.TextlintRuleErrorImpl = TextlintRuleErrorImpl;
//# sourceMappingURL=TextlintRuleErrorImpl.js.map

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

exports.TextlintSourceCodeImpl = void 0;
var ast_node_types_1 = require("@textlint/ast-node-types");
var assert = __importStar(require("assert"));
var structured_source_1 = __importDefault(require("structured-source"));
const ast_node_types_1 = require("@textlint/ast-node-types");
const assert = __importStar(require("assert"));
const structured_source_1 = __importDefault(require("structured-source"));
/**

@@ -48,3 +48,3 @@ * Validates that the given AST has the required information.

*/
var TextlintSourceCodeImpl = /** @class */ (function () {
class TextlintSourceCodeImpl {
/**

@@ -56,4 +56,3 @@ * @param {string} text

*/
function TextlintSourceCodeImpl(_a) {
var _b = _a.text, text = _b === void 0 ? "" : _b, ast = _a.ast, ext = _a.ext, filePath = _a.filePath;
constructor({ text = "", ast, ext, filePath }) {
validate(ast);

@@ -78,5 +77,5 @@ assert.ok(ext || filePath, "should be set either of fileExt or filePath.");

*/
TextlintSourceCodeImpl.prototype.getSyntax = function () {
getSyntax() {
return ast_node_types_1.ASTNodeTypes;
};
}
/**

@@ -86,5 +85,5 @@ * get filePath

*/
TextlintSourceCodeImpl.prototype.getFilePath = function () {
getFilePath() {
return this.filePath;
};
}
/**

@@ -97,7 +96,7 @@ * Gets the source code for the given node.

*/
TextlintSourceCodeImpl.prototype.getSource = function (node, beforeCount, afterCount) {
var currentText = this.text;
getSource(node, beforeCount, afterCount) {
const currentText = this.text;
if (node) {
var start = Math.max(node.range[0] - (beforeCount || 0), 0);
var end = node.range[1] + (afterCount || 0);
const start = Math.max(node.range[0] - (beforeCount || 0), 0);
const end = node.range[1] + (afterCount || 0);
return currentText.slice(start, end);

@@ -108,3 +107,3 @@ }

}
};
}
// StructuredSource wrapper

@@ -115,5 +114,5 @@ /**

*/
TextlintSourceCodeImpl.prototype.locationToRange = function (loc) {
locationToRange(loc) {
return this._structuredSource.locationToRange(loc);
};
}
/**

@@ -123,5 +122,5 @@ * @param {[ number, number ]} range - pair of indice.

*/
TextlintSourceCodeImpl.prototype.rangeToLocation = function (range) {
rangeToLocation(range) {
return this._structuredSource.rangeToLocation(range);
};
}
/**

@@ -131,5 +130,5 @@ * @param {Position} pos - position indicator.

*/
TextlintSourceCodeImpl.prototype.positionToIndex = function (pos) {
positionToIndex(pos) {
return this._structuredSource.positionToIndex(pos);
};
}
/**

@@ -139,8 +138,7 @@ * @param {number} index - index to the source code.

*/
TextlintSourceCodeImpl.prototype.indexToPosition = function (index) {
indexToPosition(index) {
return this._structuredSource.indexToPosition(index);
};
return TextlintSourceCodeImpl;
}());
}
}
exports.TextlintSourceCodeImpl = TextlintSourceCodeImpl;
//# sourceMappingURL=TextlintSourceCodeImpl.js.map

@@ -6,6 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var assert_1 = __importDefault(require("assert"));
var feature_flag_1 = require("@textlint/feature-flag");
var SourceLocation = /** @class */ (function () {
function SourceLocation(source) {
const assert_1 = __importDefault(require("assert"));
const feature_flag_1 = require("@textlint/feature-flag");
class SourceLocation {
constructor(source) {
this.source = source;

@@ -16,6 +16,6 @@ }

*/
SourceLocation.prototype.adjust = function (reportArgs) {
var node = reportArgs.node, ruleError = reportArgs.ruleError, ruleId = reportArgs.ruleId;
var errorPrefix = "[" + ruleId + "]" || "";
var padding = ruleError;
adjust(reportArgs) {
const { node, ruleError, ruleId } = reportArgs;
const errorPrefix = `[${ruleId}]` || "";
const padding = ruleError;
/*

@@ -25,6 +25,14 @@ FIXME: It is old and un-document way

*/
var _backwardCompatibleIndexValue;
let _backwardCompatibleIndexValue;
if (typeof padding === "number") {
_backwardCompatibleIndexValue = padding;
feature_flag_1.throwIfTesting(errorPrefix + " This is un-document way:\nreport(node, new RuleError(\"message\", index);\n\nPlease use { index }: \n\nreport(node, new RuleError(\"message\", {\n index: paddingLineColumn\n});\n");
feature_flag_1.throwIfTesting(`${errorPrefix} This is un-document way:
report(node, new RuleError("message", index);
Please use { index }:
report(node, new RuleError("message", {
index: paddingLineColumn
});
`);
}

@@ -34,3 +42,16 @@ // when running from textlint-tester, assert

// FIXME: Backward compatible <= textlint.5.5
feature_flag_1.throwIfTesting(errorPrefix + " Have to use a sets with \"line\" and \"column\".\nSee FAQ: https://github.com/textlint/textlint/blob/master/docs/faq/line-column-or-index.md \n\nreport(node, new RuleError(\"message\", {\n line: paddingLineNumber,\n column: paddingLineColumn\n});\n\nOR use \"index\" property insteadof only \"column\".\n\nreport(node, new RuleError(\"message\", {\n index: paddingLineColumn\n});\n");
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
report(node, new RuleError("message", {
line: paddingLineNumber,
column: paddingLineColumn
});
OR use "index" property insteadof only "column".
report(node, new RuleError("message", {
index: paddingLineColumn
});
`);
}

@@ -42,6 +63,23 @@ // When either one of {column, line} or {index} is not used, throw error

// Always throw Error
throw new Error(errorPrefix + " Have to use one of {line, column} or {index}.\nYou should use either one:\n\nuse \"line\" and \"column\" property\n\nreport(node, new RuleError(\"message\", {\n line: paddingLineNumber,\n column: paddingLineColumn\n});\n\nOR \n\nuse \"index\" property\n\nreport(node, new RuleError(\"message\", {\n index: paddingIndexValue\n});\n");
throw new Error(`${errorPrefix} Have to use one of {line, column} or {index}.
You should use either one:
use "line" and "column" property
report(node, new RuleError("message", {
line: paddingLineNumber,
column: paddingLineColumn
});
OR
use "index" property
report(node, new RuleError("message", {
index: paddingIndexValue
});
`);
}
var adjustedLoc = this.toAbsoluteLocation(node, padding, _backwardCompatibleIndexValue);
var adjustedFix = this.toAbsolutePositionFix(node, padding);
const adjustedLoc = this.toAbsoluteLocation(node, padding, _backwardCompatibleIndexValue);
const adjustedFix = this.toAbsolutePositionFix(node, padding);
/*

@@ -55,12 +93,12 @@ {

return Object.assign({}, adjustedLoc, adjustedFix);
};
SourceLocation.prototype.toAbsoluteLocation = function (node, padding, _paddingIndex) {
var nodeRange = node.range;
var line = node.loc.start.line;
var column = node.loc.start.column;
}
toAbsoluteLocation(node, padding, _paddingIndex) {
const nodeRange = node.range;
const line = node.loc.start.line;
const column = node.loc.start.column;
// when use {index}
if (padding.index !== undefined || _paddingIndex !== undefined) {
var startNodeIndex = nodeRange[0];
var paddingIndex = _paddingIndex || padding.index;
var position = this.source.indexToPosition(startNodeIndex + paddingIndex);
const startNodeIndex = nodeRange[0];
const paddingIndex = _paddingIndex || padding.index;
const position = this.source.indexToPosition(startNodeIndex + paddingIndex);
return {

@@ -74,3 +112,3 @@ column: position.column,

if (padding.line > 0) {
var addedLine = line + padding.line;
const addedLine = line + padding.line;
// when report with padding {line, column}, message.column should be 0 + padding.column.

@@ -87,3 +125,3 @@ // In other word, padding line > 0 and message.column start with 0.

line: addedLine,
column: column
column
};

@@ -95,6 +133,6 @@ }

if (padding.line !== undefined && padding.line > 0) {
var addedLine = line + padding.line;
const addedLine = line + padding.line;
return {
line: addedLine,
column: column
column
};

@@ -111,5 +149,5 @@ }

if (padding.column !== undefined && padding.column > 0) {
var addedColumn = column + padding.column;
const addedColumn = column + padding.column;
return {
line: line,
line,
column: addedColumn

@@ -119,6 +157,6 @@ };

return {
column: column,
line: line
column,
line
};
};
}
/**

@@ -128,4 +166,4 @@ * Adjust `fix` command range

*/
SourceLocation.prototype.toAbsolutePositionFix = function (node, ruleErrorObject) {
var nodeRange = node.range;
toAbsolutePositionFix(node, ruleErrorObject) {
const nodeRange = node.range;
// if not found `fix`, return empty object

@@ -158,6 +196,5 @@ if (ruleErrorObject.fix === undefined) {

};
};
return SourceLocation;
}());
}
}
exports.default = SourceLocation;
//# sourceMappingURL=source-location.js.map

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

exports.createTextlintPluginDescriptors = exports.createTextlintFilterRuleDescriptors = exports.createTextlintRuleDescriptors = void 0;
var TextlintFilterRuleDescriptor_1 = require("./TextlintFilterRuleDescriptor");
var TextlintFilterRuleDescriptors_1 = require("./TextlintFilterRuleDescriptors");
var TextlintRuleDescriptors_1 = require("./TextlintRuleDescriptors");
var TextlintLintableRuleDescriptor_1 = require("./TextlintLintableRuleDescriptor");
var TextlintPluginDescriptors_1 = require("./TextlintPluginDescriptors");
var TextlintPluginDescriptor_1 = require("./TextlintPluginDescriptor");
var rule_creator_helper_1 = require("./rule-creator-helper");
var TextlintFixableRuleDescriptor_1 = require("./TextlintFixableRuleDescriptor");
var createTextlintRuleDescriptors = function (rules) {
var ruleOrFixableRuleDescriptorList = rules.map(function (rule) {
const TextlintFilterRuleDescriptor_1 = require("./TextlintFilterRuleDescriptor");
const TextlintFilterRuleDescriptors_1 = require("./TextlintFilterRuleDescriptors");
const TextlintRuleDescriptors_1 = require("./TextlintRuleDescriptors");
const TextlintLintableRuleDescriptor_1 = require("./TextlintLintableRuleDescriptor");
const TextlintPluginDescriptors_1 = require("./TextlintPluginDescriptors");
const TextlintPluginDescriptor_1 = require("./TextlintPluginDescriptor");
const rule_creator_helper_1 = require("./rule-creator-helper");
const TextlintFixableRuleDescriptor_1 = require("./TextlintFixableRuleDescriptor");
const createTextlintRuleDescriptors = (rules) => {
const ruleOrFixableRuleDescriptorList = rules.map((rule) => {
if (rule_creator_helper_1.hasFixer(rule.rule)) {

@@ -26,10 +26,10 @@ return new TextlintFixableRuleDescriptor_1.TextlintFixableRuleDescriptor(rule);

exports.createTextlintRuleDescriptors = createTextlintRuleDescriptors;
var createTextlintFilterRuleDescriptors = function (rules) {
return new TextlintFilterRuleDescriptors_1.TextlintFilterRuleDescriptors(rules.map(function (rule) { return new TextlintFilterRuleDescriptor_1.TextlintFilterRuleDescriptor(rule); }));
const createTextlintFilterRuleDescriptors = (rules) => {
return new TextlintFilterRuleDescriptors_1.TextlintFilterRuleDescriptors(rules.map((rule) => new TextlintFilterRuleDescriptor_1.TextlintFilterRuleDescriptor(rule)));
};
exports.createTextlintFilterRuleDescriptors = createTextlintFilterRuleDescriptors;
var createTextlintPluginDescriptors = function (rules) {
return new TextlintPluginDescriptors_1.TextlintPluginDescriptors(rules.map(function (rule) { return new TextlintPluginDescriptor_1.TextlintPluginDescriptor(rule); }));
const createTextlintPluginDescriptors = (rules) => {
return new TextlintPluginDescriptors_1.TextlintPluginDescriptors(rules.map((rule) => new TextlintPluginDescriptor_1.TextlintPluginDescriptor(rule)));
};
exports.createTextlintPluginDescriptors = createTextlintPluginDescriptors;
//# sourceMappingURL=DescriptorsFactory.js.map

@@ -11,6 +11,6 @@ "use strict";

*/
var filterDuplicateDescriptor = function (descriptors) {
var newDescriptorList = [];
descriptors.forEach(function (descriptor) {
var existsDescriptor = newDescriptorList.some(function (existDescriptor) {
const filterDuplicateDescriptor = (descriptors) => {
const newDescriptorList = [];
descriptors.forEach((descriptor) => {
const existsDescriptor = newDescriptorList.some((existDescriptor) => {
return existDescriptor.equals(descriptor);

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

@@ -78,6 +78,5 @@ "use strict";

*/
function assertRuleShape(ruleModule, key) {
if (key === void 0) { key = ""; }
function assertRuleShape(ruleModule, key = "") {
if (ruleModule === undefined) {
throw new Error("Definition of rule '" + key + "' was not found.");
throw new Error(`Definition of rule '${key}' was not found.`);
}

@@ -91,3 +90,7 @@ /*

if (!isRuleModule(ruleModule)) {
throw new Error("Definition of rule '" + key + "' was not rule module.\nRule should export function:\nmodule.exports = function(context){\n // Your rule\n};");
throw new Error(`Definition of rule '${key}' was not rule module.
Rule should export function:
module.exports = function(context){
// Your rule
};`);
}

@@ -94,0 +97,0 @@ }

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

exports.TextlintFilterRuleDescriptor = void 0;
var rule_creator_helper_1 = require("./rule-creator-helper");
var deep_equal_1 = __importDefault(require("deep-equal"));
const rule_creator_helper_1 = require("./rule-creator-helper");
const deep_equal_1 = __importDefault(require("deep-equal"));
/**

@@ -15,70 +15,46 @@ * Textlint Rule Descriptor.

*/
var TextlintFilterRuleDescriptor = /** @class */ (function () {
function TextlintFilterRuleDescriptor(kernelFilterRule) {
class TextlintFilterRuleDescriptor {
constructor(kernelFilterRule) {
this.kernelFilterRule = kernelFilterRule;
}
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "id", {
get: function () {
return this.kernelFilterRule.ruleId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "rule", {
get: function () {
return this.kernelFilterRule.rule;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "enabled", {
/**
* Return true if this rule is enabled.
*/
get: function () {
return this.rawOptions !== false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "filter", {
/**
* Return filter function
* You should check hasLiner before call this.
*/
get: function () {
return rule_creator_helper_1.getFilter(this.rule);
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "normalizedOptions", {
/**
* Return normalized rule option object.
* If the rule have not option, return `true` by default.
*/
get: function () {
// default: { ruleName: true }
var DefaultRuleConfigValue = {};
if (typeof this.kernelFilterRule.options === "boolean" || this.kernelFilterRule.options === undefined) {
return DefaultRuleConfigValue;
}
else {
return this.kernelFilterRule.options;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "rawOptions", {
get: function () {
get id() {
return this.kernelFilterRule.ruleId;
}
get rule() {
return this.kernelFilterRule.rule;
}
/**
* Return true if this rule is enabled.
*/
get enabled() {
return this.rawOptions !== false;
}
/**
* Return filter function
* You should check hasLiner before call this.
*/
get filter() {
return rule_creator_helper_1.getFilter(this.rule);
}
/**
* Return normalized rule option object.
* If the rule have not option, return `true` by default.
*/
get normalizedOptions() {
// default: { ruleName: true }
const DefaultRuleConfigValue = {};
if (typeof this.kernelFilterRule.options === "boolean" || this.kernelFilterRule.options === undefined) {
return DefaultRuleConfigValue;
}
else {
return this.kernelFilterRule.options;
},
enumerable: false,
configurable: true
});
}
}
get rawOptions() {
return this.kernelFilterRule.options;
}
/**
* Return true if descriptor is same
*/
TextlintFilterRuleDescriptor.prototype.equals = function (descriptor) {
equals(descriptor) {
return (this.rule === descriptor.rule &&

@@ -88,9 +64,8 @@ deep_equal_1.default(this.normalizedOptions, descriptor.normalizedOptions, {

}));
};
TextlintFilterRuleDescriptor.prototype.toKernel = function () {
}
toKernel() {
return this.kernelFilterRule;
};
return TextlintFilterRuleDescriptor;
}());
}
}
exports.TextlintFilterRuleDescriptor = TextlintFilterRuleDescriptor;
//# sourceMappingURL=TextlintFilterRuleDescriptor.js.map

@@ -5,9 +5,8 @@ // LICENSE : MIT

exports.TextlintFilterRuleDescriptors = void 0;
var DescriptorUtil_1 = require("./DescriptorUtil");
const DescriptorUtil_1 = require("./DescriptorUtil");
/**
* The collection class of TextlintFilterRuleDescriptor
*/
var TextlintFilterRuleDescriptors = /** @class */ (function () {
function TextlintFilterRuleDescriptors(ruleDescriptorList) {
if (ruleDescriptorList === void 0) { ruleDescriptorList = []; }
class TextlintFilterRuleDescriptors {
constructor(ruleDescriptorList = []) {
this.ruleDescriptorList = ruleDescriptorList;

@@ -19,40 +18,31 @@ }

*/
TextlintFilterRuleDescriptors.prototype.toKernelFilterRulesFormat = function () {
return this.withoutDuplicated().descriptors.map(function (descriptor) {
toKernelFilterRulesFormat() {
return this.withoutDuplicated().descriptors.map((descriptor) => {
return descriptor.toKernel();
});
};
Object.defineProperty(TextlintFilterRuleDescriptors.prototype, "descriptors", {
/**
* Return enabled descriptors
*/
get: function () {
return this.ruleDescriptorList.filter(function (descriptor) {
return descriptor.enabled;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptors.prototype, "allDescriptors", {
/**
* Return all descriptors that include disabled descriptors
*/
get: function () {
return this.ruleDescriptorList;
},
enumerable: false,
configurable: true
});
}
/**
* Return enabled descriptors
*/
get descriptors() {
return this.ruleDescriptorList.filter((descriptor) => {
return descriptor.enabled;
});
}
/**
* Return all descriptors that include disabled descriptors
*/
get allDescriptors() {
return this.ruleDescriptorList;
}
/**
* filter duplicated descriptors
*/
TextlintFilterRuleDescriptors.prototype.withoutDuplicated = function () {
withoutDuplicated() {
// remove last duplicated item
var newDescriptorList = DescriptorUtil_1.filterDuplicateDescriptor(this.ruleDescriptorList);
const newDescriptorList = DescriptorUtil_1.filterDuplicateDescriptor(this.ruleDescriptorList);
return new TextlintFilterRuleDescriptors(newDescriptorList);
};
return TextlintFilterRuleDescriptors;
}());
}
}
exports.TextlintFilterRuleDescriptors = TextlintFilterRuleDescriptors;
//# sourceMappingURL=TextlintFilterRuleDescriptors.js.map
// LICENSE : MIT
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextlintFixableRuleDescriptor = void 0;
var rule_creator_helper_1 = require("./rule-creator-helper");
var TextlintLintableRuleDescriptor_1 = require("./TextlintLintableRuleDescriptor");
const rule_creator_helper_1 = require("./rule-creator-helper");
const TextlintLintableRuleDescriptor_1 = require("./TextlintLintableRuleDescriptor");
/**

@@ -27,21 +12,12 @@ * Textlint Fixable Rule Descriptor.

*/
var TextlintFixableRuleDescriptor = /** @class */ (function (_super) {
__extends(TextlintFixableRuleDescriptor, _super);
function TextlintFixableRuleDescriptor() {
return _super !== null && _super.apply(this, arguments) || this;
class TextlintFixableRuleDescriptor extends TextlintLintableRuleDescriptor_1.TextlintLintableRuleDescriptor {
/**
* Return fixer function
* You should check hasFixer before call this.
*/
get fixer() {
return rule_creator_helper_1.getFixer(this.rule);
}
Object.defineProperty(TextlintFixableRuleDescriptor.prototype, "fixer", {
/**
* Return fixer function
* You should check hasFixer before call this.
*/
get: function () {
return rule_creator_helper_1.getFixer(this.rule);
},
enumerable: false,
configurable: true
});
return TextlintFixableRuleDescriptor;
}(TextlintLintableRuleDescriptor_1.TextlintLintableRuleDescriptor));
}
exports.TextlintFixableRuleDescriptor = TextlintFixableRuleDescriptor;
//# sourceMappingURL=TextlintFixableRuleDescriptor.js.map
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextlintKernelDescriptor = void 0;
var DescriptorsFactory_1 = require("./DescriptorsFactory");
var TextlintKernelDescriptor = /** @class */ (function () {
function TextlintKernelDescriptor(args) {
const DescriptorsFactory_1 = require("./DescriptorsFactory");
class TextlintKernelDescriptor {
constructor(args) {
this.args = args;

@@ -23,13 +12,9 @@ this.rule = DescriptorsFactory_1.createTextlintRuleDescriptors(args.rules);

}
Object.defineProperty(TextlintKernelDescriptor.prototype, "availableExtensions", {
/**
* Return available extensions of plugins
*/
get: function () {
return this.plugin.availableExtensions;
},
enumerable: false,
configurable: true
});
/**
* Return available extensions of plugins
*/
get availableExtensions() {
return this.plugin.availableExtensions;
}
/**
* Merge constructor args and partialArgs

@@ -39,5 +24,5 @@ * It shallow merge partialArgs.

*/
TextlintKernelDescriptor.prototype.shallowMerge = function (partialArgs) {
return new TextlintKernelDescriptor(__assign(__assign({}, this.args), partialArgs));
};
shallowMerge(partialArgs) {
return new TextlintKernelDescriptor(Object.assign(Object.assign({}, this.args), partialArgs));
}
/**

@@ -53,8 +38,7 @@ * find PluginDescriptor with extension.

*/
TextlintKernelDescriptor.prototype.findPluginDescriptorWithExt = function (ext) {
findPluginDescriptorWithExt(ext) {
return this.plugin.findPluginDescriptorWithExt(ext);
};
return TextlintKernelDescriptor;
}());
}
}
exports.TextlintKernelDescriptor = TextlintKernelDescriptor;
//# sourceMappingURL=TextlintKernelDescriptor.js.map

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

exports.TextlintLintableRuleDescriptor = void 0;
var rule_creator_helper_1 = require("./rule-creator-helper");
var deep_equal_1 = __importDefault(require("deep-equal"));
const rule_creator_helper_1 = require("./rule-creator-helper");
const deep_equal_1 = __importDefault(require("deep-equal"));
/**

@@ -15,74 +15,50 @@ * Textlint Rule Descriptor.

*/
var TextlintLintableRuleDescriptor = /** @class */ (function () {
function TextlintLintableRuleDescriptor(textlintKernelRule) {
class TextlintLintableRuleDescriptor {
constructor(textlintKernelRule) {
this.textlintKernelRule = textlintKernelRule;
rule_creator_helper_1.assertRuleShape(textlintKernelRule.rule, textlintKernelRule.ruleId);
}
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "id", {
get: function () {
return this.textlintKernelRule.ruleId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "rule", {
/**
* Rule module-self
*/
get: function () {
return this.textlintKernelRule.rule;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "enabled", {
/**
* Return true if this rule is enabled.
*/
get: function () {
return this.rawOptions !== false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "linter", {
/**
* Return linter function
* You should check hasLiner before call this.
*/
get: function () {
return rule_creator_helper_1.getLinter(this.rule);
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "normalizedOptions", {
/**
* Return normalized rule option object.
* If the rule have not option, return `true` by default.
*/
get: function () {
// default: { ruleName: true }
var DefaultRuleConfigValue = {};
if (typeof this.textlintKernelRule.options === "boolean" || this.textlintKernelRule.options === undefined) {
return DefaultRuleConfigValue;
}
else {
return this.textlintKernelRule.options;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "rawOptions", {
get: function () {
get id() {
return this.textlintKernelRule.ruleId;
}
/**
* Rule module-self
*/
get rule() {
return this.textlintKernelRule.rule;
}
/**
* Return true if this rule is enabled.
*/
get enabled() {
return this.rawOptions !== false;
}
/**
* Return linter function
* You should check hasLiner before call this.
*/
get linter() {
return rule_creator_helper_1.getLinter(this.rule);
}
/**
* Return normalized rule option object.
* If the rule have not option, return `true` by default.
*/
get normalizedOptions() {
// default: { ruleName: true }
const DefaultRuleConfigValue = {};
if (typeof this.textlintKernelRule.options === "boolean" || this.textlintKernelRule.options === undefined) {
return DefaultRuleConfigValue;
}
else {
return this.textlintKernelRule.options;
},
enumerable: false,
configurable: true
});
}
}
get rawOptions() {
return this.textlintKernelRule.options;
}
/**
* Return true if descriptor is same
*/
TextlintLintableRuleDescriptor.prototype.equals = function (descriptor) {
equals(descriptor) {
return (this.rule === descriptor.rule &&

@@ -92,9 +68,8 @@ deep_equal_1.default(this.normalizedOptions, descriptor.normalizedOptions, {

}));
};
TextlintLintableRuleDescriptor.prototype.toKernel = function () {
}
toKernel() {
return this.textlintKernelRule;
};
return TextlintLintableRuleDescriptor;
}());
}
}
exports.TextlintLintableRuleDescriptor = TextlintLintableRuleDescriptor;
//# sourceMappingURL=TextlintLintableRuleDescriptor.js.map

@@ -7,7 +7,7 @@ "use strict";

exports.TextlintPluginDescriptor = void 0;
var deep_equal_1 = __importDefault(require("deep-equal"));
const deep_equal_1 = __importDefault(require("deep-equal"));
/**
* Get instance/static `availableExtensions()` from TextlintPluginProcessor
*/
var getAvailableExtensions = function (pluginProcessor) {
const getAvailableExtensions = (pluginProcessor) => {
if (typeof pluginProcessor.availableExtensions === "function") {

@@ -19,7 +19,7 @@ return pluginProcessor.availableExtensions();

// https://github.com/textlint/textlint/issues/531
var PluginProcessorConstructor = pluginProcessor.constructor;
const PluginProcessorConstructor = pluginProcessor.constructor;
if (typeof PluginProcessorConstructor.availableExtensions === "function") {
return PluginProcessorConstructor.availableExtensions();
}
throw new Error("Plugin(" + pluginProcessor + ") should implement availableExtensions() method");
throw new Error(`Plugin(${pluginProcessor}) should implement availableExtensions() method`);
};

@@ -29,63 +29,47 @@ /**

*/
var TextlintPluginDescriptor = /** @class */ (function () {
function TextlintPluginDescriptor(plugin) {
class TextlintPluginDescriptor {
constructor(plugin) {
this.plugin = plugin;
this.plugin = plugin;
if (!this.plugin.plugin.Processor) {
throw new Error("Plugin should have Processor property.\nmodule.exports = {\n Processor: class Processor{ ... }\n}\n");
throw new Error(`Plugin should have Processor property.
module.exports = {
Processor: class Processor{ ... }
}
`);
}
this.processor = new plugin.plugin.Processor(this.normalizedOptions);
}
Object.defineProperty(TextlintPluginDescriptor.prototype, "id", {
get: function () {
return this.plugin.pluginId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptor.prototype, "enabled", {
/**
* Return true if this rule is enabled.
*/
get: function () {
return this.rawOptions !== false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptor.prototype, "availableExtensions", {
/**
* Return available extension of this plugin
*/
get: function () {
return getAvailableExtensions(this.processor);
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptor.prototype, "normalizedOptions", {
get: function () {
// default: { ruleName: true }
var DefaultPluginOption = {};
if (typeof this.plugin.options === "boolean" || this.plugin.options === undefined) {
return DefaultPluginOption;
}
else {
return this.plugin.options;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptor.prototype, "rawOptions", {
get: function () {
get id() {
return this.plugin.pluginId;
}
/**
* Return true if this rule is enabled.
*/
get enabled() {
return this.rawOptions !== false;
}
/**
* Return available extension of this plugin
*/
get availableExtensions() {
return getAvailableExtensions(this.processor);
}
get normalizedOptions() {
// default: { ruleName: true }
const DefaultPluginOption = {};
if (typeof this.plugin.options === "boolean" || this.plugin.options === undefined) {
return DefaultPluginOption;
}
else {
return this.plugin.options;
},
enumerable: false,
configurable: true
});
TextlintPluginDescriptor.prototype.toKernel = function () {
}
}
get rawOptions() {
return this.plugin.options;
}
toKernel() {
return this.plugin;
};
TextlintPluginDescriptor.prototype.equals = function (target) {
}
equals(target) {
return (this.plugin.plugin === target.plugin.plugin &&

@@ -95,6 +79,5 @@ deep_equal_1.default(this.plugin.options, target.plugin.options, {

}));
};
return TextlintPluginDescriptor;
}());
}
}
exports.TextlintPluginDescriptor = TextlintPluginDescriptor;
//# sourceMappingURL=TextlintPluginDescriptor.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextlintPluginDescriptors = void 0;
var DescriptorUtil_1 = require("./DescriptorUtil");
const DescriptorUtil_1 = require("./DescriptorUtil");
/**
* Collection class of TextlintPluginDescriptor
*/
var TextlintPluginDescriptors = /** @class */ (function () {
function TextlintPluginDescriptors(pluginDescriptorList) {
if (pluginDescriptorList === void 0) { pluginDescriptorList = []; }
class TextlintPluginDescriptors {
constructor(pluginDescriptorList = []) {
this.pluginDescriptorList = pluginDescriptorList;
}
Object.defineProperty(TextlintPluginDescriptors.prototype, "descriptors", {
/**
* Return enabled descriptors
*/
get: function () {
return this.pluginDescriptorList.filter(function (descriptor) {
return descriptor.enabled;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptors.prototype, "allDescriptors", {
/**
* Return all descriptors that include disabled descriptors
*/
get: function () {
return this.pluginDescriptorList;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptors.prototype, "availableExtensions", {
/**
* Return available extensions
* It is not includes disabled plugin's extensions.
*/
get: function () {
return this.descriptors.reduce(function (extensions, descriptor) {
return extensions.concat(descriptor.availableExtensions);
}, []);
},
enumerable: false,
configurable: true
});
/**
* Return enabled descriptors
*/
get descriptors() {
return this.pluginDescriptorList.filter((descriptor) => {
return descriptor.enabled;
});
}
/**
* Return all descriptors that include disabled descriptors
*/
get allDescriptors() {
return this.pluginDescriptorList;
}
/**
* Return available extensions
* It is not includes disabled plugin's extensions.
*/
get availableExtensions() {
return this.descriptors.reduce((extensions, descriptor) => {
return extensions.concat(descriptor.availableExtensions);
}, []);
}
/**
* find PluginDescriptor with extension.
* This is forward match.
*/
TextlintPluginDescriptors.prototype.findPluginDescriptorWithExt = function (ext) {
return this.descriptors.find(function (descriptor) {
findPluginDescriptorWithExt(ext) {
return this.descriptors.find((descriptor) => {
return descriptor.availableExtensions.includes(ext);
});
};
}
/**
* filter duplicated descriptors
*/
TextlintPluginDescriptors.prototype.withoutDuplicated = function () {
var newDescriptorList = DescriptorUtil_1.filterDuplicateDescriptor(this.pluginDescriptorList);
withoutDuplicated() {
const newDescriptorList = DescriptorUtil_1.filterDuplicateDescriptor(this.pluginDescriptorList);
return new TextlintPluginDescriptors(newDescriptorList);
};
}
/**

@@ -68,10 +55,9 @@ * Convert this to TextlintKernel rules format

*/
TextlintPluginDescriptors.prototype.toKernelPluginsFormat = function () {
return this.descriptors.map(function (descriptor) {
toKernelPluginsFormat() {
return this.descriptors.map((descriptor) => {
return descriptor.toKernel();
});
};
return TextlintPluginDescriptors;
}());
}
}
exports.TextlintPluginDescriptors = TextlintPluginDescriptors;
//# sourceMappingURL=TextlintPluginDescriptors.js.map

@@ -5,11 +5,10 @@ // LICENSE : MIT

exports.TextlintRuleDescriptors = void 0;
var TextlintLintableRuleDescriptor_1 = require("./TextlintLintableRuleDescriptor");
var DescriptorUtil_1 = require("./DescriptorUtil");
var TextlintFixableRuleDescriptor_1 = require("./TextlintFixableRuleDescriptor");
const TextlintLintableRuleDescriptor_1 = require("./TextlintLintableRuleDescriptor");
const DescriptorUtil_1 = require("./DescriptorUtil");
const TextlintFixableRuleDescriptor_1 = require("./TextlintFixableRuleDescriptor");
/**
* The collection class of TextlintRuleDescriptor
*/
var TextlintRuleDescriptors = /** @class */ (function () {
function TextlintRuleDescriptors(ruleDescriptorList) {
if (ruleDescriptorList === void 0) { ruleDescriptorList = []; }
class TextlintRuleDescriptors {
constructor(ruleDescriptorList = []) {
this.ruleDescriptorList = ruleDescriptorList;

@@ -21,62 +20,45 @@ }

*/
TextlintRuleDescriptors.prototype.toKernelRulesFormat = function () {
return this.withoutDuplicated().lintableDescriptors.map(function (descriptor) {
toKernelRulesFormat() {
return this.withoutDuplicated().lintableDescriptors.map((descriptor) => {
return descriptor.toKernel();
});
};
Object.defineProperty(TextlintRuleDescriptors.prototype, "lintableDescriptors", {
/**
* Return enabled lintable descriptors
*/
get: function () {
return this.descriptors.filter(function (descriptor) {
// fixable is also lintable
return descriptor instanceof TextlintLintableRuleDescriptor_1.TextlintLintableRuleDescriptor;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleDescriptors.prototype, "fixableDescriptors", {
/**
* Return enabled fixable descriptors
*/
get: function () {
return this.descriptors.filter(function (descriptor) {
return descriptor instanceof TextlintFixableRuleDescriptor_1.TextlintFixableRuleDescriptor;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleDescriptors.prototype, "descriptors", {
/**
* Return enabled descriptors
*/
get: function () {
return this.ruleDescriptorList.filter(function (descriptor) { return descriptor.enabled; });
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleDescriptors.prototype, "allDescriptors", {
/**
* Return all descriptors that include disabled descriptors
*/
get: function () {
return this.ruleDescriptorList;
},
enumerable: false,
configurable: true
});
}
/**
* Return enabled lintable descriptors
*/
get lintableDescriptors() {
return this.descriptors.filter((descriptor) => {
// fixable is also lintable
return descriptor instanceof TextlintLintableRuleDescriptor_1.TextlintLintableRuleDescriptor;
});
}
/**
* Return enabled fixable descriptors
*/
get fixableDescriptors() {
return this.descriptors.filter((descriptor) => {
return descriptor instanceof TextlintFixableRuleDescriptor_1.TextlintFixableRuleDescriptor;
});
}
/**
* Return enabled descriptors
*/
get descriptors() {
return this.ruleDescriptorList.filter((descriptor) => descriptor.enabled);
}
/**
* Return all descriptors that include disabled descriptors
*/
get allDescriptors() {
return this.ruleDescriptorList;
}
/**
* filter duplicated descriptors
*/
TextlintRuleDescriptors.prototype.withoutDuplicated = function () {
var newDescriptorList = DescriptorUtil_1.filterDuplicateDescriptor(this.ruleDescriptorList);
withoutDuplicated() {
const newDescriptorList = DescriptorUtil_1.filterDuplicateDescriptor(this.ruleDescriptorList);
return new TextlintRuleDescriptors(newDescriptorList);
};
return TextlintRuleDescriptors;
}());
}
}
exports.TextlintRuleDescriptors = TextlintRuleDescriptors;
//# sourceMappingURL=TextlintRuleDescriptors.js.map

@@ -26,11 +26,11 @@ // LICENSE : MIT

Object.defineProperty(exports, "__esModule", { value: true });
var assert = __importStar(require("assert"));
var fixer_task_1 = __importDefault(require("../task/fixer-task"));
var task_runner_1 = __importDefault(require("../task/task-runner"));
var TextlintSourceCodeImpl_1 = require("../context/TextlintSourceCodeImpl");
var ast_tester_1 = require("@textlint/ast-tester");
var debug_1 = __importDefault(require("debug"));
var source_code_fixer_1 = require("@textlint/source-code-fixer");
var debug = debug_1.default("textlint:fixer-processor");
var FixerProcessor = /** @class */ (function () {
const assert = __importStar(require("assert"));
const fixer_task_1 = __importDefault(require("../task/fixer-task"));
const task_runner_1 = __importDefault(require("../task/task-runner"));
const TextlintSourceCodeImpl_1 = require("../context/TextlintSourceCodeImpl");
const ast_tester_1 = require("@textlint/ast-tester");
const debug_1 = __importDefault(require("debug"));
const source_code_fixer_1 = require("@textlint/source-code-fixer");
const debug = debug_1.default("textlint:fixer-processor");
class FixerProcessor {
/**

@@ -40,3 +40,3 @@ * @param {Processor} processor

*/
function FixerProcessor(processor, messageProcessManager) {
constructor(processor, messageProcessManager) {
this.processor = processor;

@@ -54,28 +54,26 @@ this.messageProcessManager = messageProcessManager;

*/
FixerProcessor.prototype.process = function (_a) {
var _this = this;
var config = _a.config, configBaseDir = _a.configBaseDir, ruleDescriptors = _a.ruleDescriptors, filterRules = _a.filterRules, sourceCode = _a.sourceCode;
process({ config, configBaseDir, ruleDescriptors, filterRules, sourceCode }) {
assert.ok(sourceCode);
var _b = this.processor.processor(sourceCode.ext), preProcess = _b.preProcess, postProcess = _b.postProcess;
const { preProcess, postProcess } = this.processor.processor(sourceCode.ext);
// messages
var resultFilePath = sourceCode.filePath;
let resultFilePath = sourceCode.filePath;
// applied fixing messages
// Revert = Sequentially apply applied message to applied output
// SourceCodeFixer.sequentiallyApplyFixes(fixedOutput, result.applyingMessages);
var applyingMessages = [];
const applyingMessages = [];
// not applied fixing messages
var remainingMessages = [];
const remainingMessages = [];
// original means original for applyingMessages and remainingMessages
// pre-applyingMessages + remainingMessages
var originalMessages = [];
var fixerProcessList = ruleDescriptors.fixableDescriptors.map(function (ruleDescriptor) {
return function (sourceText) {
const originalMessages = [];
const fixerProcessList = ruleDescriptors.fixableDescriptors.map((ruleDescriptor) => {
return (sourceText) => {
// create new SourceCode object
var preProcessResult = preProcess(sourceText, sourceCode.filePath);
var isPluginReturnAnAST = ast_tester_1.isTxtAST(preProcessResult);
var textForAST = isPluginReturnAnAST ? sourceText : preProcessResult.text;
var ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
var newSourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
const preProcessResult = preProcess(sourceText, sourceCode.filePath);
const isPluginReturnAnAST = ast_tester_1.isTxtAST(preProcessResult);
const textForAST = isPluginReturnAnAST ? sourceText : preProcessResult.text;
const ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
const newSourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
text: textForAST,
ast: ast,
ast,
filePath: resultFilePath,

@@ -85,18 +83,18 @@ ext: sourceCode.ext

// create new Task
var task = new fixer_task_1.default({
config: config,
const task = new fixer_task_1.default({
config,
fixableRuleDescriptor: ruleDescriptor,
filterRuleDescriptors: filterRules,
sourceCode: newSourceCode,
configBaseDir: configBaseDir
configBaseDir
});
return task_runner_1.default.process(task).then(function (messages) {
var result = postProcess(messages, sourceCode.filePath);
var filteredResult = {
messages: _this.messageProcessManager.process(result.messages),
filePath: result.filePath ? result.filePath : "<Unkown" + sourceCode.ext + ">"
return task_runner_1.default.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
const filteredResult = {
messages: this.messageProcessManager.process(result.messages),
filePath: result.filePath ? result.filePath : `<Unkown${sourceCode.ext}>`
};
// TODO: should be removed resultFilePath
resultFilePath = filteredResult.filePath;
var applied = source_code_fixer_1.applyFixesToSourceCode(newSourceCode, filteredResult.messages);
const applied = source_code_fixer_1.applyFixesToSourceCode(newSourceCode, filteredResult.messages);
// add messages

@@ -115,23 +113,22 @@ Array.prototype.push.apply(applyingMessages, applied.applyingMessages);

});
var promiseTask = fixerProcessList.reduce(function (promise, fixerProcess) {
return promise.then(function (sourceText) {
const promiseTask = fixerProcessList.reduce((promise, fixerProcess) => {
return promise.then((sourceText) => {
return fixerProcess(sourceText);
});
}, Promise.resolve(sourceCode.text));
return promiseTask.then(function (output) {
debug("Finish Processing: " + resultFilePath);
debug("applyingMessages: " + applyingMessages.length);
debug("remainingMessages: " + remainingMessages.length);
return promiseTask.then((output) => {
debug(`Finish Processing: ${resultFilePath}`);
debug(`applyingMessages: ${applyingMessages.length}`);
debug(`remainingMessages: ${remainingMessages.length}`);
return {
filePath: resultFilePath ? resultFilePath : "<Unkown" + sourceCode.ext + ">",
output: output,
filePath: resultFilePath ? resultFilePath : `<Unkown${sourceCode.ext}>`,
output,
messages: originalMessages,
applyingMessages: applyingMessages,
remainingMessages: remainingMessages
applyingMessages,
remainingMessages
};
});
};
return FixerProcessor;
}());
}
}
exports.default = FixerProcessor;
//# sourceMappingURL=fixer-processor.js.map

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

Object.defineProperty(exports, "__esModule", { value: true });
var assert = __importStar(require("assert"));
const assert = __importStar(require("assert"));
/**

@@ -35,3 +35,3 @@ * Creates a fix command that inserts text at the specified index in the source text.

range: [index, index],
text: text,
text,
isAbsolute: false

@@ -51,3 +51,3 @@ };

range: [index, index],
text: text,
text,
isAbsolute: true

@@ -63,5 +63,3 @@ };

*/
var RuleFixer = /** @class */ (function () {
function RuleFixer() {
}
class RuleFixer {
/**

@@ -74,5 +72,5 @@ * Creates a fix command that inserts text after the given node or token.

*/
RuleFixer.prototype.insertTextAfter = function (node, text) {
insertTextAfter(node, text) {
return insertTextAtAbsolute(node.range[1], text);
};
}
/**

@@ -87,5 +85,5 @@ * Creates a fix command that inserts text after the specified range in the source text.

*/
RuleFixer.prototype.insertTextAfterRange = function (range, text) {
insertTextAfterRange(range, text) {
return insertTextAt(range[1], text);
};
}
/**

@@ -98,5 +96,5 @@ * Creates a fix command that inserts text before the given node or token.

*/
RuleFixer.prototype.insertTextBefore = function (node, text) {
insertTextBefore(node, text) {
return insertTextAtAbsolute(node.range[0], text);
};
}
/**

@@ -111,5 +109,5 @@ * Creates a fix command that inserts text before the specified range in the source text.

*/
RuleFixer.prototype.insertTextBeforeRange = function (range, text) {
insertTextBeforeRange(range, text) {
return insertTextAt(range[0], text);
};
}
/**

@@ -122,9 +120,9 @@ * Creates a fix command that replaces text at the node or token.

*/
RuleFixer.prototype.replaceText = function (node, text) {
replaceText(node, text) {
return {
range: node.range,
text: text,
text,
isAbsolute: true
};
};
}
/**

@@ -139,9 +137,9 @@ * Creates a fix command that replaces text at the specified range in the source text.

*/
RuleFixer.prototype.replaceTextRange = function (range, text) {
replaceTextRange(range, text) {
return {
range: range,
text: text,
range,
text,
isAbsolute: false
};
};
}
/**

@@ -153,5 +151,5 @@ * Creates a fix command that removes the node or token from the source.

*/
RuleFixer.prototype.remove = function (node) {
remove(node) {
return this.replaceText(node, "");
};
}
/**

@@ -165,8 +163,7 @@ * Creates a fix command that removes the specified range of text from the source.

*/
RuleFixer.prototype.removeRange = function (range) {
removeRange(range) {
return this.replaceTextRange(range, "");
};
return RuleFixer;
}());
}
}
exports.default = RuleFixer;
//# sourceMappingURL=rule-fixer.js.map

@@ -26,6 +26,6 @@ // LICENSE : MIT

Object.defineProperty(exports, "__esModule", { value: true });
var assert = __importStar(require("assert"));
var linter_task_1 = __importDefault(require("../task/linter-task"));
var task_runner_1 = __importDefault(require("../task/task-runner"));
var LinterProcessor = /** @class */ (function () {
const assert = __importStar(require("assert"));
const linter_task_1 = __importDefault(require("../task/linter-task"));
const task_runner_1 = __importDefault(require("../task/task-runner"));
class LinterProcessor {
/**

@@ -35,3 +35,3 @@ * @param {Processor} processor

*/
function LinterProcessor(processor, messageProcessManager) {
constructor(processor, messageProcessManager) {
this.processor = processor;

@@ -43,19 +43,17 @@ this.messageProcessManager = messageProcessManager;

*/
LinterProcessor.prototype.process = function (_a) {
var _this = this;
var config = _a.config, configBaseDir = _a.configBaseDir, ruleDescriptors = _a.ruleDescriptors, filterRuleDescriptors = _a.filterRuleDescriptors, sourceCode = _a.sourceCode;
var _b = this.processor.processor(sourceCode.ext), preProcess = _b.preProcess, postProcess = _b.postProcess;
process({ config, configBaseDir, ruleDescriptors, filterRuleDescriptors, sourceCode }) {
const { preProcess, postProcess } = this.processor.processor(sourceCode.ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", "processor should implement {preProcess, postProcess}");
var task = new linter_task_1.default({
config: config,
const task = new linter_task_1.default({
config,
ruleDescriptors: ruleDescriptors,
filterRuleDescriptors: filterRuleDescriptors,
sourceCode: sourceCode,
configBaseDir: configBaseDir
sourceCode,
configBaseDir
});
return task_runner_1.default.process(task).then(function (messages) {
var result = postProcess(messages, sourceCode.filePath);
result.messages = _this.messageProcessManager.process(result.messages);
return task_runner_1.default.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
result.messages = this.messageProcessManager.process(result.messages);
if (result.filePath == null) {
result.filePath = "<Unkown" + sourceCode.ext + ">";
result.filePath = `<Unkown${sourceCode.ext}>`;
}

@@ -65,6 +63,5 @@ assert.ok(result.filePath && result.messages.length >= 0, "postProcess should return { messages, filePath } ");

});
};
return LinterProcessor;
}());
}
}
exports.default = LinterProcessor;
//# sourceMappingURL=linter-processor.js.map

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

*/
var isEqualMessage = function (aMessage, bMessage) {
const isEqualMessage = (aMessage, bMessage) => {
return (aMessage.index === bMessage.index &&

@@ -19,7 +19,6 @@ aMessage.severity === bMessage.severity &&

*/
function filterDuplicatedMessages(messages) {
if (messages === void 0) { messages = []; }
return messages.filter(function (message, index) {
var restMessages = messages.slice(index + 1);
return !restMessages.some(function (restMessage) {
function filterDuplicatedMessages(messages = []) {
return messages.filter((message, index) => {
const restMessages = messages.slice(index + 1);
return !restMessages.some((restMessage) => {
return isEqualMessage(message, restMessage);

@@ -26,0 +25,0 @@ });

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

Object.defineProperty(exports, "__esModule", { value: true });
var MessageType_1 = __importDefault(require("../shared/type/MessageType"));
const MessageType_1 = __importDefault(require("../shared/type/MessageType"));
/**

@@ -15,4 +15,4 @@ * the `index` is in the `range` and return true.

*/
var isContainedRange = function (index, range) {
var start = range[0], end = range[1];
const isContainedRange = (index, range) => {
const [start, end] = range;
return start <= index && index <= end;

@@ -25,14 +25,13 @@ };

*/
function filterMessages(messages) {
if (messages === void 0) { messages = []; }
var lintingMessages = messages.filter(function (message) {
function filterMessages(messages = []) {
const lintingMessages = messages.filter((message) => {
return message.type === MessageType_1.default.lint;
});
var ignoreMessages = messages.filter(function (message) {
const ignoreMessages = messages.filter((message) => {
return message.type === MessageType_1.default.ignore;
});
// if match, reject the message
return lintingMessages.filter(function (message) {
return !ignoreMessages.some(function (ignoreMessage) {
var isInIgnoringRange = isContainedRange(message.index, ignoreMessage.range);
return lintingMessages.filter((message) => {
return !ignoreMessages.some((ignoreMessage) => {
const isInIgnoringRange = isContainedRange(message.index, ignoreMessage.range);
if (isInIgnoringRange && ignoreMessage.ignoringRuleId) {

@@ -39,0 +38,0 @@ // "*" is wildcard that match any rule

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

exports.through = exports.filterWarningMessages = void 0;
var TextlintRuleSeverityLevelKeys_1 = require("../context/TextlintRuleSeverityLevelKeys");
const TextlintRuleSeverityLevelKeys_1 = require("../context/TextlintRuleSeverityLevelKeys");
/**

@@ -12,5 +12,4 @@ * Filter messages by their severity.

*/
function filterWarningMessages(messages) {
if (messages === void 0) { messages = []; }
return messages.filter(function (message) {
function filterWarningMessages(messages = []) {
return messages.filter((message) => {
return message.severity === TextlintRuleSeverityLevelKeys_1.TextlintRuleSeverityLevelKeys.error;

@@ -25,4 +24,3 @@ });

*/
function through(messages) {
if (messages === void 0) { messages = []; }
function through(messages = []) {
return messages;

@@ -29,0 +27,0 @@ }

// LICENSE : MIT
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MessageProcessManager = /** @class */ (function () {
class MessageProcessManager {
/**
* Preprossor
*/
function MessageProcessManager(preProcessors) {
constructor(preProcessors) {
this._preProcessors = preProcessors || [];
this._processors = [];
}
MessageProcessManager.prototype.add = function (messageProcessor) {
add(messageProcessor) {
this._processors.push(messageProcessor);
};
MessageProcessManager.prototype.remove = function (process) {
var index = this._processors.indexOf(process);
}
remove(process) {
const index = this._processors.indexOf(process);
if (index !== -1) {
this._processors.splice(index, 1);
}
};
}
/**

@@ -26,8 +26,8 @@ * process `messages` with registered processes

*/
MessageProcessManager.prototype.process = function (messages) {
var originalMessages = messages;
process(messages) {
const originalMessages = messages;
if (this._preProcessors.length === 0) {
throw new Error("pre process should be > 0");
}
var preProcessedMesssages = this._preProcessors.reduce(function (messages, filter) {
const preProcessedMesssages = this._preProcessors.reduce((messages, filter) => {
return filter(messages);

@@ -38,9 +38,8 @@ }, originalMessages);

}
return this._processors.reduce(function (messages, filter) {
return this._processors.reduce((messages, filter) => {
return filter(messages);
}, preProcessedMesssages);
};
return MessageProcessManager;
}());
}
}
exports.default = MessageProcessManager;
//# sourceMappingURL=MessageProcessManager.js.map

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

return messages.sort(function (a, b) {
var lineDiff = a.line - b.line;
const lineDiff = a.line - b.line;
if (lineDiff === 0) {

@@ -15,0 +15,0 @@ return a.column - b.column;

@@ -5,6 +5,9 @@ // LICENSE : MIT

exports.getSeverity = void 0;
var TextlintRuleSeverityLevelKeys_1 = require("../context/TextlintRuleSeverityLevelKeys");
var isSeverityLevelValue = function (type) {
const TextlintRuleSeverityLevelKeys_1 = require("../context/TextlintRuleSeverityLevelKeys");
const isSeverityLevelValue = (type) => {
if (type === undefined) {
throw new Error("Please set following value to severity:\n\"rule-key\": {\n \"severity\": \"<warning|error>\"\n}");
throw new Error(`Please set following value to severity:
"rule-key": {
"severity": "<warning|error>"
}`);
}

@@ -27,5 +30,8 @@ return true;

if (ruleConfig.severity) {
var severityValue = TextlintRuleSeverityLevelKeys_1.TextlintRuleSeverityLevelKeys[ruleConfig.severity];
const severityValue = TextlintRuleSeverityLevelKeys_1.TextlintRuleSeverityLevelKeys[ruleConfig.severity];
if (!isSeverityLevelValue(severityValue)) {
throw new Error("Please set following value to severity:\n\"rule-key\": {\n \"severity\": \"<warning|error>\"\n}");
throw new Error(`Please set following value to severity:
"rule-key": {
"severity": "<warning|error>"
}`);
}

@@ -32,0 +38,0 @@ return severityValue;

// LICENSE : MIT
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -22,37 +7,33 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var textlint_core_task_1 = __importDefault(require("./textlint-core-task"));
var rule_severity_1 = require("../shared/rule-severity");
var TextlintFilterRuleContextImpl_1 = require("../context/TextlintFilterRuleContextImpl");
var TextlintRuleContextImpl_1 = require("../context/TextlintRuleContextImpl");
var debug_1 = __importDefault(require("debug"));
var debug = debug_1.default("textlint:TextLintCoreTask");
var TextLintCoreTask = /** @class */ (function (_super) {
__extends(TextLintCoreTask, _super);
function TextLintCoreTask(_a) {
var config = _a.config, configBaseDir = _a.configBaseDir, fixableRuleDescriptor = _a.fixableRuleDescriptor, filterRuleDescriptors = _a.filterRuleDescriptors, sourceCode = _a.sourceCode;
var _this = _super.call(this) || this;
_this.config = config;
_this.configBaseDir = configBaseDir;
_this.fixableRuleDescriptor = fixableRuleDescriptor;
_this.filterRuleDescriptors = filterRuleDescriptors;
_this.sourceCode = sourceCode;
_this._setupRules();
return _this;
const textlint_core_task_1 = __importDefault(require("./textlint-core-task"));
const rule_severity_1 = require("../shared/rule-severity");
const TextlintFilterRuleContextImpl_1 = require("../context/TextlintFilterRuleContextImpl");
const TextlintRuleContextImpl_1 = require("../context/TextlintRuleContextImpl");
const debug_1 = __importDefault(require("debug"));
const debug = debug_1.default("textlint:TextLintCoreTask");
class TextLintCoreTask extends textlint_core_task_1.default {
constructor({ config, configBaseDir, fixableRuleDescriptor, filterRuleDescriptors, sourceCode }) {
super();
this.config = config;
this.configBaseDir = configBaseDir;
this.fixableRuleDescriptor = fixableRuleDescriptor;
this.filterRuleDescriptors = filterRuleDescriptors;
this.sourceCode = sourceCode;
this._setupRules();
}
TextLintCoreTask.prototype.start = function () {
start() {
this.startTraverser(this.sourceCode);
};
TextLintCoreTask.prototype._setupRules = function () {
var _this = this;
}
_setupRules() {
// rule
var sourceCode = this.sourceCode;
var report = this.createReporter(sourceCode);
var ignoreReport = this.createShouldIgnore();
const sourceCode = this.sourceCode;
const report = this.createReporter(sourceCode);
const ignoreReport = this.createShouldIgnore();
// setup "rules" field by using a single fixerRule
debug("fixerRule", this.fixableRuleDescriptor);
var ruleContext = new TextlintRuleContextImpl_1.TextlintRuleContextImpl({
const ruleContext = new TextlintRuleContextImpl_1.TextlintRuleContextImpl({
ruleId: this.fixableRuleDescriptor.id,
severityLevel: rule_severity_1.getSeverity(this.fixableRuleDescriptor.normalizedOptions),
sourceCode: sourceCode,
report: report,
sourceCode,
report,
configBaseDir: this.configBaseDir

@@ -63,16 +44,15 @@ });

debug("filterRules", this.filterRuleDescriptors);
this.filterRuleDescriptors.descriptors.forEach(function (filterRuleDescriptor) {
var ruleContext = new TextlintFilterRuleContextImpl_1.TextlintFilterRuleContextImpl({
this.filterRuleDescriptors.descriptors.forEach((filterRuleDescriptor) => {
const ruleContext = new TextlintFilterRuleContextImpl_1.TextlintFilterRuleContextImpl({
ruleId: filterRuleDescriptor.id,
severityLevel: rule_severity_1.getSeverity(filterRuleDescriptor.normalizedOptions),
sourceCode: sourceCode,
ignoreReport: ignoreReport,
configBaseDir: _this.configBaseDir
sourceCode,
ignoreReport,
configBaseDir: this.configBaseDir
});
_this.tryToAddListenRule(filterRuleDescriptor.filter, ruleContext, filterRuleDescriptor.normalizedOptions);
this.tryToAddListenRule(filterRuleDescriptor.filter, ruleContext, filterRuleDescriptor.normalizedOptions);
});
};
return TextLintCoreTask;
}(textlint_core_task_1.default));
}
}
exports.default = TextLintCoreTask;
//# sourceMappingURL=fixer-task.js.map
// LICENSE : MIT
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -22,57 +7,52 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var textlint_core_task_1 = __importDefault(require("./textlint-core-task"));
var rule_severity_1 = require("../shared/rule-severity");
var TextlintRuleContextImpl_1 = require("../context/TextlintRuleContextImpl");
var TextlintFilterRuleContextImpl_1 = require("../context/TextlintFilterRuleContextImpl");
var TextLintCoreTask = /** @class */ (function (_super) {
__extends(TextLintCoreTask, _super);
function TextLintCoreTask(_a) {
var config = _a.config, configBaseDir = _a.configBaseDir, ruleDescriptors = _a.ruleDescriptors, filterRuleDescriptors = _a.filterRuleDescriptors, sourceCode = _a.sourceCode;
var _this = _super.call(this) || this;
_this.config = config;
_this.configBaseDir = configBaseDir;
_this.ruleDescriptors = ruleDescriptors;
_this.filterRuleDescriptors = filterRuleDescriptors;
_this.sourceCode = sourceCode;
_this._setupRules();
return _this;
const textlint_core_task_1 = __importDefault(require("./textlint-core-task"));
const rule_severity_1 = require("../shared/rule-severity");
const TextlintRuleContextImpl_1 = require("../context/TextlintRuleContextImpl");
const TextlintFilterRuleContextImpl_1 = require("../context/TextlintFilterRuleContextImpl");
class TextLintCoreTask extends textlint_core_task_1.default {
constructor({ config, configBaseDir, ruleDescriptors, filterRuleDescriptors: filterRuleDescriptors, sourceCode }) {
super();
this.config = config;
this.configBaseDir = configBaseDir;
this.ruleDescriptors = ruleDescriptors;
this.filterRuleDescriptors = filterRuleDescriptors;
this.sourceCode = sourceCode;
this._setupRules();
}
TextLintCoreTask.prototype.start = function () {
start() {
this.startTraverser(this.sourceCode);
};
TextLintCoreTask.prototype._setupRules = function () {
var _this = this;
}
_setupRules() {
// rule
var sourceCode = this.sourceCode;
var report = this.createReporter(sourceCode);
var ignoreReport = this.createShouldIgnore();
const sourceCode = this.sourceCode;
const report = this.createReporter(sourceCode);
const ignoreReport = this.createShouldIgnore();
// setup "rules" field
// filter duplicated rules for improving experience
// see https://github.com/textlint/textlint/issues/219
this.ruleDescriptors.lintableDescriptors.forEach(function (ruleDescriptor) {
var ruleOptions = ruleDescriptor.normalizedOptions;
var ruleContext = new TextlintRuleContextImpl_1.TextlintRuleContextImpl({
this.ruleDescriptors.lintableDescriptors.forEach((ruleDescriptor) => {
const ruleOptions = ruleDescriptor.normalizedOptions;
const ruleContext = new TextlintRuleContextImpl_1.TextlintRuleContextImpl({
ruleId: ruleDescriptor.id,
severityLevel: rule_severity_1.getSeverity(ruleOptions),
sourceCode: sourceCode,
report: report,
configBaseDir: _this.configBaseDir
sourceCode,
report,
configBaseDir: this.configBaseDir
});
_this.tryToAddListenRule(ruleDescriptor.linter, ruleContext, ruleOptions);
this.tryToAddListenRule(ruleDescriptor.linter, ruleContext, ruleOptions);
});
// setup "filters" field
this.filterRuleDescriptors.descriptors.forEach(function (filterDescriptor) {
var ruleContext = new TextlintFilterRuleContextImpl_1.TextlintFilterRuleContextImpl({
this.filterRuleDescriptors.descriptors.forEach((filterDescriptor) => {
const ruleContext = new TextlintFilterRuleContextImpl_1.TextlintFilterRuleContextImpl({
ruleId: filterDescriptor.id,
sourceCode: sourceCode,
ignoreReport: ignoreReport,
configBaseDir: _this.configBaseDir,
sourceCode,
ignoreReport,
configBaseDir: this.configBaseDir,
severityLevel: rule_severity_1.getSeverity(filterDescriptor.normalizedOptions)
});
_this.tryToAddListenRule(filterDescriptor.filter, ruleContext, filterDescriptor.normalizedOptions);
this.tryToAddListenRule(filterDescriptor.filter, ruleContext, filterDescriptor.normalizedOptions);
});
};
return TextLintCoreTask;
}(textlint_core_task_1.default));
}
}
exports.default = TextLintCoreTask;
//# sourceMappingURL=linter-task.js.map

@@ -7,28 +7,23 @@ // MIT © 2017 azu

exports.PromiseEventEmitter = void 0;
var events_1 = require("events");
var PromiseEventEmitter = /** @class */ (function () {
function PromiseEventEmitter() {
const events_1 = require("events");
class PromiseEventEmitter {
constructor() {
this.events = new events_1.EventEmitter();
this.events.setMaxListeners(0);
}
PromiseEventEmitter.prototype.listenerCount = function (type) {
listenerCount(type) {
return this.events.listenerCount(type);
};
PromiseEventEmitter.prototype.on = function (event, listener) {
}
on(event, listener) {
return this.events.on(event, listener);
};
PromiseEventEmitter.prototype.emit = function (event) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var promises = [];
this.events.listeners(event).forEach(function (listener) {
promises.push(listener.apply(void 0, args));
}
emit(event, ...args) {
const promises = [];
this.events.listeners(event).forEach((listener) => {
promises.push(listener(...args));
});
return Promise.all(promises);
};
return PromiseEventEmitter;
}());
}
}
exports.PromiseEventEmitter = PromiseEventEmitter;
//# sourceMappingURL=promise-event-emitter.js.map

@@ -7,6 +7,4 @@ // LICENSE : MIT

Object.defineProperty(exports, "__esModule", { value: true });
var textlint_core_task_1 = __importDefault(require("./textlint-core-task"));
var TaskRunner = /** @class */ (function () {
function TaskRunner() {
}
const textlint_core_task_1 = __importDefault(require("./textlint-core-task"));
class TaskRunner {
/**

@@ -17,12 +15,12 @@ * Task and return promise

*/
TaskRunner.process = function (task) {
return new Promise(function (resolve, reject) {
var messages = [];
task.on(textlint_core_task_1.default.events.message, function (message) {
static process(task) {
return new Promise((resolve, reject) => {
const messages = [];
task.on(textlint_core_task_1.default.events.message, (message) => {
messages.push(message);
});
task.on(textlint_core_task_1.default.events.error, function (error) {
task.on(textlint_core_task_1.default.events.error, (error) => {
reject(error);
});
task.on(textlint_core_task_1.default.events.complete, function () {
task.on(textlint_core_task_1.default.events.complete, () => {
task.removeAllListeners();

@@ -33,6 +31,5 @@ resolve(messages);

});
};
return TaskRunner;
}());
}
}
exports.default = TaskRunner;
//# sourceMappingURL=task-runner.js.map
// LICENSE : MIT
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

@@ -41,22 +26,17 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var TextlintRuleErrorImpl_1 = require("../context/TextlintRuleErrorImpl");
var promise_event_emitter_1 = require("./promise-event-emitter");
var source_location_1 = __importDefault(require("../core/source-location"));
var timing_1 = __importDefault(require("../util/timing"));
var MessageType_1 = __importDefault(require("../shared/type/MessageType"));
var events_1 = require("events");
var assert = __importStar(require("assert"));
var utils_1 = require("@textlint/utils");
var TextlintRuleContextImpl_1 = require("../context/TextlintRuleContextImpl");
var debug_1 = __importDefault(require("debug"));
var ast_traverse_1 = require("@textlint/ast-traverse");
var traverseController = new ast_traverse_1.Controller();
var debug = debug_1.default("textlint:core-task");
var RuleTypeEmitter = /** @class */ (function (_super) {
__extends(RuleTypeEmitter, _super);
function RuleTypeEmitter() {
return _super !== null && _super.apply(this, arguments) || this;
}
return RuleTypeEmitter;
}(promise_event_emitter_1.PromiseEventEmitter));
const TextlintRuleErrorImpl_1 = require("../context/TextlintRuleErrorImpl");
const promise_event_emitter_1 = require("./promise-event-emitter");
const source_location_1 = __importDefault(require("../core/source-location"));
const timing_1 = __importDefault(require("../util/timing"));
const MessageType_1 = __importDefault(require("../shared/type/MessageType"));
const events_1 = require("events");
const assert = __importStar(require("assert"));
const utils_1 = require("@textlint/utils");
const TextlintRuleContextImpl_1 = require("../context/TextlintRuleContextImpl");
const debug_1 = __importDefault(require("debug"));
const ast_traverse_1 = require("@textlint/ast-traverse");
const traverseController = new ast_traverse_1.Controller();
const debug = debug_1.default("textlint:core-task");
class RuleTypeEmitter extends promise_event_emitter_1.PromiseEventEmitter {
}
/**

@@ -66,33 +46,26 @@ * CoreTask receive AST and prepare, traverse AST, emit nodeType event!

*/
var TextLintCoreTask = /** @class */ (function (_super) {
__extends(TextLintCoreTask, _super);
function TextLintCoreTask() {
var _this = _super.call(this) || this;
_this.ruleTypeEmitter = new RuleTypeEmitter();
return _this;
class TextLintCoreTask extends events_1.EventEmitter {
constructor() {
super();
this.ruleTypeEmitter = new RuleTypeEmitter();
}
Object.defineProperty(TextLintCoreTask, "events", {
get: function () {
return {
// receive start event
start: "start",
// receive message from each rules
message: "message",
// receive complete event
complete: "complete",
// receive error event
error: "error"
};
},
enumerable: false,
configurable: true
});
TextLintCoreTask.prototype.createShouldIgnore = function () {
var _this = this;
var shouldIgnore = function (args) {
var ruleId = args.ruleId, range = args.range, optional = args.optional;
static get events() {
return {
// receive start event
start: "start",
// receive message from each rules
message: "message",
// receive complete event
complete: "complete",
// receive error event
error: "error"
};
}
createShouldIgnore() {
const shouldIgnore = (args) => {
const { ruleId, range, optional } = args;
assert.ok(typeof range[0] !== "undefined" && typeof range[1] !== "undefined" && range[0] >= 0 && range[1] >= 0, "ignoreRange should have actual range: " + range);
// FIXME: should have index, loc
// should be compatible with LintReportedMessage?
var message = {
const message = {
type: MessageType_1.default.ignore,

@@ -105,9 +78,8 @@ ruleId: ruleId,

};
_this.emit(TextLintCoreTask.events.message, message);
this.emit(TextLintCoreTask.events.message, message);
};
return shouldIgnore;
};
TextLintCoreTask.prototype.createReporter = function (sourceCode) {
var _this = this;
var sourceLocation = new source_location_1.default(sourceCode);
}
createReporter(sourceCode) {
const sourceLocation = new source_location_1.default(sourceCode);
/**

@@ -117,13 +89,13 @@ * push new RuleError to results

*/
var reportFunction = function (reportArgs) {
var ruleId = reportArgs.ruleId, severity = reportArgs.severity, ruleError = reportArgs.ruleError;
const reportFunction = (reportArgs) => {
const { ruleId, severity, ruleError } = reportArgs;
debug("%s pushReport %s", ruleId, ruleError);
var _a = sourceLocation.adjust(reportArgs), line = _a.line, column = _a.column, fix = _a.fix;
var index = sourceCode.positionToIndex({ line: line, column: column });
const { line, column, fix } = sourceLocation.adjust(reportArgs);
const index = sourceCode.positionToIndex({ line, column });
// add TextLintMessage
var message = {
const message = {
type: MessageType_1.default.lint,
ruleId: ruleId,
message: ruleError.message,
index: index,
index,
// See https://github.com/textlint/textlint/blob/master/typing/textlint.d.ts

@@ -138,9 +110,9 @@ line: line,

// `error` is a any data.
var data = ruleError;
const data = ruleError;
message.data = data;
}
_this.emit(TextLintCoreTask.events.message, message);
this.emit(TextLintCoreTask.events.message, message);
};
return reportFunction;
};
}
/**

@@ -151,20 +123,19 @@ * start process and emitting events.

*/
TextLintCoreTask.prototype.startTraverser = function (sourceCode) {
var _this = this;
startTraverser(sourceCode) {
this.emit(TextLintCoreTask.events.start);
var promiseQueue = [];
var ruleTypeEmitter = this.ruleTypeEmitter;
const promiseQueue = [];
const ruleTypeEmitter = this.ruleTypeEmitter;
traverseController.traverse(sourceCode.ast, {
enter: function (node, parent) {
var type = node.type;
enter(node, parent) {
const type = node.type;
Object.defineProperty(node, "parent", { value: parent });
if (ruleTypeEmitter.listenerCount(type) > 0) {
var promise = ruleTypeEmitter.emit(type, node);
const promise = ruleTypeEmitter.emit(type, node);
promiseQueue.push(promise);
}
},
leave: function (node) {
var type = node.type + ":exit";
leave(node) {
const type = `${node.type}:exit`;
if (ruleTypeEmitter.listenerCount(type) > 0) {
var promise = ruleTypeEmitter.emit(type, node);
const promise = ruleTypeEmitter.emit(type, node);
promiseQueue.push(promise);

@@ -175,13 +146,13 @@ }

Promise.all(promiseQueue)
.then(function () {
_this.emit(TextLintCoreTask.events.complete);
.then(() => {
this.emit(TextLintCoreTask.events.complete);
})
.catch(function (error) {
_this.emit(TextLintCoreTask.events.error, error);
.catch((error) => {
this.emit(TextLintCoreTask.events.error, error);
});
};
}
/**
* try to get rule object
*/
TextLintCoreTask.prototype.tryToGetRuleObject = function (ruleCreator, ruleContext, ruleOptions) {
tryToGetRuleObject(ruleCreator, ruleContext, ruleOptions) {
try {

@@ -191,10 +162,10 @@ return ruleCreator(ruleContext, ruleOptions);

catch (error) {
error.message = "Error while loading rule '" + ruleContext.id + "': " + error.message;
error.message = `Error while loading rule '${ruleContext.id}': ${error.message}`;
throw error;
}
};
}
/**
* try to get filter rule object
*/
TextLintCoreTask.prototype.tryToGetFilterRuleObject = function (ruleCreator, ruleContext, ruleOptions) {
tryToGetFilterRuleObject(ruleCreator, ruleContext, ruleOptions) {
try {

@@ -204,6 +175,6 @@ return ruleCreator(ruleContext, ruleOptions);

catch (error) {
error.message = "Error while loading filter rule '" + ruleContext.id + "': " + error.message;
error.message = `Error while loading filter rule '${ruleContext.id}': ${error.message}`;
throw error;
}
};
}
/**

@@ -216,15 +187,13 @@ * add all the node types as listeners of the rule

*/
TextLintCoreTask.prototype.tryToAddListenRule = function (ruleCreator, ruleContext, ruleOptions) {
var _this = this;
var ruleObject = ruleContext instanceof TextlintRuleContextImpl_1.TextlintRuleContextImpl
tryToAddListenRule(ruleCreator, ruleContext, ruleOptions) {
const ruleObject = ruleContext instanceof TextlintRuleContextImpl_1.TextlintRuleContextImpl
? this.tryToGetRuleObject(ruleCreator, ruleContext, ruleOptions)
: this.tryToGetFilterRuleObject(ruleCreator, ruleContext, ruleOptions);
var types = Object.keys(ruleObject);
types.forEach(function (nodeType) {
_this.ruleTypeEmitter.on(nodeType, timing_1.default.enabled ? timing_1.default.time(ruleContext.id, ruleObject[nodeType]) : ruleObject[nodeType]);
const types = Object.keys(ruleObject);
types.forEach((nodeType) => {
this.ruleTypeEmitter.on(nodeType, timing_1.default.enabled ? timing_1.default.time(ruleContext.id, ruleObject[nodeType]) : ruleObject[nodeType]);
});
};
return TextLintCoreTask;
}(events_1.EventEmitter));
}
}
exports.default = TextLintCoreTask;
//# sourceMappingURL=textlint-core-task.js.map

@@ -27,18 +27,18 @@ "use strict";

// MIT © 2017- azu
var assert = __importStar(require("assert"));
const assert = __importStar(require("assert"));
// sequence
var fixer_processor_1 = __importDefault(require("./fixer/fixer-processor"));
const fixer_processor_1 = __importDefault(require("./fixer/fixer-processor"));
// parallel
var linter_processor_1 = __importDefault(require("./linter/linter-processor"));
const linter_processor_1 = __importDefault(require("./linter/linter-processor"));
// message process manager
var MessageProcessManager_1 = __importDefault(require("./messages/MessageProcessManager"));
var filter_ignored_process_1 = __importDefault(require("./messages/filter-ignored-process"));
var filter_duplicated_process_1 = __importDefault(require("./messages/filter-duplicated-process"));
var filter_severity_process_1 = __importDefault(require("./messages/filter-severity-process"));
var sort_messages_process_1 = __importDefault(require("./messages/sort-messages-process"));
var descriptor_1 = require("./descriptor");
var TextlintSourceCodeImpl_1 = require("./context/TextlintSourceCodeImpl");
var ast_tester_1 = require("@textlint/ast-tester");
var debug_1 = __importDefault(require("debug"));
var debug = debug_1.default("textlint:kernel");
const MessageProcessManager_1 = __importDefault(require("./messages/MessageProcessManager"));
const filter_ignored_process_1 = __importDefault(require("./messages/filter-ignored-process"));
const filter_duplicated_process_1 = __importDefault(require("./messages/filter-duplicated-process"));
const filter_severity_process_1 = __importDefault(require("./messages/filter-severity-process"));
const sort_messages_process_1 = __importDefault(require("./messages/sort-messages-process"));
const descriptor_1 = require("./descriptor");
const TextlintSourceCodeImpl_1 = require("./context/TextlintSourceCodeImpl");
const ast_tester_1 = require("@textlint/ast-tester");
const debug_1 = __importDefault(require("debug"));
const debug = debug_1.default("textlint:kernel");
/**

@@ -54,3 +54,4 @@ * add fileName to trailing of error message

}
return message + "\nat " + fileName;
return `${message}
at ${fileName}`;
}

@@ -69,8 +70,7 @@ /**

*/
var TextlintKernel = /** @class */ (function () {
class TextlintKernel {
/**
* @param config
*/
function TextlintKernel(config) {
if (config === void 0) { config = {}; }
constructor(config = {}) {
// this.config often is undefined.

@@ -95,6 +95,5 @@ this.config = config;

*/
TextlintKernel.prototype.lintText = function (text, options) {
var _this = this;
return Promise.resolve().then(function () {
var descriptor = new descriptor_1.TextlintKernelDescriptor({
lintText(text, options) {
return Promise.resolve().then(() => {
const descriptor = new descriptor_1.TextlintKernelDescriptor({
rules: options.rules || [],

@@ -104,9 +103,9 @@ filterRules: options.filterRules || [],

});
return _this._parallelProcess({
descriptor: descriptor,
text: text,
options: options
return this._parallelProcess({
descriptor,
text,
options
});
});
};
}
/**

@@ -118,6 +117,5 @@ * fix texts and return fix result object

*/
TextlintKernel.prototype.fixText = function (text, options) {
var _this = this;
return Promise.resolve().then(function () {
var descriptor = new descriptor_1.TextlintKernelDescriptor({
fixText(text, options) {
return Promise.resolve().then(() => {
const descriptor = new descriptor_1.TextlintKernelDescriptor({
rules: options.rules || [],

@@ -127,9 +125,9 @@ filterRules: options.filterRules || [],

});
return _this._sequenceProcess({
descriptor: descriptor,
options: options,
text: text
return this._sequenceProcess({
descriptor,
options,
text
});
});
};
}
/**

@@ -144,25 +142,24 @@ * process text in parallel for Rules and return {Promise.<TextLintResult>}

*/
TextlintKernel.prototype._parallelProcess = function (_a) {
var descriptor = _a.descriptor, text = _a.text, options = _a.options;
var ext = options.ext, filePath = options.filePath, configBaseDir = options.configBaseDir;
var plugin = descriptor.findPluginDescriptorWithExt(ext);
_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);
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
var processor = plugin.processor;
var _b = processor.processor(ext), preProcess = _b.preProcess, postProcess = _b.postProcess;
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", "processor should implements {preProcess, postProcess}");
var preProcessResult = preProcess(text, filePath);
var isPluginReturnAnAST = ast_tester_1.isTxtAST(preProcessResult);
var textForAST = isPluginReturnAnAST ? text : preProcessResult.text;
var ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
var sourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
const preProcessResult = preProcess(text, filePath);
const isPluginReturnAnAST = ast_tester_1.isTxtAST(preProcessResult);
const textForAST = isPluginReturnAnAST ? text : preProcessResult.text;
const ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
const sourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
text: textForAST,
ast: ast,
ext: ext,
filePath: filePath
ast,
ext,
filePath
});
var linterProcessor = new linter_processor_1.default(processor, this.messageProcessManager);
const linterProcessor = new linter_processor_1.default(processor, this.messageProcessManager);
return linterProcessor

@@ -173,10 +170,10 @@ .process({

filterRuleDescriptors: descriptor.filterRule,
sourceCode: sourceCode,
configBaseDir: configBaseDir
sourceCode,
configBaseDir
})
.catch(function (error) {
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
};
}
/**

@@ -191,25 +188,24 @@ * process text in series for Rules and return {Promise.<TextlintFixResult>}

*/
TextlintKernel.prototype._sequenceProcess = function (_a) {
var descriptor = _a.descriptor, text = _a.text, options = _a.options;
var ext = options.ext, filePath = options.filePath, configBaseDir = options.configBaseDir;
var plugin = descriptor.findPluginDescriptorWithExt(ext);
_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);
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
var processor = plugin.processor;
var _b = processor.processor(ext), preProcess = _b.preProcess, postProcess = _b.postProcess;
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", "processor should implements {preProcess, postProcess}");
var preProcessResult = preProcess(text, filePath);
var isPluginReturnAnAST = ast_tester_1.isTxtAST(preProcessResult);
var textForAST = isPluginReturnAnAST ? text : preProcessResult.text;
var ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
var sourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
const preProcessResult = preProcess(text, filePath);
const isPluginReturnAnAST = ast_tester_1.isTxtAST(preProcessResult);
const textForAST = isPluginReturnAnAST ? text : preProcessResult.text;
const ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
const sourceCode = new TextlintSourceCodeImpl_1.TextlintSourceCodeImpl({
text: textForAST,
ast: ast,
ext: ext,
filePath: filePath
ast,
ext,
filePath
});
var fixerProcessor = new fixer_processor_1.default(processor, this.messageProcessManager);
const fixerProcessor = new fixer_processor_1.default(processor, this.messageProcessManager);
return fixerProcessor

@@ -220,13 +216,12 @@ .process({

filterRules: descriptor.filterRule,
sourceCode: sourceCode,
configBaseDir: configBaseDir
sourceCode,
configBaseDir
})
.catch(function (error) {
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
};
return TextlintKernel;
}());
}
}
exports.TextlintKernel = TextlintKernel;
//# sourceMappingURL=textlint-kernel.js.map

@@ -10,29 +10,14 @@ // LICENSE : MIT

*/
var Logger = /** @class */ (function () {
function Logger() {
class Logger {
static log(...message) {
console.log(...message);
}
Logger.log = function () {
var message = [];
for (var _i = 0; _i < arguments.length; _i++) {
message[_i] = arguments[_i];
}
console.log.apply(console, message);
};
Logger.warn = function () {
var message = [];
for (var _i = 0; _i < arguments.length; _i++) {
message[_i] = arguments[_i];
}
console.warn.apply(console, message);
};
Logger.error = function () {
var message = [];
for (var _i = 0; _i < arguments.length; _i++) {
message[_i] = arguments[_i];
}
console.error.apply(console, message);
};
return Logger;
}());
static warn(...message) {
console.warn(...message);
}
static error(...message) {
console.error(...message);
}
}
exports.default = Logger;
//# sourceMappingURL=logger.js.map

@@ -11,3 +11,3 @@ /**

Object.defineProperty(exports, "__esModule", { value: true });
var logger_1 = __importDefault(require("./logger"));
const logger_1 = __importDefault(require("./logger"));
/* istanbul ignore next */

@@ -37,5 +37,5 @@ /**

}
var enabled = Boolean(process.env.TIMING);
var HEADERS = ["Rule", "Time (ms)", "Relative"];
var ALIGN = [alignLeft, alignRight, alignRight];
const enabled = Boolean(process.env.TIMING);
const HEADERS = ["Rule", "Time (ms)", "Relative"];
const ALIGN = [alignLeft, alignRight, alignRight];
/* istanbul ignore next */

@@ -49,6 +49,6 @@ /**

function display(data) {
var total = 0;
var rows = Object.keys(data)
let total = 0;
const rows = Object.keys(data)
.map(function (key) {
var time = data[key];
const time = data[key];
total += time;

@@ -66,6 +66,6 @@ return [key, time];

rows.unshift(HEADERS);
var widths = [];
const widths = [];
rows.forEach(function (row) {
for (var i = 0; i < row.length; i++) {
var n = row[i].length;
for (let i = 0; i < row.length; i++) {
const n = row[i].length;
if (!widths[i] || n > widths[i]) {

@@ -76,3 +76,3 @@ widths[i] = n;

});
var table = rows.map(function (row) {
const table = rows.map(function (row) {
return row

@@ -96,3 +96,3 @@ .map(function (cell, index) {

exports.default = (function () {
var data = Object.create(null);
const data = Object.create(null);
/**

@@ -110,3 +110,3 @@ * Time the run

return function () {
var t = process.hrtime();
let t = process.hrtime();
fn.apply(null, Array.prototype.slice.call(arguments));

@@ -113,0 +113,0 @@ t = process.hrtime(t);

import * as assert from "assert";
import { TextlintRuleErrorImpl } from "./TextlintRuleErrorImpl";
var TextlintFilterRuleContextImpl = /** @class */ (function () {
function TextlintFilterRuleContextImpl(args) {
var _this = this;
this.shouldIgnore = function (range, optional) {
if (optional === void 0) { optional = {}; }
export class TextlintFilterRuleContextImpl {
constructor(args) {
this.shouldIgnore = (range, optional = {}) => {
assert.ok(Array.isArray(range) && typeof range[0] === "number" && typeof range[1] === "number", "shouldIgnore([number, number]); accept range.");
_this._ignoreReport({ ruleId: _this._ruleId, range: range, optional: optional });
this._ignoreReport({ ruleId: this._ruleId, range, optional });
};

@@ -14,4 +12,4 @@ /**

*/
this.getFilePath = function () {
return _this._sourceCode.getFilePath();
this.getFilePath = () => {
return this._sourceCode.getFilePath();
};

@@ -25,4 +23,4 @@ /**

*/
this.getSource = function (node, beforeCount, afterCount) {
return _this._sourceCode.getSource(node, beforeCount, afterCount);
this.getSource = (node, beforeCount, afterCount) => {
return this._sourceCode.getSource(node, beforeCount, afterCount);
};

@@ -42,4 +40,4 @@ /**

*/
this.getConfigBaseDir = function () {
return _this._configBaseDir;
this.getConfigBaseDir = () => {
return this._configBaseDir;
};

@@ -53,58 +51,36 @@ this._ruleId = args.ruleId;

}
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "id", {
/**
* Rule id
* @returns {string}
*/
get: function () {
return this._ruleId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "severity", {
get: function () {
return this._severityLevel;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "Syntax", {
/**
* Node's type values
* @type {TextLintNodeType}
*/
get: function () {
return this._sourceCode.getSyntax();
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "RuleError", {
/**
* CustomError object
* @type {RuleError}
*/
get: function () {
return TextlintRuleErrorImpl;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleContextImpl.prototype, "report", {
/**
* Not use
* @returns {() => void}
*/
get: function () {
return function () {
throw new Error("Filter rule can not report");
};
},
enumerable: false,
configurable: true
});
return TextlintFilterRuleContextImpl;
}());
export { TextlintFilterRuleContextImpl };
/**
* Rule id
* @returns {string}
*/
get id() {
return this._ruleId;
}
get severity() {
return this._severityLevel;
}
/**
* Node's type values
* @type {TextLintNodeType}
*/
get Syntax() {
return this._sourceCode.getSyntax();
}
/**
* CustomError object
* @type {RuleError}
*/
get RuleError() {
return TextlintRuleErrorImpl;
}
/**
* Not use
* @returns {() => void}
*/
get report() {
return () => {
throw new Error("Filter rule can not report");
};
}
}
//# sourceMappingURL=TextlintFilterRuleContextImpl.js.map

@@ -13,3 +13,3 @@ import * as assert from "assert";

range: [index, index],
text: text,
text,
isAbsolute: false

@@ -29,3 +29,3 @@ };

range: [index, index],
text: text,
text,
isAbsolute: true

@@ -41,5 +41,3 @@ };

*/
var TextlintRuleContextFixCommandGeneratorImpl = /** @class */ (function () {
function TextlintRuleContextFixCommandGeneratorImpl() {
}
export class TextlintRuleContextFixCommandGeneratorImpl {
/**

@@ -52,5 +50,5 @@ * Creates a fix command that inserts text after the given node or token.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.insertTextAfter = function (node, text) {
insertTextAfter(node, text) {
return insertTextAtAbsolute(node.range[1], text);
};
}
/**

@@ -65,5 +63,5 @@ * Creates a fix command that inserts text after the specified range in the source text.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.insertTextAfterRange = function (range, text) {
insertTextAfterRange(range, text) {
return insertTextAt(range[1], text);
};
}
/**

@@ -76,5 +74,5 @@ * Creates a fix command that inserts text before the given node or token.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.insertTextBefore = function (node, text) {
insertTextBefore(node, text) {
return insertTextAtAbsolute(node.range[0], text);
};
}
/**

@@ -89,5 +87,5 @@ * Creates a fix command that inserts text before the specified range in the source text.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.insertTextBeforeRange = function (range, text) {
insertTextBeforeRange(range, text) {
return insertTextAt(range[0], text);
};
}
/**

@@ -100,9 +98,9 @@ * Creates a fix command that replaces text at the node or token.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.replaceText = function (node, text) {
replaceText(node, text) {
return {
range: node.range,
text: text,
text,
isAbsolute: true
};
};
}
/**

@@ -117,9 +115,9 @@ * Creates a fix command that replaces text at the specified range in the source text.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.replaceTextRange = function (range, text) {
replaceTextRange(range, text) {
return {
range: range,
text: text,
range,
text,
isAbsolute: false
};
};
}
/**

@@ -131,5 +129,5 @@ * Creates a fix command that removes the node or token from the source.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.remove = function (node) {
remove(node) {
return this.replaceText(node, "");
};
}
/**

@@ -143,8 +141,6 @@ * Creates a fix command that removes the specified range of text from the source.

*/
TextlintRuleContextFixCommandGeneratorImpl.prototype.removeRange = function (range) {
removeRange(range) {
return this.replaceTextRange(range, "");
};
return TextlintRuleContextFixCommandGeneratorImpl;
}());
export { TextlintRuleContextFixCommandGeneratorImpl };
}
}
//# sourceMappingURL=TextlintRuleContextFixCommandGeneratorImpl.js.map

@@ -5,10 +5,9 @@ import assert from "assert";

import { TextlintRuleErrorImpl } from "./TextlintRuleErrorImpl";
var ruleFixer = new TextlintRuleContextFixCommandGeneratorImpl();
var TextlintRuleContextImpl = /** @class */ (function () {
function TextlintRuleContextImpl(args) {
var _this = this;
const ruleFixer = new TextlintRuleContextFixCommandGeneratorImpl();
export class TextlintRuleContextImpl {
constructor(args) {
/**
* report function that is called in a rule
*/
this.report = function (node, ruleError, _shouldNotUsed) {
this.report = (node, ruleError, _shouldNotUsed) => {
assert.ok(!(node instanceof TextlintRuleErrorImpl), "1st argument should be node. Usage: `report(node, ruleError);`");

@@ -18,9 +17,9 @@ assert.ok(_shouldNotUsed === undefined, "3rd argument should not be used. Usage: `report(node, ruleError);`");

// severity come from `.textlintrc` option like `{ "<rule-name>" : { serverity: "warning" } } `
_this._report({ ruleId: _this._ruleId, node: node, severity: _this._severityLevel, ruleError: ruleError });
this._report({ ruleId: this._ruleId, node, severity: this._severityLevel, ruleError });
}
else {
var ruleReportedObject = ruleError;
const ruleReportedObject = ruleError;
// severity come from report arguments like `report(node, { severity: 1 })`
var level = ruleReportedObject.severity || TextlintRuleSeverityLevelKeys.error;
_this._report({ ruleId: _this._ruleId, node: node, severity: level, ruleError: ruleReportedObject });
const level = ruleReportedObject.severity || TextlintRuleSeverityLevelKeys.error;
this._report({ ruleId: this._ruleId, node, severity: level, ruleError: ruleReportedObject });
}

@@ -31,4 +30,4 @@ };

*/
this.getFilePath = function () {
return _this._sourceCode.getFilePath();
this.getFilePath = () => {
return this._sourceCode.getFilePath();
};

@@ -42,4 +41,4 @@ /**

*/
this.getSource = function (node, beforeCount, afterCount) {
return _this._sourceCode.getSource(node, beforeCount, afterCount);
this.getSource = (node, beforeCount, afterCount) => {
return this._sourceCode.getSource(node, beforeCount, afterCount);
};

@@ -59,4 +58,4 @@ /**

*/
this.getConfigBaseDir = function () {
return _this._configBaseDir;
this.getConfigBaseDir = () => {
return this._configBaseDir;
};

@@ -70,59 +69,37 @@ this._ruleId = args.ruleId;

}
Object.defineProperty(TextlintRuleContextImpl.prototype, "id", {
/**
* Rule id
* @returns {string}
*/
get: function () {
return this._ruleId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleContextImpl.prototype, "severity", {
/**
* severity level
*/
get: function () {
return this._severityLevel;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleContextImpl.prototype, "Syntax", {
/**
* Node's type values
* @type {ASTNodeTypes}
*/
get: function () {
return this._sourceCode.getSyntax();
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleContextImpl.prototype, "RuleError", {
/**
* CustomError object
* @type {RuleError}
*/
get: function () {
return TextlintRuleErrorImpl;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleContextImpl.prototype, "fixer", {
/**
* Rule fixer command object
* @type {RuleFixer}
*/
get: function () {
return ruleFixer;
},
enumerable: false,
configurable: true
});
return TextlintRuleContextImpl;
}());
export { TextlintRuleContextImpl };
/**
* Rule id
* @returns {string}
*/
get id() {
return this._ruleId;
}
/**
* severity level
*/
get severity() {
return this._severityLevel;
}
/**
* Node's type values
* @type {ASTNodeTypes}
*/
get Syntax() {
return this._sourceCode.getSyntax();
}
/**
* CustomError object
* @type {RuleError}
*/
get RuleError() {
return TextlintRuleErrorImpl;
}
/**
* Rule fixer command object
* @type {RuleFixer}
*/
get fixer() {
return ruleFixer;
}
}
//# sourceMappingURL=TextlintRuleContextImpl.js.map
// LICENSE : MIT
"use strict";
var TextlintRuleErrorImpl = /** @class */ (function () {
export class TextlintRuleErrorImpl {
/**

@@ -11,3 +11,3 @@ * RuleError is like Error object.

*/
function TextlintRuleErrorImpl(message, paddingLocation) {
constructor(message, paddingLocation) {
this.message = message;

@@ -42,3 +42,3 @@ if (typeof paddingLocation === "object") {

}
TextlintRuleErrorImpl.prototype.toString = function () {
toString() {
return JSON.stringify({

@@ -51,6 +51,4 @@ message: this.message,

});
};
return TextlintRuleErrorImpl;
}());
export { TextlintRuleErrorImpl };
}
}
//# sourceMappingURL=TextlintRuleErrorImpl.js.map
/**
* Keys of TextlintRuleSeverityLevel
*/
export var TextlintRuleSeverityLevelKeys = {
export const TextlintRuleSeverityLevelKeys = {
none: 0,

@@ -6,0 +6,0 @@ info: 0,

@@ -22,3 +22,3 @@ import { ASTNodeTypes } from "@textlint/ast-node-types";

*/
var TextlintSourceCodeImpl = /** @class */ (function () {
export class TextlintSourceCodeImpl {
/**

@@ -30,4 +30,3 @@ * @param {string} text

*/
function TextlintSourceCodeImpl(_a) {
var _b = _a.text, text = _b === void 0 ? "" : _b, ast = _a.ast, ext = _a.ext, filePath = _a.filePath;
constructor({ text = "", ast, ext, filePath }) {
validate(ast);

@@ -52,5 +51,5 @@ assert.ok(ext || filePath, "should be set either of fileExt or filePath.");

*/
TextlintSourceCodeImpl.prototype.getSyntax = function () {
getSyntax() {
return ASTNodeTypes;
};
}
/**

@@ -60,5 +59,5 @@ * get filePath

*/
TextlintSourceCodeImpl.prototype.getFilePath = function () {
getFilePath() {
return this.filePath;
};
}
/**

@@ -71,7 +70,7 @@ * Gets the source code for the given node.

*/
TextlintSourceCodeImpl.prototype.getSource = function (node, beforeCount, afterCount) {
var currentText = this.text;
getSource(node, beforeCount, afterCount) {
const currentText = this.text;
if (node) {
var start = Math.max(node.range[0] - (beforeCount || 0), 0);
var end = node.range[1] + (afterCount || 0);
const start = Math.max(node.range[0] - (beforeCount || 0), 0);
const end = node.range[1] + (afterCount || 0);
return currentText.slice(start, end);

@@ -82,3 +81,3 @@ }

}
};
}
// StructuredSource wrapper

@@ -89,5 +88,5 @@ /**

*/
TextlintSourceCodeImpl.prototype.locationToRange = function (loc) {
locationToRange(loc) {
return this._structuredSource.locationToRange(loc);
};
}
/**

@@ -97,5 +96,5 @@ * @param {[ number, number ]} range - pair of indice.

*/
TextlintSourceCodeImpl.prototype.rangeToLocation = function (range) {
rangeToLocation(range) {
return this._structuredSource.rangeToLocation(range);
};
}
/**

@@ -105,5 +104,5 @@ * @param {Position} pos - position indicator.

*/
TextlintSourceCodeImpl.prototype.positionToIndex = function (pos) {
positionToIndex(pos) {
return this._structuredSource.positionToIndex(pos);
};
}
/**

@@ -113,8 +112,6 @@ * @param {number} index - index to the source code.

*/
TextlintSourceCodeImpl.prototype.indexToPosition = function (index) {
indexToPosition(index) {
return this._structuredSource.indexToPosition(index);
};
return TextlintSourceCodeImpl;
}());
export { TextlintSourceCodeImpl };
}
}
//# sourceMappingURL=TextlintSourceCodeImpl.js.map
import assert from "assert";
import { throwIfTesting } from "@textlint/feature-flag";
var SourceLocation = /** @class */ (function () {
function SourceLocation(source) {
export default class SourceLocation {
constructor(source) {
this.source = source;

@@ -10,6 +10,6 @@ }

*/
SourceLocation.prototype.adjust = function (reportArgs) {
var node = reportArgs.node, ruleError = reportArgs.ruleError, ruleId = reportArgs.ruleId;
var errorPrefix = "[" + ruleId + "]" || "";
var padding = ruleError;
adjust(reportArgs) {
const { node, ruleError, ruleId } = reportArgs;
const errorPrefix = `[${ruleId}]` || "";
const padding = ruleError;
/*

@@ -19,6 +19,14 @@ FIXME: It is old and un-document way

*/
var _backwardCompatibleIndexValue;
let _backwardCompatibleIndexValue;
if (typeof padding === "number") {
_backwardCompatibleIndexValue = padding;
throwIfTesting(errorPrefix + " This is un-document way:\nreport(node, new RuleError(\"message\", index);\n\nPlease use { index }: \n\nreport(node, new RuleError(\"message\", {\n index: paddingLineColumn\n});\n");
throwIfTesting(`${errorPrefix} This is un-document way:
report(node, new RuleError("message", index);
Please use { index }:
report(node, new RuleError("message", {
index: paddingLineColumn
});
`);
}

@@ -28,3 +36,16 @@ // when running from textlint-tester, assert

// FIXME: Backward compatible <= textlint.5.5
throwIfTesting(errorPrefix + " Have to use a sets with \"line\" and \"column\".\nSee FAQ: https://github.com/textlint/textlint/blob/master/docs/faq/line-column-or-index.md \n\nreport(node, new RuleError(\"message\", {\n line: paddingLineNumber,\n column: paddingLineColumn\n});\n\nOR use \"index\" property insteadof only \"column\".\n\nreport(node, new RuleError(\"message\", {\n index: paddingLineColumn\n});\n");
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
});
`);
}

@@ -36,6 +57,23 @@ // When either one of {column, line} or {index} is not used, throw error

// Always throw Error
throw new Error(errorPrefix + " Have to use one of {line, column} or {index}.\nYou should use either one:\n\nuse \"line\" and \"column\" property\n\nreport(node, new RuleError(\"message\", {\n line: paddingLineNumber,\n column: paddingLineColumn\n});\n\nOR \n\nuse \"index\" property\n\nreport(node, new RuleError(\"message\", {\n index: paddingIndexValue\n});\n");
throw new Error(`${errorPrefix} Have to use one of {line, column} or {index}.
You should use either one:
use "line" and "column" property
report(node, new RuleError("message", {
line: paddingLineNumber,
column: paddingLineColumn
});
OR
use "index" property
report(node, new RuleError("message", {
index: paddingIndexValue
});
`);
}
var adjustedLoc = this.toAbsoluteLocation(node, padding, _backwardCompatibleIndexValue);
var adjustedFix = this.toAbsolutePositionFix(node, padding);
const adjustedLoc = this.toAbsoluteLocation(node, padding, _backwardCompatibleIndexValue);
const adjustedFix = this.toAbsolutePositionFix(node, padding);
/*

@@ -49,12 +87,12 @@ {

return Object.assign({}, adjustedLoc, adjustedFix);
};
SourceLocation.prototype.toAbsoluteLocation = function (node, padding, _paddingIndex) {
var nodeRange = node.range;
var line = node.loc.start.line;
var column = node.loc.start.column;
}
toAbsoluteLocation(node, padding, _paddingIndex) {
const nodeRange = node.range;
const line = node.loc.start.line;
const column = node.loc.start.column;
// when use {index}
if (padding.index !== undefined || _paddingIndex !== undefined) {
var startNodeIndex = nodeRange[0];
var paddingIndex = _paddingIndex || padding.index;
var position = this.source.indexToPosition(startNodeIndex + paddingIndex);
const startNodeIndex = nodeRange[0];
const paddingIndex = _paddingIndex || padding.index;
const position = this.source.indexToPosition(startNodeIndex + paddingIndex);
return {

@@ -68,3 +106,3 @@ column: position.column,

if (padding.line > 0) {
var addedLine = line + padding.line;
const addedLine = line + padding.line;
// when report with padding {line, column}, message.column should be 0 + padding.column.

@@ -81,3 +119,3 @@ // In other word, padding line > 0 and message.column start with 0.

line: addedLine,
column: column
column
};

@@ -89,6 +127,6 @@ }

if (padding.line !== undefined && padding.line > 0) {
var addedLine = line + padding.line;
const addedLine = line + padding.line;
return {
line: addedLine,
column: column
column
};

@@ -105,5 +143,5 @@ }

if (padding.column !== undefined && padding.column > 0) {
var addedColumn = column + padding.column;
const addedColumn = column + padding.column;
return {
line: line,
line,
column: addedColumn

@@ -113,6 +151,6 @@ };

return {
column: column,
line: line
column,
line
};
};
}
/**

@@ -122,4 +160,4 @@ * Adjust `fix` command range

*/
SourceLocation.prototype.toAbsolutePositionFix = function (node, ruleErrorObject) {
var nodeRange = node.range;
toAbsolutePositionFix(node, ruleErrorObject) {
const nodeRange = node.range;
// if not found `fix`, return empty object

@@ -152,6 +190,4 @@ if (ruleErrorObject.fix === undefined) {

};
};
return SourceLocation;
}());
export default SourceLocation;
}
}
//# sourceMappingURL=source-location.js.map

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

import { TextlintFixableRuleDescriptor } from "./TextlintFixableRuleDescriptor";
export var createTextlintRuleDescriptors = function (rules) {
var ruleOrFixableRuleDescriptorList = rules.map(function (rule) {
export const createTextlintRuleDescriptors = (rules) => {
const ruleOrFixableRuleDescriptorList = rules.map((rule) => {
if (hasFixer(rule.rule)) {

@@ -23,8 +23,8 @@ return new TextlintFixableRuleDescriptor(rule);

};
export var createTextlintFilterRuleDescriptors = function (rules) {
return new TextlintFilterRuleDescriptors(rules.map(function (rule) { return new TextlintFilterRuleDescriptor(rule); }));
export const createTextlintFilterRuleDescriptors = (rules) => {
return new TextlintFilterRuleDescriptors(rules.map((rule) => new TextlintFilterRuleDescriptor(rule)));
};
export var createTextlintPluginDescriptors = function (rules) {
return new TextlintPluginDescriptors(rules.map(function (rule) { return new TextlintPluginDescriptor(rule); }));
export const createTextlintPluginDescriptors = (rules) => {
return new TextlintPluginDescriptors(rules.map((rule) => new TextlintPluginDescriptor(rule)));
};
//# sourceMappingURL=DescriptorsFactory.js.map

@@ -8,6 +8,6 @@ /**

*/
export var filterDuplicateDescriptor = function (descriptors) {
var newDescriptorList = [];
descriptors.forEach(function (descriptor) {
var existsDescriptor = newDescriptorList.some(function (existDescriptor) {
export const filterDuplicateDescriptor = (descriptors) => {
const newDescriptorList = [];
descriptors.forEach((descriptor) => {
const existsDescriptor = newDescriptorList.some((existDescriptor) => {
return existDescriptor.equals(descriptor);

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

@@ -70,6 +70,5 @@ /**

*/
export function assertRuleShape(ruleModule, key) {
if (key === void 0) { key = ""; }
export function assertRuleShape(ruleModule, key = "") {
if (ruleModule === undefined) {
throw new Error("Definition of rule '" + key + "' was not found.");
throw new Error(`Definition of rule '${key}' was not found.`);
}

@@ -83,3 +82,7 @@ /*

if (!isRuleModule(ruleModule)) {
throw new Error("Definition of rule '" + key + "' was not rule module.\nRule should export function:\nmodule.exports = function(context){\n // Your rule\n};");
throw new Error(`Definition of rule '${key}' was not rule module.
Rule should export function:
module.exports = function(context){
// Your rule
};`);
}

@@ -86,0 +89,0 @@ }

@@ -9,70 +9,46 @@ // LICENSE : MIT

*/
var TextlintFilterRuleDescriptor = /** @class */ (function () {
function TextlintFilterRuleDescriptor(kernelFilterRule) {
export class TextlintFilterRuleDescriptor {
constructor(kernelFilterRule) {
this.kernelFilterRule = kernelFilterRule;
}
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "id", {
get: function () {
return this.kernelFilterRule.ruleId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "rule", {
get: function () {
return this.kernelFilterRule.rule;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "enabled", {
/**
* Return true if this rule is enabled.
*/
get: function () {
return this.rawOptions !== false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "filter", {
/**
* Return filter function
* You should check hasLiner before call this.
*/
get: function () {
return getFilter(this.rule);
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "normalizedOptions", {
/**
* Return normalized rule option object.
* If the rule have not option, return `true` by default.
*/
get: function () {
// default: { ruleName: true }
var DefaultRuleConfigValue = {};
if (typeof this.kernelFilterRule.options === "boolean" || this.kernelFilterRule.options === undefined) {
return DefaultRuleConfigValue;
}
else {
return this.kernelFilterRule.options;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptor.prototype, "rawOptions", {
get: function () {
get id() {
return this.kernelFilterRule.ruleId;
}
get rule() {
return this.kernelFilterRule.rule;
}
/**
* Return true if this rule is enabled.
*/
get enabled() {
return this.rawOptions !== false;
}
/**
* Return filter function
* You should check hasLiner before call this.
*/
get filter() {
return getFilter(this.rule);
}
/**
* Return normalized rule option object.
* If the rule have not option, return `true` by default.
*/
get normalizedOptions() {
// default: { ruleName: true }
const DefaultRuleConfigValue = {};
if (typeof this.kernelFilterRule.options === "boolean" || this.kernelFilterRule.options === undefined) {
return DefaultRuleConfigValue;
}
else {
return this.kernelFilterRule.options;
},
enumerable: false,
configurable: true
});
}
}
get rawOptions() {
return this.kernelFilterRule.options;
}
/**
* Return true if descriptor is same
*/
TextlintFilterRuleDescriptor.prototype.equals = function (descriptor) {
equals(descriptor) {
return (this.rule === descriptor.rule &&

@@ -82,9 +58,7 @@ deepEqual(this.normalizedOptions, descriptor.normalizedOptions, {

}));
};
TextlintFilterRuleDescriptor.prototype.toKernel = function () {
}
toKernel() {
return this.kernelFilterRule;
};
return TextlintFilterRuleDescriptor;
}());
export { TextlintFilterRuleDescriptor };
}
}
//# sourceMappingURL=TextlintFilterRuleDescriptor.js.map

@@ -7,5 +7,4 @@ // LICENSE : MIT

*/
var TextlintFilterRuleDescriptors = /** @class */ (function () {
function TextlintFilterRuleDescriptors(ruleDescriptorList) {
if (ruleDescriptorList === void 0) { ruleDescriptorList = []; }
export class TextlintFilterRuleDescriptors {
constructor(ruleDescriptorList = []) {
this.ruleDescriptorList = ruleDescriptorList;

@@ -17,40 +16,30 @@ }

*/
TextlintFilterRuleDescriptors.prototype.toKernelFilterRulesFormat = function () {
return this.withoutDuplicated().descriptors.map(function (descriptor) {
toKernelFilterRulesFormat() {
return this.withoutDuplicated().descriptors.map((descriptor) => {
return descriptor.toKernel();
});
};
Object.defineProperty(TextlintFilterRuleDescriptors.prototype, "descriptors", {
/**
* Return enabled descriptors
*/
get: function () {
return this.ruleDescriptorList.filter(function (descriptor) {
return descriptor.enabled;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintFilterRuleDescriptors.prototype, "allDescriptors", {
/**
* Return all descriptors that include disabled descriptors
*/
get: function () {
return this.ruleDescriptorList;
},
enumerable: false,
configurable: true
});
}
/**
* Return enabled descriptors
*/
get descriptors() {
return this.ruleDescriptorList.filter((descriptor) => {
return descriptor.enabled;
});
}
/**
* Return all descriptors that include disabled descriptors
*/
get allDescriptors() {
return this.ruleDescriptorList;
}
/**
* filter duplicated descriptors
*/
TextlintFilterRuleDescriptors.prototype.withoutDuplicated = function () {
withoutDuplicated() {
// remove last duplicated item
var newDescriptorList = filterDuplicateDescriptor(this.ruleDescriptorList);
const newDescriptorList = filterDuplicateDescriptor(this.ruleDescriptorList);
return new TextlintFilterRuleDescriptors(newDescriptorList);
};
return TextlintFilterRuleDescriptors;
}());
export { TextlintFilterRuleDescriptors };
}
}
//# sourceMappingURL=TextlintFilterRuleDescriptors.js.map
// LICENSE : MIT
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { getFixer } from "./rule-creator-helper";

@@ -25,21 +10,11 @@ import { TextlintLintableRuleDescriptor } from "./TextlintLintableRuleDescriptor";

*/
var TextlintFixableRuleDescriptor = /** @class */ (function (_super) {
__extends(TextlintFixableRuleDescriptor, _super);
function TextlintFixableRuleDescriptor() {
return _super !== null && _super.apply(this, arguments) || this;
export class TextlintFixableRuleDescriptor extends TextlintLintableRuleDescriptor {
/**
* Return fixer function
* You should check hasFixer before call this.
*/
get fixer() {
return getFixer(this.rule);
}
Object.defineProperty(TextlintFixableRuleDescriptor.prototype, "fixer", {
/**
* Return fixer function
* You should check hasFixer before call this.
*/
get: function () {
return getFixer(this.rule);
},
enumerable: false,
configurable: true
});
return TextlintFixableRuleDescriptor;
}(TextlintLintableRuleDescriptor));
export { TextlintFixableRuleDescriptor };
}
//# sourceMappingURL=TextlintFixableRuleDescriptor.js.map

@@ -1,15 +0,4 @@

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { createTextlintFilterRuleDescriptors, createTextlintPluginDescriptors, createTextlintRuleDescriptors } from "./DescriptorsFactory";
var TextlintKernelDescriptor = /** @class */ (function () {
function TextlintKernelDescriptor(args) {
export class TextlintKernelDescriptor {
constructor(args) {
this.args = args;

@@ -20,13 +9,9 @@ this.rule = createTextlintRuleDescriptors(args.rules);

}
Object.defineProperty(TextlintKernelDescriptor.prototype, "availableExtensions", {
/**
* Return available extensions of plugins
*/
get: function () {
return this.plugin.availableExtensions;
},
enumerable: false,
configurable: true
});
/**
* Return available extensions of plugins
*/
get availableExtensions() {
return this.plugin.availableExtensions;
}
/**
* Merge constructor args and partialArgs

@@ -36,5 +21,5 @@ * It shallow merge partialArgs.

*/
TextlintKernelDescriptor.prototype.shallowMerge = function (partialArgs) {
return new TextlintKernelDescriptor(__assign(__assign({}, this.args), partialArgs));
};
shallowMerge(partialArgs) {
return new TextlintKernelDescriptor(Object.assign(Object.assign({}, this.args), partialArgs));
}
/**

@@ -50,8 +35,6 @@ * find PluginDescriptor with extension.

*/
TextlintKernelDescriptor.prototype.findPluginDescriptorWithExt = function (ext) {
findPluginDescriptorWithExt(ext) {
return this.plugin.findPluginDescriptorWithExt(ext);
};
return TextlintKernelDescriptor;
}());
export { TextlintKernelDescriptor };
}
}
//# sourceMappingURL=TextlintKernelDescriptor.js.map

@@ -9,74 +9,50 @@ // LICENSE : MIT

*/
var TextlintLintableRuleDescriptor = /** @class */ (function () {
function TextlintLintableRuleDescriptor(textlintKernelRule) {
export class TextlintLintableRuleDescriptor {
constructor(textlintKernelRule) {
this.textlintKernelRule = textlintKernelRule;
assertRuleShape(textlintKernelRule.rule, textlintKernelRule.ruleId);
}
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "id", {
get: function () {
return this.textlintKernelRule.ruleId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "rule", {
/**
* Rule module-self
*/
get: function () {
return this.textlintKernelRule.rule;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "enabled", {
/**
* Return true if this rule is enabled.
*/
get: function () {
return this.rawOptions !== false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "linter", {
/**
* Return linter function
* You should check hasLiner before call this.
*/
get: function () {
return getLinter(this.rule);
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "normalizedOptions", {
/**
* Return normalized rule option object.
* If the rule have not option, return `true` by default.
*/
get: function () {
// default: { ruleName: true }
var DefaultRuleConfigValue = {};
if (typeof this.textlintKernelRule.options === "boolean" || this.textlintKernelRule.options === undefined) {
return DefaultRuleConfigValue;
}
else {
return this.textlintKernelRule.options;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintLintableRuleDescriptor.prototype, "rawOptions", {
get: function () {
get id() {
return this.textlintKernelRule.ruleId;
}
/**
* Rule module-self
*/
get rule() {
return this.textlintKernelRule.rule;
}
/**
* Return true if this rule is enabled.
*/
get enabled() {
return this.rawOptions !== false;
}
/**
* Return linter function
* You should check hasLiner before call this.
*/
get linter() {
return getLinter(this.rule);
}
/**
* Return normalized rule option object.
* If the rule have not option, return `true` by default.
*/
get normalizedOptions() {
// default: { ruleName: true }
const DefaultRuleConfigValue = {};
if (typeof this.textlintKernelRule.options === "boolean" || this.textlintKernelRule.options === undefined) {
return DefaultRuleConfigValue;
}
else {
return this.textlintKernelRule.options;
},
enumerable: false,
configurable: true
});
}
}
get rawOptions() {
return this.textlintKernelRule.options;
}
/**
* Return true if descriptor is same
*/
TextlintLintableRuleDescriptor.prototype.equals = function (descriptor) {
equals(descriptor) {
return (this.rule === descriptor.rule &&

@@ -86,9 +62,7 @@ deepEqual(this.normalizedOptions, descriptor.normalizedOptions, {

}));
};
TextlintLintableRuleDescriptor.prototype.toKernel = function () {
}
toKernel() {
return this.textlintKernelRule;
};
return TextlintLintableRuleDescriptor;
}());
export { TextlintLintableRuleDescriptor };
}
}
//# sourceMappingURL=TextlintLintableRuleDescriptor.js.map

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

*/
var getAvailableExtensions = function (pluginProcessor) {
const getAvailableExtensions = (pluginProcessor) => {
if (typeof pluginProcessor.availableExtensions === "function") {

@@ -14,7 +14,7 @@ return pluginProcessor.availableExtensions();

// https://github.com/textlint/textlint/issues/531
var PluginProcessorConstructor = pluginProcessor.constructor;
const PluginProcessorConstructor = pluginProcessor.constructor;
if (typeof PluginProcessorConstructor.availableExtensions === "function") {
return PluginProcessorConstructor.availableExtensions();
}
throw new Error("Plugin(" + pluginProcessor + ") should implement availableExtensions() method");
throw new Error(`Plugin(${pluginProcessor}) should implement availableExtensions() method`);
};

@@ -24,63 +24,47 @@ /**

*/
var TextlintPluginDescriptor = /** @class */ (function () {
function TextlintPluginDescriptor(plugin) {
export class TextlintPluginDescriptor {
constructor(plugin) {
this.plugin = plugin;
this.plugin = plugin;
if (!this.plugin.plugin.Processor) {
throw new Error("Plugin should have Processor property.\nmodule.exports = {\n Processor: class Processor{ ... }\n}\n");
throw new Error(`Plugin should have Processor property.
module.exports = {
Processor: class Processor{ ... }
}
`);
}
this.processor = new plugin.plugin.Processor(this.normalizedOptions);
}
Object.defineProperty(TextlintPluginDescriptor.prototype, "id", {
get: function () {
return this.plugin.pluginId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptor.prototype, "enabled", {
/**
* Return true if this rule is enabled.
*/
get: function () {
return this.rawOptions !== false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptor.prototype, "availableExtensions", {
/**
* Return available extension of this plugin
*/
get: function () {
return getAvailableExtensions(this.processor);
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptor.prototype, "normalizedOptions", {
get: function () {
// default: { ruleName: true }
var DefaultPluginOption = {};
if (typeof this.plugin.options === "boolean" || this.plugin.options === undefined) {
return DefaultPluginOption;
}
else {
return this.plugin.options;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptor.prototype, "rawOptions", {
get: function () {
get id() {
return this.plugin.pluginId;
}
/**
* Return true if this rule is enabled.
*/
get enabled() {
return this.rawOptions !== false;
}
/**
* Return available extension of this plugin
*/
get availableExtensions() {
return getAvailableExtensions(this.processor);
}
get normalizedOptions() {
// default: { ruleName: true }
const DefaultPluginOption = {};
if (typeof this.plugin.options === "boolean" || this.plugin.options === undefined) {
return DefaultPluginOption;
}
else {
return this.plugin.options;
},
enumerable: false,
configurable: true
});
TextlintPluginDescriptor.prototype.toKernel = function () {
}
}
get rawOptions() {
return this.plugin.options;
}
toKernel() {
return this.plugin;
};
TextlintPluginDescriptor.prototype.equals = function (target) {
}
equals(target) {
return (this.plugin.plugin === target.plugin.plugin &&

@@ -90,6 +74,4 @@ deepEqual(this.plugin.options, target.plugin.options, {

}));
};
return TextlintPluginDescriptor;
}());
export { TextlintPluginDescriptor };
}
}
//# sourceMappingURL=TextlintPluginDescriptor.js.map

@@ -6,58 +6,45 @@ "use strict";

*/
var TextlintPluginDescriptors = /** @class */ (function () {
function TextlintPluginDescriptors(pluginDescriptorList) {
if (pluginDescriptorList === void 0) { pluginDescriptorList = []; }
export class TextlintPluginDescriptors {
constructor(pluginDescriptorList = []) {
this.pluginDescriptorList = pluginDescriptorList;
}
Object.defineProperty(TextlintPluginDescriptors.prototype, "descriptors", {
/**
* Return enabled descriptors
*/
get: function () {
return this.pluginDescriptorList.filter(function (descriptor) {
return descriptor.enabled;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptors.prototype, "allDescriptors", {
/**
* Return all descriptors that include disabled descriptors
*/
get: function () {
return this.pluginDescriptorList;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintPluginDescriptors.prototype, "availableExtensions", {
/**
* Return available extensions
* It is not includes disabled plugin's extensions.
*/
get: function () {
return this.descriptors.reduce(function (extensions, descriptor) {
return extensions.concat(descriptor.availableExtensions);
}, []);
},
enumerable: false,
configurable: true
});
/**
* Return enabled descriptors
*/
get descriptors() {
return this.pluginDescriptorList.filter((descriptor) => {
return descriptor.enabled;
});
}
/**
* Return all descriptors that include disabled descriptors
*/
get allDescriptors() {
return this.pluginDescriptorList;
}
/**
* Return available extensions
* It is not includes disabled plugin's extensions.
*/
get availableExtensions() {
return this.descriptors.reduce((extensions, descriptor) => {
return extensions.concat(descriptor.availableExtensions);
}, []);
}
/**
* find PluginDescriptor with extension.
* This is forward match.
*/
TextlintPluginDescriptors.prototype.findPluginDescriptorWithExt = function (ext) {
return this.descriptors.find(function (descriptor) {
findPluginDescriptorWithExt(ext) {
return this.descriptors.find((descriptor) => {
return descriptor.availableExtensions.includes(ext);
});
};
}
/**
* filter duplicated descriptors
*/
TextlintPluginDescriptors.prototype.withoutDuplicated = function () {
var newDescriptorList = filterDuplicateDescriptor(this.pluginDescriptorList);
withoutDuplicated() {
const newDescriptorList = filterDuplicateDescriptor(this.pluginDescriptorList);
return new TextlintPluginDescriptors(newDescriptorList);
};
}
/**

@@ -67,10 +54,8 @@ * Convert this to TextlintKernel rules format

*/
TextlintPluginDescriptors.prototype.toKernelPluginsFormat = function () {
return this.descriptors.map(function (descriptor) {
toKernelPluginsFormat() {
return this.descriptors.map((descriptor) => {
return descriptor.toKernel();
});
};
return TextlintPluginDescriptors;
}());
export { TextlintPluginDescriptors };
}
}
//# sourceMappingURL=TextlintPluginDescriptors.js.map

@@ -9,5 +9,4 @@ // LICENSE : MIT

*/
var TextlintRuleDescriptors = /** @class */ (function () {
function TextlintRuleDescriptors(ruleDescriptorList) {
if (ruleDescriptorList === void 0) { ruleDescriptorList = []; }
export class TextlintRuleDescriptors {
constructor(ruleDescriptorList = []) {
this.ruleDescriptorList = ruleDescriptorList;

@@ -19,62 +18,44 @@ }

*/
TextlintRuleDescriptors.prototype.toKernelRulesFormat = function () {
return this.withoutDuplicated().lintableDescriptors.map(function (descriptor) {
toKernelRulesFormat() {
return this.withoutDuplicated().lintableDescriptors.map((descriptor) => {
return descriptor.toKernel();
});
};
Object.defineProperty(TextlintRuleDescriptors.prototype, "lintableDescriptors", {
/**
* Return enabled lintable descriptors
*/
get: function () {
return this.descriptors.filter(function (descriptor) {
// fixable is also lintable
return descriptor instanceof TextlintLintableRuleDescriptor;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleDescriptors.prototype, "fixableDescriptors", {
/**
* Return enabled fixable descriptors
*/
get: function () {
return this.descriptors.filter(function (descriptor) {
return descriptor instanceof TextlintFixableRuleDescriptor;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleDescriptors.prototype, "descriptors", {
/**
* Return enabled descriptors
*/
get: function () {
return this.ruleDescriptorList.filter(function (descriptor) { return descriptor.enabled; });
},
enumerable: false,
configurable: true
});
Object.defineProperty(TextlintRuleDescriptors.prototype, "allDescriptors", {
/**
* Return all descriptors that include disabled descriptors
*/
get: function () {
return this.ruleDescriptorList;
},
enumerable: false,
configurable: true
});
}
/**
* Return enabled lintable descriptors
*/
get lintableDescriptors() {
return this.descriptors.filter((descriptor) => {
// fixable is also lintable
return descriptor instanceof TextlintLintableRuleDescriptor;
});
}
/**
* Return enabled fixable descriptors
*/
get fixableDescriptors() {
return this.descriptors.filter((descriptor) => {
return descriptor instanceof TextlintFixableRuleDescriptor;
});
}
/**
* Return enabled descriptors
*/
get descriptors() {
return this.ruleDescriptorList.filter((descriptor) => descriptor.enabled);
}
/**
* Return all descriptors that include disabled descriptors
*/
get allDescriptors() {
return this.ruleDescriptorList;
}
/**
* filter duplicated descriptors
*/
TextlintRuleDescriptors.prototype.withoutDuplicated = function () {
var newDescriptorList = filterDuplicateDescriptor(this.ruleDescriptorList);
withoutDuplicated() {
const newDescriptorList = filterDuplicateDescriptor(this.ruleDescriptorList);
return new TextlintRuleDescriptors(newDescriptorList);
};
return TextlintRuleDescriptors;
}());
export { TextlintRuleDescriptors };
}
}
//# sourceMappingURL=TextlintRuleDescriptors.js.map

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

import { applyFixesToSourceCode } from "@textlint/source-code-fixer";
var debug = _debug("textlint:fixer-processor");
var FixerProcessor = /** @class */ (function () {
const debug = _debug("textlint:fixer-processor");
export default class FixerProcessor {
/**

@@ -17,3 +17,3 @@ * @param {Processor} processor

*/
function FixerProcessor(processor, messageProcessManager) {
constructor(processor, messageProcessManager) {
this.processor = processor;

@@ -31,28 +31,26 @@ this.messageProcessManager = messageProcessManager;

*/
FixerProcessor.prototype.process = function (_a) {
var _this = this;
var config = _a.config, configBaseDir = _a.configBaseDir, ruleDescriptors = _a.ruleDescriptors, filterRules = _a.filterRules, sourceCode = _a.sourceCode;
process({ config, configBaseDir, ruleDescriptors, filterRules, sourceCode }) {
assert.ok(sourceCode);
var _b = this.processor.processor(sourceCode.ext), preProcess = _b.preProcess, postProcess = _b.postProcess;
const { preProcess, postProcess } = this.processor.processor(sourceCode.ext);
// messages
var resultFilePath = sourceCode.filePath;
let resultFilePath = sourceCode.filePath;
// applied fixing messages
// Revert = Sequentially apply applied message to applied output
// SourceCodeFixer.sequentiallyApplyFixes(fixedOutput, result.applyingMessages);
var applyingMessages = [];
const applyingMessages = [];
// not applied fixing messages
var remainingMessages = [];
const remainingMessages = [];
// original means original for applyingMessages and remainingMessages
// pre-applyingMessages + remainingMessages
var originalMessages = [];
var fixerProcessList = ruleDescriptors.fixableDescriptors.map(function (ruleDescriptor) {
return function (sourceText) {
const originalMessages = [];
const fixerProcessList = ruleDescriptors.fixableDescriptors.map((ruleDescriptor) => {
return (sourceText) => {
// create new SourceCode object
var preProcessResult = preProcess(sourceText, sourceCode.filePath);
var isPluginReturnAnAST = isTxtAST(preProcessResult);
var textForAST = isPluginReturnAnAST ? sourceText : preProcessResult.text;
var ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
var newSourceCode = new TextlintSourceCodeImpl({
const preProcessResult = preProcess(sourceText, sourceCode.filePath);
const isPluginReturnAnAST = isTxtAST(preProcessResult);
const textForAST = isPluginReturnAnAST ? sourceText : preProcessResult.text;
const ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
const newSourceCode = new TextlintSourceCodeImpl({
text: textForAST,
ast: ast,
ast,
filePath: resultFilePath,

@@ -62,18 +60,18 @@ ext: sourceCode.ext

// create new Task
var task = new FixerTask({
config: config,
const task = new FixerTask({
config,
fixableRuleDescriptor: ruleDescriptor,
filterRuleDescriptors: filterRules,
sourceCode: newSourceCode,
configBaseDir: configBaseDir
configBaseDir
});
return TaskRunner.process(task).then(function (messages) {
var result = postProcess(messages, sourceCode.filePath);
var filteredResult = {
messages: _this.messageProcessManager.process(result.messages),
filePath: result.filePath ? result.filePath : "<Unkown" + sourceCode.ext + ">"
return TaskRunner.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
const filteredResult = {
messages: this.messageProcessManager.process(result.messages),
filePath: result.filePath ? result.filePath : `<Unkown${sourceCode.ext}>`
};
// TODO: should be removed resultFilePath
resultFilePath = filteredResult.filePath;
var applied = applyFixesToSourceCode(newSourceCode, filteredResult.messages);
const applied = applyFixesToSourceCode(newSourceCode, filteredResult.messages);
// add messages

@@ -92,23 +90,21 @@ Array.prototype.push.apply(applyingMessages, applied.applyingMessages);

});
var promiseTask = fixerProcessList.reduce(function (promise, fixerProcess) {
return promise.then(function (sourceText) {
const promiseTask = fixerProcessList.reduce((promise, fixerProcess) => {
return promise.then((sourceText) => {
return fixerProcess(sourceText);
});
}, Promise.resolve(sourceCode.text));
return promiseTask.then(function (output) {
debug("Finish Processing: " + resultFilePath);
debug("applyingMessages: " + applyingMessages.length);
debug("remainingMessages: " + remainingMessages.length);
return promiseTask.then((output) => {
debug(`Finish Processing: ${resultFilePath}`);
debug(`applyingMessages: ${applyingMessages.length}`);
debug(`remainingMessages: ${remainingMessages.length}`);
return {
filePath: resultFilePath ? resultFilePath : "<Unkown" + sourceCode.ext + ">",
output: output,
filePath: resultFilePath ? resultFilePath : `<Unkown${sourceCode.ext}>`,
output,
messages: originalMessages,
applyingMessages: applyingMessages,
remainingMessages: remainingMessages
applyingMessages,
remainingMessages
};
});
};
return FixerProcessor;
}());
export default FixerProcessor;
}
}
//# sourceMappingURL=fixer-processor.js.map

@@ -13,3 +13,3 @@ import * as assert from "assert";

range: [index, index],
text: text,
text,
isAbsolute: false

@@ -29,3 +29,3 @@ };

range: [index, index],
text: text,
text,
isAbsolute: true

@@ -41,5 +41,3 @@ };

*/
var RuleFixer = /** @class */ (function () {
function RuleFixer() {
}
export default class RuleFixer {
/**

@@ -52,5 +50,5 @@ * Creates a fix command that inserts text after the given node or token.

*/
RuleFixer.prototype.insertTextAfter = function (node, text) {
insertTextAfter(node, text) {
return insertTextAtAbsolute(node.range[1], text);
};
}
/**

@@ -65,5 +63,5 @@ * Creates a fix command that inserts text after the specified range in the source text.

*/
RuleFixer.prototype.insertTextAfterRange = function (range, text) {
insertTextAfterRange(range, text) {
return insertTextAt(range[1], text);
};
}
/**

@@ -76,5 +74,5 @@ * Creates a fix command that inserts text before the given node or token.

*/
RuleFixer.prototype.insertTextBefore = function (node, text) {
insertTextBefore(node, text) {
return insertTextAtAbsolute(node.range[0], text);
};
}
/**

@@ -89,5 +87,5 @@ * Creates a fix command that inserts text before the specified range in the source text.

*/
RuleFixer.prototype.insertTextBeforeRange = function (range, text) {
insertTextBeforeRange(range, text) {
return insertTextAt(range[0], text);
};
}
/**

@@ -100,9 +98,9 @@ * Creates a fix command that replaces text at the node or token.

*/
RuleFixer.prototype.replaceText = function (node, text) {
replaceText(node, text) {
return {
range: node.range,
text: text,
text,
isAbsolute: true
};
};
}
/**

@@ -117,9 +115,9 @@ * Creates a fix command that replaces text at the specified range in the source text.

*/
RuleFixer.prototype.replaceTextRange = function (range, text) {
replaceTextRange(range, text) {
return {
range: range,
text: text,
range,
text,
isAbsolute: false
};
};
}
/**

@@ -131,5 +129,5 @@ * Creates a fix command that removes the node or token from the source.

*/
RuleFixer.prototype.remove = function (node) {
remove(node) {
return this.replaceText(node, "");
};
}
/**

@@ -143,8 +141,6 @@ * Creates a fix command that removes the specified range of text from the source.

*/
RuleFixer.prototype.removeRange = function (range) {
removeRange(range) {
return this.replaceTextRange(range, "");
};
return RuleFixer;
}());
export default RuleFixer;
}
}
//# sourceMappingURL=rule-fixer.js.map

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

import TaskRunner from "../task/task-runner";
var LinterProcessor = /** @class */ (function () {
export default class LinterProcessor {
/**

@@ -12,3 +12,3 @@ * @param {Processor} processor

*/
function LinterProcessor(processor, messageProcessManager) {
constructor(processor, messageProcessManager) {
this.processor = processor;

@@ -20,19 +20,17 @@ this.messageProcessManager = messageProcessManager;

*/
LinterProcessor.prototype.process = function (_a) {
var _this = this;
var config = _a.config, configBaseDir = _a.configBaseDir, ruleDescriptors = _a.ruleDescriptors, filterRuleDescriptors = _a.filterRuleDescriptors, sourceCode = _a.sourceCode;
var _b = this.processor.processor(sourceCode.ext), preProcess = _b.preProcess, postProcess = _b.postProcess;
process({ config, configBaseDir, ruleDescriptors, filterRuleDescriptors, sourceCode }) {
const { preProcess, postProcess } = this.processor.processor(sourceCode.ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", "processor should implement {preProcess, postProcess}");
var task = new LinterTask({
config: config,
const task = new LinterTask({
config,
ruleDescriptors: ruleDescriptors,
filterRuleDescriptors: filterRuleDescriptors,
sourceCode: sourceCode,
configBaseDir: configBaseDir
sourceCode,
configBaseDir
});
return TaskRunner.process(task).then(function (messages) {
var result = postProcess(messages, sourceCode.filePath);
result.messages = _this.messageProcessManager.process(result.messages);
return TaskRunner.process(task).then((messages) => {
const result = postProcess(messages, sourceCode.filePath);
result.messages = this.messageProcessManager.process(result.messages);
if (result.filePath == null) {
result.filePath = "<Unkown" + sourceCode.ext + ">";
result.filePath = `<Unkown${sourceCode.ext}>`;
}

@@ -42,6 +40,4 @@ assert.ok(result.filePath && result.messages.length >= 0, "postProcess should return { messages, filePath } ");

});
};
return LinterProcessor;
}());
export default LinterProcessor;
}
}
//# sourceMappingURL=linter-processor.js.map

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

*/
var isEqualMessage = function (aMessage, bMessage) {
const isEqualMessage = (aMessage, bMessage) => {
return (aMessage.index === bMessage.index &&

@@ -18,7 +18,6 @@ aMessage.severity === bMessage.severity &&

*/
export default function filterDuplicatedMessages(messages) {
if (messages === void 0) { messages = []; }
return messages.filter(function (message, index) {
var restMessages = messages.slice(index + 1);
return !restMessages.some(function (restMessage) {
export default function filterDuplicatedMessages(messages = []) {
return messages.filter((message, index) => {
const restMessages = messages.slice(index + 1);
return !restMessages.some((restMessage) => {
return isEqualMessage(message, restMessage);

@@ -25,0 +24,0 @@ });

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

*/
var isContainedRange = function (index, range) {
var start = range[0], end = range[1];
const isContainedRange = (index, range) => {
const [start, end] = range;
return start <= index && index <= end;

@@ -20,14 +20,13 @@ };

*/
export default function filterMessages(messages) {
if (messages === void 0) { messages = []; }
var lintingMessages = messages.filter(function (message) {
export default function filterMessages(messages = []) {
const lintingMessages = messages.filter((message) => {
return message.type === MessageType.lint;
});
var ignoreMessages = messages.filter(function (message) {
const ignoreMessages = messages.filter((message) => {
return message.type === MessageType.ignore;
});
// if match, reject the message
return lintingMessages.filter(function (message) {
return !ignoreMessages.some(function (ignoreMessage) {
var isInIgnoringRange = isContainedRange(message.index, ignoreMessage.range);
return lintingMessages.filter((message) => {
return !ignoreMessages.some((ignoreMessage) => {
const isInIgnoringRange = isContainedRange(message.index, ignoreMessage.range);
if (isInIgnoringRange && ignoreMessage.ignoringRuleId) {

@@ -34,0 +33,0 @@ // "*" is wildcard that match any rule

@@ -9,5 +9,4 @@ // LICENSE : MIT

*/
export function filterWarningMessages(messages) {
if (messages === void 0) { messages = []; }
return messages.filter(function (message) {
export function filterWarningMessages(messages = []) {
return messages.filter((message) => {
return message.severity === TextlintRuleSeverityLevelKeys.error;

@@ -21,4 +20,3 @@ });

*/
export function through(messages) {
if (messages === void 0) { messages = []; }
export function through(messages = []) {
return messages;

@@ -25,0 +23,0 @@ }

// LICENSE : MIT
"use strict";
var MessageProcessManager = /** @class */ (function () {
export default class MessageProcessManager {
/**
* Preprossor
*/
function MessageProcessManager(preProcessors) {
constructor(preProcessors) {
this._preProcessors = preProcessors || [];
this._processors = [];
}
MessageProcessManager.prototype.add = function (messageProcessor) {
add(messageProcessor) {
this._processors.push(messageProcessor);
};
MessageProcessManager.prototype.remove = function (process) {
var index = this._processors.indexOf(process);
}
remove(process) {
const index = this._processors.indexOf(process);
if (index !== -1) {
this._processors.splice(index, 1);
}
};
}
/**

@@ -25,8 +25,8 @@ * process `messages` with registered processes

*/
MessageProcessManager.prototype.process = function (messages) {
var originalMessages = messages;
process(messages) {
const originalMessages = messages;
if (this._preProcessors.length === 0) {
throw new Error("pre process should be > 0");
}
var preProcessedMesssages = this._preProcessors.reduce(function (messages, filter) {
const preProcessedMesssages = this._preProcessors.reduce((messages, filter) => {
return filter(messages);

@@ -37,9 +37,7 @@ }, originalMessages);

}
return this._processors.reduce(function (messages, filter) {
return this._processors.reduce((messages, filter) => {
return filter(messages);
}, preProcessedMesssages);
};
return MessageProcessManager;
}());
export default MessageProcessManager;
}
}
//# sourceMappingURL=MessageProcessManager.js.map

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

return messages.sort(function (a, b) {
var lineDiff = a.line - b.line;
const lineDiff = a.line - b.line;
if (lineDiff === 0) {

@@ -14,0 +14,0 @@ return a.column - b.column;

// LICENSE : MIT
"use strict";
import { TextlintRuleSeverityLevelKeys } from "../context/TextlintRuleSeverityLevelKeys";
var isSeverityLevelValue = function (type) {
const isSeverityLevelValue = (type) => {
if (type === undefined) {
throw new Error("Please set following value to severity:\n\"rule-key\": {\n \"severity\": \"<warning|error>\"\n}");
throw new Error(`Please set following value to severity:
"rule-key": {
"severity": "<warning|error>"
}`);
}

@@ -24,5 +27,8 @@ return true;

if (ruleConfig.severity) {
var severityValue = TextlintRuleSeverityLevelKeys[ruleConfig.severity];
const severityValue = TextlintRuleSeverityLevelKeys[ruleConfig.severity];
if (!isSeverityLevelValue(severityValue)) {
throw new Error("Please set following value to severity:\n\"rule-key\": {\n \"severity\": \"<warning|error>\"\n}");
throw new Error(`Please set following value to severity:
"rule-key": {
"severity": "<warning|error>"
}`);
}

@@ -29,0 +35,0 @@ return severityValue;

// LICENSE : MIT
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import CoreTask from "./textlint-core-task";

@@ -23,32 +8,28 @@ import { getSeverity } from "../shared/rule-severity";

import _debug from "debug";
var debug = _debug("textlint:TextLintCoreTask");
var TextLintCoreTask = /** @class */ (function (_super) {
__extends(TextLintCoreTask, _super);
function TextLintCoreTask(_a) {
var config = _a.config, configBaseDir = _a.configBaseDir, fixableRuleDescriptor = _a.fixableRuleDescriptor, filterRuleDescriptors = _a.filterRuleDescriptors, sourceCode = _a.sourceCode;
var _this = _super.call(this) || this;
_this.config = config;
_this.configBaseDir = configBaseDir;
_this.fixableRuleDescriptor = fixableRuleDescriptor;
_this.filterRuleDescriptors = filterRuleDescriptors;
_this.sourceCode = sourceCode;
_this._setupRules();
return _this;
const debug = _debug("textlint:TextLintCoreTask");
export default class TextLintCoreTask extends CoreTask {
constructor({ config, configBaseDir, fixableRuleDescriptor, filterRuleDescriptors, sourceCode }) {
super();
this.config = config;
this.configBaseDir = configBaseDir;
this.fixableRuleDescriptor = fixableRuleDescriptor;
this.filterRuleDescriptors = filterRuleDescriptors;
this.sourceCode = sourceCode;
this._setupRules();
}
TextLintCoreTask.prototype.start = function () {
start() {
this.startTraverser(this.sourceCode);
};
TextLintCoreTask.prototype._setupRules = function () {
var _this = this;
}
_setupRules() {
// rule
var sourceCode = this.sourceCode;
var report = this.createReporter(sourceCode);
var ignoreReport = this.createShouldIgnore();
const sourceCode = this.sourceCode;
const report = this.createReporter(sourceCode);
const ignoreReport = this.createShouldIgnore();
// setup "rules" field by using a single fixerRule
debug("fixerRule", this.fixableRuleDescriptor);
var ruleContext = new TextlintRuleContextImpl({
const ruleContext = new TextlintRuleContextImpl({
ruleId: this.fixableRuleDescriptor.id,
severityLevel: getSeverity(this.fixableRuleDescriptor.normalizedOptions),
sourceCode: sourceCode,
report: report,
sourceCode,
report,
configBaseDir: this.configBaseDir

@@ -59,16 +40,14 @@ });

debug("filterRules", this.filterRuleDescriptors);
this.filterRuleDescriptors.descriptors.forEach(function (filterRuleDescriptor) {
var ruleContext = new TextlintFilterRuleContextImpl({
this.filterRuleDescriptors.descriptors.forEach((filterRuleDescriptor) => {
const ruleContext = new TextlintFilterRuleContextImpl({
ruleId: filterRuleDescriptor.id,
severityLevel: getSeverity(filterRuleDescriptor.normalizedOptions),
sourceCode: sourceCode,
ignoreReport: ignoreReport,
configBaseDir: _this.configBaseDir
sourceCode,
ignoreReport,
configBaseDir: this.configBaseDir
});
_this.tryToAddListenRule(filterRuleDescriptor.filter, ruleContext, filterRuleDescriptor.normalizedOptions);
this.tryToAddListenRule(filterRuleDescriptor.filter, ruleContext, filterRuleDescriptor.normalizedOptions);
});
};
return TextLintCoreTask;
}(CoreTask));
export default TextLintCoreTask;
}
}
//# sourceMappingURL=fixer-task.js.map
// LICENSE : MIT
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import CoreTask from "./textlint-core-task";

@@ -22,53 +7,47 @@ import { getSeverity } from "../shared/rule-severity";

import { TextlintFilterRuleContextImpl } from "../context/TextlintFilterRuleContextImpl";
var TextLintCoreTask = /** @class */ (function (_super) {
__extends(TextLintCoreTask, _super);
function TextLintCoreTask(_a) {
var config = _a.config, configBaseDir = _a.configBaseDir, ruleDescriptors = _a.ruleDescriptors, filterRuleDescriptors = _a.filterRuleDescriptors, sourceCode = _a.sourceCode;
var _this = _super.call(this) || this;
_this.config = config;
_this.configBaseDir = configBaseDir;
_this.ruleDescriptors = ruleDescriptors;
_this.filterRuleDescriptors = filterRuleDescriptors;
_this.sourceCode = sourceCode;
_this._setupRules();
return _this;
export default class TextLintCoreTask extends CoreTask {
constructor({ config, configBaseDir, ruleDescriptors, filterRuleDescriptors: filterRuleDescriptors, sourceCode }) {
super();
this.config = config;
this.configBaseDir = configBaseDir;
this.ruleDescriptors = ruleDescriptors;
this.filterRuleDescriptors = filterRuleDescriptors;
this.sourceCode = sourceCode;
this._setupRules();
}
TextLintCoreTask.prototype.start = function () {
start() {
this.startTraverser(this.sourceCode);
};
TextLintCoreTask.prototype._setupRules = function () {
var _this = this;
}
_setupRules() {
// rule
var sourceCode = this.sourceCode;
var report = this.createReporter(sourceCode);
var ignoreReport = this.createShouldIgnore();
const sourceCode = this.sourceCode;
const report = this.createReporter(sourceCode);
const ignoreReport = this.createShouldIgnore();
// setup "rules" field
// filter duplicated rules for improving experience
// see https://github.com/textlint/textlint/issues/219
this.ruleDescriptors.lintableDescriptors.forEach(function (ruleDescriptor) {
var ruleOptions = ruleDescriptor.normalizedOptions;
var ruleContext = new TextlintRuleContextImpl({
this.ruleDescriptors.lintableDescriptors.forEach((ruleDescriptor) => {
const ruleOptions = ruleDescriptor.normalizedOptions;
const ruleContext = new TextlintRuleContextImpl({
ruleId: ruleDescriptor.id,
severityLevel: getSeverity(ruleOptions),
sourceCode: sourceCode,
report: report,
configBaseDir: _this.configBaseDir
sourceCode,
report,
configBaseDir: this.configBaseDir
});
_this.tryToAddListenRule(ruleDescriptor.linter, ruleContext, ruleOptions);
this.tryToAddListenRule(ruleDescriptor.linter, ruleContext, ruleOptions);
});
// setup "filters" field
this.filterRuleDescriptors.descriptors.forEach(function (filterDescriptor) {
var ruleContext = new TextlintFilterRuleContextImpl({
this.filterRuleDescriptors.descriptors.forEach((filterDescriptor) => {
const ruleContext = new TextlintFilterRuleContextImpl({
ruleId: filterDescriptor.id,
sourceCode: sourceCode,
ignoreReport: ignoreReport,
configBaseDir: _this.configBaseDir,
sourceCode,
ignoreReport,
configBaseDir: this.configBaseDir,
severityLevel: getSeverity(filterDescriptor.normalizedOptions)
});
_this.tryToAddListenRule(filterDescriptor.filter, ruleContext, filterDescriptor.normalizedOptions);
this.tryToAddListenRule(filterDescriptor.filter, ruleContext, filterDescriptor.normalizedOptions);
});
};
return TextLintCoreTask;
}(CoreTask));
export default TextLintCoreTask;
}
}
//# sourceMappingURL=linter-task.js.map

@@ -6,27 +6,21 @@ // MIT © 2017 azu

import { EventEmitter } from "events";
var PromiseEventEmitter = /** @class */ (function () {
function PromiseEventEmitter() {
export class PromiseEventEmitter {
constructor() {
this.events = new EventEmitter();
this.events.setMaxListeners(0);
}
PromiseEventEmitter.prototype.listenerCount = function (type) {
listenerCount(type) {
return this.events.listenerCount(type);
};
PromiseEventEmitter.prototype.on = function (event, listener) {
}
on(event, listener) {
return this.events.on(event, listener);
};
PromiseEventEmitter.prototype.emit = function (event) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var promises = [];
this.events.listeners(event).forEach(function (listener) {
promises.push(listener.apply(void 0, args));
}
emit(event, ...args) {
const promises = [];
this.events.listeners(event).forEach((listener) => {
promises.push(listener(...args));
});
return Promise.all(promises);
};
return PromiseEventEmitter;
}());
export { PromiseEventEmitter };
}
}
//# sourceMappingURL=promise-event-emitter.js.map
// LICENSE : MIT
"use strict";
import CoreTask from "./textlint-core-task";
var TaskRunner = /** @class */ (function () {
function TaskRunner() {
}
export default class TaskRunner {
/**

@@ -12,12 +10,12 @@ * Task and return promise

*/
TaskRunner.process = function (task) {
return new Promise(function (resolve, reject) {
var messages = [];
task.on(CoreTask.events.message, function (message) {
static process(task) {
return new Promise((resolve, reject) => {
const messages = [];
task.on(CoreTask.events.message, (message) => {
messages.push(message);
});
task.on(CoreTask.events.error, function (error) {
task.on(CoreTask.events.error, (error) => {
reject(error);
});
task.on(CoreTask.events.complete, function () {
task.on(CoreTask.events.complete, () => {
task.removeAllListeners();

@@ -28,6 +26,4 @@ resolve(messages);

});
};
return TaskRunner;
}());
export default TaskRunner;
}
}
//# sourceMappingURL=task-runner.js.map
// LICENSE : MIT
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { TextlintRuleErrorImpl } from "../context/TextlintRuleErrorImpl";

@@ -29,11 +14,6 @@ import { PromiseEventEmitter } from "./promise-event-emitter";

import { Controller as TraverseController } from "@textlint/ast-traverse";
var traverseController = new TraverseController();
var debug = _debug("textlint:core-task");
var RuleTypeEmitter = /** @class */ (function (_super) {
__extends(RuleTypeEmitter, _super);
function RuleTypeEmitter() {
return _super !== null && _super.apply(this, arguments) || this;
}
return RuleTypeEmitter;
}(PromiseEventEmitter));
const traverseController = new TraverseController();
const debug = _debug("textlint:core-task");
class RuleTypeEmitter extends PromiseEventEmitter {
}
/**

@@ -43,33 +23,26 @@ * CoreTask receive AST and prepare, traverse AST, emit nodeType event!

*/
var TextLintCoreTask = /** @class */ (function (_super) {
__extends(TextLintCoreTask, _super);
function TextLintCoreTask() {
var _this = _super.call(this) || this;
_this.ruleTypeEmitter = new RuleTypeEmitter();
return _this;
export default class TextLintCoreTask extends EventEmitter {
constructor() {
super();
this.ruleTypeEmitter = new RuleTypeEmitter();
}
Object.defineProperty(TextLintCoreTask, "events", {
get: function () {
return {
// receive start event
start: "start",
// receive message from each rules
message: "message",
// receive complete event
complete: "complete",
// receive error event
error: "error"
};
},
enumerable: false,
configurable: true
});
TextLintCoreTask.prototype.createShouldIgnore = function () {
var _this = this;
var shouldIgnore = function (args) {
var ruleId = args.ruleId, range = args.range, optional = args.optional;
static get events() {
return {
// receive start event
start: "start",
// receive message from each rules
message: "message",
// receive complete event
complete: "complete",
// receive error event
error: "error"
};
}
createShouldIgnore() {
const shouldIgnore = (args) => {
const { ruleId, range, optional } = args;
assert.ok(typeof range[0] !== "undefined" && typeof range[1] !== "undefined" && range[0] >= 0 && range[1] >= 0, "ignoreRange should have actual range: " + range);
// FIXME: should have index, loc
// should be compatible with LintReportedMessage?
var message = {
const message = {
type: MessageType.ignore,

@@ -82,9 +55,8 @@ ruleId: ruleId,

};
_this.emit(TextLintCoreTask.events.message, message);
this.emit(TextLintCoreTask.events.message, message);
};
return shouldIgnore;
};
TextLintCoreTask.prototype.createReporter = function (sourceCode) {
var _this = this;
var sourceLocation = new SourceLocation(sourceCode);
}
createReporter(sourceCode) {
const sourceLocation = new SourceLocation(sourceCode);
/**

@@ -94,13 +66,13 @@ * push new RuleError to results

*/
var reportFunction = function (reportArgs) {
var ruleId = reportArgs.ruleId, severity = reportArgs.severity, ruleError = reportArgs.ruleError;
const reportFunction = (reportArgs) => {
const { ruleId, severity, ruleError } = reportArgs;
debug("%s pushReport %s", ruleId, ruleError);
var _a = sourceLocation.adjust(reportArgs), line = _a.line, column = _a.column, fix = _a.fix;
var index = sourceCode.positionToIndex({ line: line, column: column });
const { line, column, fix } = sourceLocation.adjust(reportArgs);
const index = sourceCode.positionToIndex({ line, column });
// add TextLintMessage
var message = {
const message = {
type: MessageType.lint,
ruleId: ruleId,
message: ruleError.message,
index: index,
index,
// See https://github.com/textlint/textlint/blob/master/typing/textlint.d.ts

@@ -115,9 +87,9 @@ line: line,

// `error` is a any data.
var data = ruleError;
const data = ruleError;
message.data = data;
}
_this.emit(TextLintCoreTask.events.message, message);
this.emit(TextLintCoreTask.events.message, message);
};
return reportFunction;
};
}
/**

@@ -128,20 +100,19 @@ * start process and emitting events.

*/
TextLintCoreTask.prototype.startTraverser = function (sourceCode) {
var _this = this;
startTraverser(sourceCode) {
this.emit(TextLintCoreTask.events.start);
var promiseQueue = [];
var ruleTypeEmitter = this.ruleTypeEmitter;
const promiseQueue = [];
const ruleTypeEmitter = this.ruleTypeEmitter;
traverseController.traverse(sourceCode.ast, {
enter: function (node, parent) {
var type = node.type;
enter(node, parent) {
const type = node.type;
Object.defineProperty(node, "parent", { value: parent });
if (ruleTypeEmitter.listenerCount(type) > 0) {
var promise = ruleTypeEmitter.emit(type, node);
const promise = ruleTypeEmitter.emit(type, node);
promiseQueue.push(promise);
}
},
leave: function (node) {
var type = node.type + ":exit";
leave(node) {
const type = `${node.type}:exit`;
if (ruleTypeEmitter.listenerCount(type) > 0) {
var promise = ruleTypeEmitter.emit(type, node);
const promise = ruleTypeEmitter.emit(type, node);
promiseQueue.push(promise);

@@ -152,13 +123,13 @@ }

Promise.all(promiseQueue)
.then(function () {
_this.emit(TextLintCoreTask.events.complete);
.then(() => {
this.emit(TextLintCoreTask.events.complete);
})
.catch(function (error) {
_this.emit(TextLintCoreTask.events.error, error);
.catch((error) => {
this.emit(TextLintCoreTask.events.error, error);
});
};
}
/**
* try to get rule object
*/
TextLintCoreTask.prototype.tryToGetRuleObject = function (ruleCreator, ruleContext, ruleOptions) {
tryToGetRuleObject(ruleCreator, ruleContext, ruleOptions) {
try {

@@ -168,10 +139,10 @@ return ruleCreator(ruleContext, ruleOptions);

catch (error) {
error.message = "Error while loading rule '" + ruleContext.id + "': " + error.message;
error.message = `Error while loading rule '${ruleContext.id}': ${error.message}`;
throw error;
}
};
}
/**
* try to get filter rule object
*/
TextLintCoreTask.prototype.tryToGetFilterRuleObject = function (ruleCreator, ruleContext, ruleOptions) {
tryToGetFilterRuleObject(ruleCreator, ruleContext, ruleOptions) {
try {

@@ -181,6 +152,6 @@ return ruleCreator(ruleContext, ruleOptions);

catch (error) {
error.message = "Error while loading filter rule '" + ruleContext.id + "': " + error.message;
error.message = `Error while loading filter rule '${ruleContext.id}': ${error.message}`;
throw error;
}
};
}
/**

@@ -193,15 +164,12 @@ * add all the node types as listeners of the rule

*/
TextLintCoreTask.prototype.tryToAddListenRule = function (ruleCreator, ruleContext, ruleOptions) {
var _this = this;
var ruleObject = ruleContext instanceof TextlintRuleContextImpl
tryToAddListenRule(ruleCreator, ruleContext, ruleOptions) {
const ruleObject = ruleContext instanceof TextlintRuleContextImpl
? this.tryToGetRuleObject(ruleCreator, ruleContext, ruleOptions)
: this.tryToGetFilterRuleObject(ruleCreator, ruleContext, ruleOptions);
var types = Object.keys(ruleObject);
types.forEach(function (nodeType) {
_this.ruleTypeEmitter.on(nodeType, timing.enabled ? timing.time(ruleContext.id, ruleObject[nodeType]) : ruleObject[nodeType]);
const types = Object.keys(ruleObject);
types.forEach((nodeType) => {
this.ruleTypeEmitter.on(nodeType, timing.enabled ? timing.time(ruleContext.id, ruleObject[nodeType]) : ruleObject[nodeType]);
});
};
return TextLintCoreTask;
}(EventEmitter));
export default TextLintCoreTask;
}
}
//# sourceMappingURL=textlint-core-task.js.map

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

import _debug from "debug";
var debug = _debug("textlint:kernel");
const debug = _debug("textlint:kernel");
/**

@@ -29,3 +29,4 @@ * add fileName to trailing of error message

}
return message + "\nat " + fileName;
return `${message}
at ${fileName}`;
}

@@ -44,8 +45,7 @@ /**

*/
var TextlintKernel = /** @class */ (function () {
export class TextlintKernel {
/**
* @param config
*/
function TextlintKernel(config) {
if (config === void 0) { config = {}; }
constructor(config = {}) {
// this.config often is undefined.

@@ -70,6 +70,5 @@ this.config = config;

*/
TextlintKernel.prototype.lintText = function (text, options) {
var _this = this;
return Promise.resolve().then(function () {
var descriptor = new TextlintKernelDescriptor({
lintText(text, options) {
return Promise.resolve().then(() => {
const descriptor = new TextlintKernelDescriptor({
rules: options.rules || [],

@@ -79,9 +78,9 @@ filterRules: options.filterRules || [],

});
return _this._parallelProcess({
descriptor: descriptor,
text: text,
options: options
return this._parallelProcess({
descriptor,
text,
options
});
});
};
}
/**

@@ -93,6 +92,5 @@ * fix texts and return fix result object

*/
TextlintKernel.prototype.fixText = function (text, options) {
var _this = this;
return Promise.resolve().then(function () {
var descriptor = new TextlintKernelDescriptor({
fixText(text, options) {
return Promise.resolve().then(() => {
const descriptor = new TextlintKernelDescriptor({
rules: options.rules || [],

@@ -102,9 +100,9 @@ filterRules: options.filterRules || [],

});
return _this._sequenceProcess({
descriptor: descriptor,
options: options,
text: text
return this._sequenceProcess({
descriptor,
options,
text
});
});
};
}
/**

@@ -119,25 +117,24 @@ * process text in parallel for Rules and return {Promise.<TextLintResult>}

*/
TextlintKernel.prototype._parallelProcess = function (_a) {
var descriptor = _a.descriptor, text = _a.text, options = _a.options;
var ext = options.ext, filePath = options.filePath, configBaseDir = options.configBaseDir;
var plugin = descriptor.findPluginDescriptorWithExt(ext);
_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);
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
var processor = plugin.processor;
var _b = processor.processor(ext), preProcess = _b.preProcess, postProcess = _b.postProcess;
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", "processor should implements {preProcess, postProcess}");
var preProcessResult = preProcess(text, filePath);
var isPluginReturnAnAST = isTxtAST(preProcessResult);
var textForAST = isPluginReturnAnAST ? text : preProcessResult.text;
var ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
var sourceCode = new TextlintSourceCodeImpl({
const preProcessResult = preProcess(text, filePath);
const isPluginReturnAnAST = isTxtAST(preProcessResult);
const textForAST = isPluginReturnAnAST ? text : preProcessResult.text;
const ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
const sourceCode = new TextlintSourceCodeImpl({
text: textForAST,
ast: ast,
ext: ext,
filePath: filePath
ast,
ext,
filePath
});
var linterProcessor = new LinterProcessor(processor, this.messageProcessManager);
const linterProcessor = new LinterProcessor(processor, this.messageProcessManager);
return linterProcessor

@@ -148,10 +145,10 @@ .process({

filterRuleDescriptors: descriptor.filterRule,
sourceCode: sourceCode,
configBaseDir: configBaseDir
sourceCode,
configBaseDir
})
.catch(function (error) {
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
};
}
/**

@@ -166,25 +163,24 @@ * process text in series for Rules and return {Promise.<TextlintFixResult>}

*/
TextlintKernel.prototype._sequenceProcess = function (_a) {
var descriptor = _a.descriptor, text = _a.text, options = _a.options;
var ext = options.ext, filePath = options.filePath, configBaseDir = options.configBaseDir;
var plugin = descriptor.findPluginDescriptorWithExt(ext);
_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);
throw new Error(`Not found available plugin for ${ext}`);
}
debug("use plugin: %s", plugin.id);
var processor = plugin.processor;
var _b = processor.processor(ext), preProcess = _b.preProcess, postProcess = _b.postProcess;
const processor = plugin.processor;
const { preProcess, postProcess } = processor.processor(ext);
assert.ok(typeof preProcess === "function" && typeof postProcess === "function", "processor should implements {preProcess, postProcess}");
var preProcessResult = preProcess(text, filePath);
var isPluginReturnAnAST = isTxtAST(preProcessResult);
var textForAST = isPluginReturnAnAST ? text : preProcessResult.text;
var ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
var sourceCode = new TextlintSourceCodeImpl({
const preProcessResult = preProcess(text, filePath);
const isPluginReturnAnAST = isTxtAST(preProcessResult);
const textForAST = isPluginReturnAnAST ? text : preProcessResult.text;
const ast = isPluginReturnAnAST ? preProcessResult : preProcessResult.ast;
const sourceCode = new TextlintSourceCodeImpl({
text: textForAST,
ast: ast,
ext: ext,
filePath: filePath
ast,
ext,
filePath
});
var fixerProcessor = new FixerProcessor(processor, this.messageProcessManager);
const fixerProcessor = new FixerProcessor(processor, this.messageProcessManager);
return fixerProcessor

@@ -195,13 +191,11 @@ .process({

filterRules: descriptor.filterRule,
sourceCode: sourceCode,
configBaseDir: configBaseDir
sourceCode,
configBaseDir
})
.catch(function (error) {
.catch((error) => {
error.message = addingAtFileNameToError(filePath, error.message);
return Promise.reject(error);
});
};
return TextlintKernel;
}());
export { TextlintKernel };
}
}
//# sourceMappingURL=textlint-kernel.js.map

@@ -9,29 +9,13 @@ // LICENSE : MIT

*/
var Logger = /** @class */ (function () {
function Logger() {
export default class Logger {
static log(...message) {
console.log(...message);
}
Logger.log = function () {
var message = [];
for (var _i = 0; _i < arguments.length; _i++) {
message[_i] = arguments[_i];
}
console.log.apply(console, message);
};
Logger.warn = function () {
var message = [];
for (var _i = 0; _i < arguments.length; _i++) {
message[_i] = arguments[_i];
}
console.warn.apply(console, message);
};
Logger.error = function () {
var message = [];
for (var _i = 0; _i < arguments.length; _i++) {
message[_i] = arguments[_i];
}
console.error.apply(console, message);
};
return Logger;
}());
export default Logger;
static warn(...message) {
console.warn(...message);
}
static error(...message) {
console.error(...message);
}
}
//# sourceMappingURL=logger.js.map

@@ -32,5 +32,5 @@ /**

}
var enabled = Boolean(process.env.TIMING);
var HEADERS = ["Rule", "Time (ms)", "Relative"];
var ALIGN = [alignLeft, alignRight, alignRight];
const enabled = Boolean(process.env.TIMING);
const HEADERS = ["Rule", "Time (ms)", "Relative"];
const ALIGN = [alignLeft, alignRight, alignRight];
/* istanbul ignore next */

@@ -44,6 +44,6 @@ /**

function display(data) {
var total = 0;
var rows = Object.keys(data)
let total = 0;
const rows = Object.keys(data)
.map(function (key) {
var time = data[key];
const time = data[key];
total += time;

@@ -61,6 +61,6 @@ return [key, time];

rows.unshift(HEADERS);
var widths = [];
const widths = [];
rows.forEach(function (row) {
for (var i = 0; i < row.length; i++) {
var n = row[i].length;
for (let i = 0; i < row.length; i++) {
const n = row[i].length;
if (!widths[i] || n > widths[i]) {

@@ -71,3 +71,3 @@ widths[i] = n;

});
var table = rows.map(function (row) {
const table = rows.map(function (row) {
return row

@@ -91,3 +91,3 @@ .map(function (cell, index) {

export default (function () {
var data = Object.create(null);
const data = Object.create(null);
/**

@@ -105,3 +105,3 @@ * Time the run

return function () {
var t = process.hrtime();
let t = process.hrtime();
fn.apply(null, Array.prototype.slice.call(arguments));

@@ -108,0 +108,0 @@ t = process.hrtime(t);

{
"name": "@textlint/kernel",
"version": "12.0.0-beta.0",
"version": "12.0.0-beta.1",
"description": "textlint kernel is core logic by pure JavaScript.",

@@ -38,9 +38,9 @@ "keywords": [

"dependencies": {
"@textlint/ast-node-types": "^12.0.0-beta.0",
"@textlint/ast-tester": "^12.0.0-beta.0",
"@textlint/ast-traverse": "^12.0.0-beta.0",
"@textlint/feature-flag": "^12.0.0-beta.0",
"@textlint/source-code-fixer": "^12.0.0-beta.0",
"@textlint/types": "^12.0.0-beta.0",
"@textlint/utils": "^12.0.0-beta.0",
"@textlint/ast-node-types": "^12.0.0-beta.1",
"@textlint/ast-tester": "^12.0.0-beta.1",
"@textlint/ast-traverse": "^12.0.0-beta.1",
"@textlint/feature-flag": "^12.0.0-beta.1",
"@textlint/source-code-fixer": "^12.0.0-beta.1",
"@textlint/types": "^12.0.0-beta.1",
"@textlint/utils": "^12.0.0-beta.1",
"debug": "^4.3.1",

@@ -52,3 +52,3 @@ "deep-equal": "^1.1.1",

"devDependencies": {
"@textlint/markdown-to-ast": "^12.0.0-beta.0",
"@textlint/markdown-to-ast": "^12.0.0-beta.1",
"@types/debug": "^4.1.5",

@@ -69,3 +69,3 @@ "@types/deep-equal": "^1.0.1",

},
"gitHead": "1e0d0d7f628be0bfce04b6cd36fcc8390ca43096"
"gitHead": "2856b387cfb0a151655a809e8253b242e7b90725"
}

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

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

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

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