Files
react-native-devtools-frontend/node_modules/stylelint/lib/utils/validateObjectWithArrayProps.js
T
Tim van der Lippe efb716af67 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>
2020-12-01 16:04:40 +00:00

44 lines
959 B
JavaScript

'use strict';
const _ = require('lodash');
/**
* @template T
* @typedef {(i: T) => boolean} Validator
*/
/**
* Check whether the variable is an object and all it's properties are arrays of string values:
*
* ignoreProperties = {
* value1: ["item11", "item12", "item13"],
* value2: ["item21", "item22", "item23"],
* value3: ["item31", "item32", "item33"],
* }
* @template T
* @param {Validator<T>|Validator<T>[]} validator
* @returns {(value: {[k: any]: T|T[]}) => boolean}
*/
module.exports = (validator) => (value) => {
if (!_.isPlainObject(value)) {
return false;
}
// TODO: Issue #4985
// eslint-disable-next-line no-shadow
return Object.values(value).every((value) => {
if (!Array.isArray(value)) {
return false;
}
// Make sure the array items are strings
return value.every((item) => {
if (Array.isArray(validator)) {
return validator.some((v) => v(item));
}
return validator(item);
});
});
};