Reland "Reland "Update stylelint to 14.0.1""

This reverts commit 2b4a9df2d922bb9d183fe2f816da40dda2e87790.

Reason for revert: subsequent presubmit uploads should be fixed now.

Original change's description:
> Revert "Reland "Update stylelint to 14.0.1""
>
> This reverts commit f2ea2c940dd62b3295047e03959c89c237e216c8.
>
> Reason for revert: https://ci.chromium.org/ui/p/devtools-frontend/builders/try/dtf_presubmit_linux/b8831129368825517985/overview
>
> Original change's description:
> > Reland "Update stylelint to 14.0.1"
> >
> > This reverts commit 6c0f161c95acd70706aeed4e1167ab1c28f88eee.
> >
> > Reason for revert: the prerequisite CL (https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3259703) has landed
> >
> > Original change's description:
> > > Revert "Update stylelint to 14.0.1"
> > >
> > > This reverts commit 1e08ee816bab192a7d295d2f457be97bd88c09c1.
> > >
> > > Reason for revert: tree is closed due to errors https://ci.chromium.org/ui/p/devtools-frontend/builders/ci/Stand-alone%20Linux/8169/overview
> > >
> > > Original change's description:
> > > > Update stylelint to 14.0.1
> > > >
> > > > This also upgrades PostCSS to 8.3.11.
> > > >
> > > > DISABLE_THIRD_PARTY_CHECK=Updating Stylelint configuration
> > > > R=​szuend@chromium.org
> > > >
> > > > Bug: none
> > > > Change-Id: I606540b03509d7c6e73f3d490327cd4174e03d31
> > > > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3259541
> > > > Reviewed-by: Simon Zünd <szuend@chromium.org>
> > > > Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
> > >
> > > Bug: none
> > > Change-Id: Icb1c02b41dbccc3b4fc5760f5dd0b78eca078b61
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3263399
> > > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> > > Owners-Override: Alex Rudenko <alexrudenko@chromium.org>
> > > Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
> >
> > DISABLE_THIRD_PARTY_CHECK=Updating Stylelint configuration
> >
> > Bug: none
> > Change-Id: If132a67ee4253d27114caedd66c5ee61c774a6c7
> > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3264206
> > Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
> > Reviewed-by: Simon Zünd <szuend@chromium.org>
> > Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
>
> Bug: none
> Change-Id: Idc6c9f5cc1e225c752799461eb0344e94b4ad1e5
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3264222
> Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>

DISABLE_THIRD_PARTY_CHECK=Updating Stylelint configuration

Bug: none
Change-Id: I609941d48b46bfcf454b03dcc75a76d460fbe674
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3264223
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
diff --git a/node_modules/stylelint/lib/utils/validateOptions.js b/node_modules/stylelint/lib/utils/validateOptions.js
index 0d06ae4..12cc139 100644
--- a/node_modules/stylelint/lib/utils/validateOptions.js
+++ b/node_modules/stylelint/lib/utils/validateOptions.js
@@ -1,10 +1,13 @@
 'use strict';
 
-const _ = require('lodash');
+const arrayEqual = require('./arrayEqual');
+const { isPlainObject } = require('is-plain-object');
 
-const IGNORED_OPTIONS = new Set(['severity', 'message', 'reportDisables']);
+const IGNORED_OPTIONS = new Set(['severity', 'message', 'reportDisables', 'disableFix']);
 
-/** @typedef {{possible: any, actual: any, optional?: boolean}} Options */
+/** @typedef {import('stylelint').RuleOptions} RuleOptions */
+/** @typedef {import('stylelint').RuleOptionsPossible} Possible */
+/** @typedef {import('stylelint').RuleOptionsPossibleFunc} PossibleFunc */
 
 /**
  * Validate a rule's options.
@@ -13,7 +16,7 @@
  *
  * @param {import('stylelint').PostcssResult} result - postcss result
  * @param {string} ruleName
- * @param {...Options} optionDescriptions - Each optionDescription can
+ * @param {...RuleOptions} optionDescriptions - Each optionDescription can
  *   have the following properties:
  *   - `actual` (required): the actual passed option value or object.
  *   - `possible` (required): a schema representation of what values are
@@ -26,8 +29,7 @@
  *    - `optional` (optional): If this is `true`, `actual` can be undefined.
  * @return {boolean} Whether or not the options are valid (true = valid)
  */
-
-module.exports = function (result, ruleName, ...optionDescriptions) {
+function validateOptions(result, ruleName, ...optionDescriptions) {
 	let noErrors = true;
 
 	optionDescriptions.forEach((optionDescription) => {
@@ -42,23 +44,28 @@
 		result.warn(message, {
 			stylelintType: 'invalidOption',
 		});
-		_.set(result, 'stylelint.stylelintError', true);
+		result.stylelint = result.stylelint || {
+			disabledRanges: {},
+			ruleSeverities: {},
+			customMessages: {},
+		};
+		result.stylelint.stylelintError = true;
 	}
 
 	return noErrors;
-};
+}
 
 /**
- * @param {Options} opts
+ * @param {RuleOptions} opts
  * @param {string} ruleName
- * @param {(s: string) => void} complain
+ * @param {(message: string) => void} complain
  */
 function validate(opts, ruleName, complain) {
 	const possible = opts.possible;
 	const actual = opts.actual;
 	const optional = opts.optional;
 
-	if (actual === null || _.isEqual(actual, [null])) {
+	if (actual === null || arrayEqual(actual, [null])) {
 		return;
 	}
 
@@ -93,8 +100,7 @@
 		return;
 	}
 
-	// If `possible` is a function ...
-	if (_.isFunction(possible)) {
+	if (typeof possible === 'function') {
 		if (!possible(actual)) {
 			complain(`Invalid option "${JSON.stringify(actual)}" for rule ${ruleName}`);
 		}
@@ -103,20 +109,20 @@
 	}
 
 	// If `possible` is an array instead of an object ...
-	if (!_.isPlainObject(possible)) {
-		[].concat(actual).forEach((a) => {
+	if (Array.isArray(possible)) {
+		for (const a of [actual].flat()) {
 			if (isValid(possible, a)) {
-				return;
+				continue;
 			}
 
 			complain(`Invalid option value "${String(a)}" for rule "${ruleName}"`);
-		});
+		}
 
 		return;
 	}
 
 	// If actual is NOT an object ...
-	if (typeof actual !== 'object') {
+	if (!isPlainObject(actual) || typeof actual !== 'object' || actual == null) {
 		complain(
 			`Invalid option value ${JSON.stringify(actual)} for rule "${ruleName}": should be an object`,
 		);
@@ -124,38 +130,36 @@
 		return;
 	}
 
-	Object.keys(actual).forEach((optionName) => {
+	for (const [optionName, optionValue] of Object.entries(actual)) {
 		if (IGNORED_OPTIONS.has(optionName)) {
-			return;
+			continue;
 		}
 
-		if (!possible[optionName]) {
+		const possibleValue = possible && possible[optionName];
+
+		if (!possibleValue) {
 			complain(`Invalid option name "${optionName}" for rule "${ruleName}"`);
 
-			return;
+			continue;
 		}
 
-		const actualOptionValue = actual[optionName];
-
-		[].concat(actualOptionValue).forEach((a) => {
-			if (isValid(possible[optionName], a)) {
-				return;
+		for (const a of [optionValue].flat()) {
+			if (isValid(possibleValue, a)) {
+				continue;
 			}
 
 			complain(`Invalid value "${a}" for option "${optionName}" of rule "${ruleName}"`);
-		});
-	});
+		}
+	}
 }
 
 /**
- * @param {any|Function} possible
- * @param {any} actual
+ * @param {Possible | Possible[]} possible
+ * @param {unknown} actual
  * @returns {boolean}
  */
 function isValid(possible, actual) {
-	const possibleList = /** @type {Array<any|Function>} */ ([]).concat(possible);
-
-	for (const possibility of possibleList) {
+	for (const possibility of [possible].flat()) {
 		if (typeof possibility === 'function' && possibility(actual)) {
 			return true;
 		}
@@ -167,3 +171,5 @@
 
 	return false;
 }
+
+module.exports = /** @type {typeof import('stylelint').utils.validateOptions} */ (validateOptions);