return descriptor.node.loc;
}
+/**
+ * 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.
* @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;
}
if (fix && Symbol.iterator in fix) {
return mergeFixes(Array.from(fix), sourceCode);
}
+
+ assertValidFix(fix);
return fix;
}