Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/lib/linter/report-translator.js')
-rw-r--r--tools/node_modules/eslint/lib/linter/report-translator.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/lib/linter/report-translator.js b/tools/node_modules/eslint/lib/linter/report-translator.js
index bed5af81e5d..75005c16e58 100644
--- a/tools/node_modules/eslint/lib/linter/report-translator.js
+++ b/tools/node_modules/eslint/lib/linter/report-translator.js
@@ -116,6 +116,17 @@ function normalizeReportLoc(descriptor) {
}
/**
+ * Check that a fix has a valid range.
+ * @param {Fix|null} fix The fix to validate.
+ * @returns {void}
+ */
+function assertValidFix(fix) {
+ if (fix) {
+ assert(fix.range && typeof fix.range[0] === "number" && typeof fix.range[1] === "number", `Fix has invalid range: ${JSON.stringify(fix, null, 2)}`);
+ }
+}
+
+/**
* Compares items in a fixes array by range.
* @param {Fix} a The first message.
* @param {Fix} b The second message.
@@ -133,6 +144,10 @@ function compareFixesByRange(a, b) {
* @returns {{text: string, range: number[]}} The merged fixes
*/
function mergeFixes(fixes, sourceCode) {
+ for (const fix of fixes) {
+ assertValidFix(fix);
+ }
+
if (fixes.length === 0) {
return null;
}
@@ -181,6 +196,8 @@ function normalizeFixes(descriptor, sourceCode) {
if (fix && Symbol.iterator in fix) {
return mergeFixes(Array.from(fix), sourceCode);
}
+
+ assertValidFix(fix);
return fix;
}