Update linter packages

- Updates stylelint to 13.8.0
- Updates ESLint to 7.14.0
- Updates @typescript-eslint to 4.9.0

DISABLE_THIRD_PARTY_CHECK=NPM update
R=jacktfranklin@chromium.org

Change-Id: I207e204607ede782710e042c17d6510c7f696905
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2566806
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
diff --git a/node_modules/stylelint/lib/assignDisabledRanges.js b/node_modules/stylelint/lib/assignDisabledRanges.js
index f33611d..71f81af 100644
--- a/node_modules/stylelint/lib/assignDisabledRanges.js
+++ b/node_modules/stylelint/lib/assignDisabledRanges.js
@@ -9,25 +9,29 @@
 const disableNextLineCommand = `${COMMAND_PREFIX}disable-next-line`;
 const ALL_RULES = 'all';
 
-/** @typedef {import('postcss').Comment} PostcssComment */
+/** @typedef {import('postcss/lib/comment')} PostcssComment */
 /** @typedef {import('postcss').Root} PostcssRoot */
 /** @typedef {import('stylelint').PostcssResult} PostcssResult */
 /** @typedef {import('stylelint').DisabledRangeObject} DisabledRangeObject */
 /** @typedef {import('stylelint').DisabledRange} DisabledRange */
 
 /**
+ * @param {PostcssComment} comment
  * @param {number} start
  * @param {boolean} strictStart
+ * @param {string|undefined} description
  * @param {number} [end]
  * @param {boolean} [strictEnd]
  * @returns {DisabledRange}
  */
-function createDisableRange(start, strictStart, end, strictEnd) {
+function createDisableRange(comment, start, strictStart, description, end, strictEnd) {
 	return {
+		comment,
 		start,
 		end: end || undefined,
 		strictStart,
 		strictEnd: typeof strictEnd === 'boolean' ? strictEnd : undefined,
+		description,
 	};
 }
 
@@ -53,19 +57,96 @@
 	};
 
 	result.stylelint.disabledRanges = disabledRanges;
-	root.walkComments(checkComment);
+
+	// Work around postcss/postcss-scss#109 by merging adjacent `//` comments
+	// into a single node before passing to `checkComment`.
+
+	/** @type {PostcssComment?} */
+	let inlineEnd;
+
+	root.walkComments((/** @type {PostcssComment} */ comment) => {
+		if (inlineEnd) {
+			// Ignore comments already processed by grouping with a previous one.
+			if (inlineEnd === comment) inlineEnd = null;
+
+			return;
+		}
+
+		const next = comment.next();
+
+		// If any of these conditions are not met, do not merge comments.
+		if (
+			!(
+				isInlineComment(comment) &&
+				isStylelintCommand(comment) &&
+				next &&
+				next.type === 'comment' &&
+				(comment.text.includes('--') || next.text.startsWith('--'))
+			)
+		) {
+			checkComment(comment);
+
+			return;
+		}
+
+		let lastLine = (comment.source && comment.source.end && comment.source.end.line) || 0;
+		const fullComment = comment.clone();
+
+		/** @type {PostcssComment} */
+		let current = next;
+
+		while (isInlineComment(current) && !isStylelintCommand(current)) {
+			const currentLine = (current.source && current.source.end && current.source.end.line) || 0;
+
+			if (lastLine + 1 !== currentLine) break;
+
+			fullComment.text += `\n${current.text}`;
+
+			if (fullComment.source && current.source) {
+				fullComment.source.end = current.source.end;
+			}
+
+			inlineEnd = current;
+			// TODO: Issue #4985
+			// eslint-disable-next-line no-shadow
+			const next = current.next();
+
+			if (!next || next.type !== 'comment') break;
+
+			current = next;
+			lastLine = currentLine;
+		}
+		checkComment(fullComment);
+	});
 
 	return result;
 
 	/**
 	 * @param {PostcssComment} comment
 	 */
+	function isInlineComment(comment) {
+		// We check both here because the Sass parser uses `raws.inline` to indicate
+		// inline comments, while the Less parser uses `inline`.
+		return comment.inline || comment.raws.inline;
+	}
+
+	/**
+	 * @param {PostcssComment} comment
+	 */
+	function isStylelintCommand(comment) {
+		return comment.text.startsWith(disableCommand) || comment.text.startsWith(enableCommand);
+	}
+
+	/**
+	 * @param {PostcssComment} comment
+	 */
 	function processDisableLineCommand(comment) {
 		if (comment.source && comment.source.start) {
 			const line = comment.source.start.line;
+			const description = getDescription(comment.text);
 
 			getCommandRules(disableLineCommand, comment.text).forEach((ruleName) => {
-				disableLine(line, ruleName, comment);
+				disableLine(comment, line, ruleName, description);
 			});
 		}
 	}
@@ -74,21 +155,23 @@
 	 * @param {PostcssComment} comment
 	 */
 	function processDisableNextLineCommand(comment) {
-		if (comment.source && comment.source.start) {
-			const line = comment.source.start.line;
+		if (comment.source && comment.source.end) {
+			const line = comment.source.end.line;
+			const description = getDescription(comment.text);
 
 			getCommandRules(disableNextLineCommand, comment.text).forEach((ruleName) => {
-				disableLine(line + 1, ruleName, comment);
+				disableLine(comment, line + 1, ruleName, description);
 			});
 		}
 	}
 
 	/**
+	 * @param {PostcssComment} comment
 	 * @param {number} line
 	 * @param {string} ruleName
-	 * @param {PostcssComment} comment
+	 * @param {string|undefined} description
 	 */
-	function disableLine(line, ruleName, comment) {
+	function disableLine(comment, line, ruleName, description) {
 		if (ruleIsDisabled(ALL_RULES)) {
 			throw comment.error('All rules have already been disabled', {
 				plugin: 'stylelint',
@@ -101,7 +184,7 @@
 
 				const strict = disabledRuleName === ALL_RULES;
 
-				startDisabledRange(line, disabledRuleName, strict);
+				startDisabledRange(comment, line, disabledRuleName, strict, description);
 				endDisabledRange(line, disabledRuleName, strict);
 			});
 		} else {
@@ -111,7 +194,7 @@
 				});
 			}
 
-			startDisabledRange(line, ruleName, true);
+			startDisabledRange(comment, line, ruleName, true, description);
 			endDisabledRange(line, ruleName, true);
 		}
 	}
@@ -120,6 +203,8 @@
 	 * @param {PostcssComment} comment
 	 */
 	function processDisableCommand(comment) {
+		const description = getDescription(comment.text);
+
 		getCommandRules(disableCommand, comment.text).forEach((ruleToDisable) => {
 			const isAllRules = ruleToDisable === ALL_RULES;
 
@@ -139,10 +224,10 @@
 
 				if (isAllRules) {
 					Object.keys(disabledRanges).forEach((ruleName) => {
-						startDisabledRange(line, ruleName, ruleName === ALL_RULES);
+						startDisabledRange(comment, line, ruleName, ruleName === ALL_RULES, description);
 					});
 				} else {
-					startDisabledRange(line, ruleToDisable, true);
+					startDisabledRange(comment, line, ruleToDisable, true, description);
 				}
 			}
 		});
@@ -182,8 +267,8 @@
 			if (ruleIsDisabled(ALL_RULES) && disabledRanges[ruleToEnable] === undefined) {
 				// Get a starting point from the where all rules were disabled
 				if (!disabledRanges[ruleToEnable]) {
-					disabledRanges[ruleToEnable] = disabledRanges.all.map(({ start, end }) =>
-						createDisableRange(start, false, end, false),
+					disabledRanges[ruleToEnable] = disabledRanges.all.map(({ start, end, description }) =>
+						createDisableRange(comment, start, false, description, end, false),
 					);
 				} else {
 					const range = _.last(disabledRanges[ALL_RULES]);
@@ -241,6 +326,8 @@
 	function getCommandRules(command, fullText) {
 		const rules = fullText
 			.slice(command.length)
+			.split(/\s-{2,}\s/u)[0] // Allow for description (f.e. /* stylelint-disable a, b -- Description */).
+			.trim()
 			.split(',')
 			.filter(Boolean)
 			.map((r) => r.trim());
@@ -253,12 +340,26 @@
 	}
 
 	/**
+	 * @param {string} fullText
+	 * @returns {string|undefined}
+	 */
+	function getDescription(fullText) {
+		const descriptionStart = fullText.indexOf('--');
+
+		if (descriptionStart === -1) return;
+
+		return fullText.slice(descriptionStart + 2).trim();
+	}
+
+	/**
+	 * @param {PostcssComment} comment
 	 * @param {number} line
 	 * @param {string} ruleName
 	 * @param {boolean} strict
+	 * @param {string|undefined} description
 	 */
-	function startDisabledRange(line, ruleName, strict) {
-		const rangeObj = createDisableRange(line, strict);
+	function startDisabledRange(comment, line, ruleName, strict, description) {
+		const rangeObj = createDisableRange(comment, line, strict, description);
 
 		ensureRuleRanges(ruleName);
 		disabledRanges[ruleName].push(rangeObj);
@@ -286,8 +387,8 @@
 	 */
 	function ensureRuleRanges(ruleName) {
 		if (!disabledRanges[ruleName]) {
-			disabledRanges[ruleName] = disabledRanges.all.map(({ start, end }) =>
-				createDisableRange(start, false, end, false),
+			disabledRanges[ruleName] = disabledRanges.all.map(({ comment, start, end, description }) =>
+				createDisableRange(comment, start, false, description, end, false),
 			);
 		}
 	}