mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 20:39:31 +08:00
This reverts commit2b4a9df2d9. Reason for revert: subsequent presubmit uploads should be fixed now. Original change's description: > Revert "Reland "Update stylelint to 14.0.1"" > > This reverts commitf2ea2c940d. > > 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 commit6c0f161c95. > > > > 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 commit1e08ee816b. > > > > > > 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>
158 lines
6.3 KiB
JavaScript
158 lines
6.3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
|
|
const path = require("path");
|
|
const globParent = require("glob-parent");
|
|
const micromatch = require("micromatch");
|
|
const GLOBSTAR = '**';
|
|
const ESCAPE_SYMBOL = '\\';
|
|
const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
|
|
const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[.*]/;
|
|
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\(.*\|.*\)/;
|
|
const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
|
|
const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;
|
|
function isStaticPattern(pattern, options = {}) {
|
|
return !isDynamicPattern(pattern, options);
|
|
}
|
|
exports.isStaticPattern = isStaticPattern;
|
|
function isDynamicPattern(pattern, options = {}) {
|
|
/**
|
|
* A special case with an empty string is necessary for matching patterns that start with a forward slash.
|
|
* An empty string cannot be a dynamic pattern.
|
|
* For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
|
|
*/
|
|
if (pattern === '') {
|
|
return false;
|
|
}
|
|
/**
|
|
* When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
|
|
* filepath directly (without read directory).
|
|
*/
|
|
if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
|
|
return true;
|
|
}
|
|
if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
|
|
return true;
|
|
}
|
|
if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
|
|
return true;
|
|
}
|
|
if (options.braceExpansion !== false && BRACE_EXPANSIONS_SYMBOLS_RE.test(pattern)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
exports.isDynamicPattern = isDynamicPattern;
|
|
function convertToPositivePattern(pattern) {
|
|
return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
|
|
}
|
|
exports.convertToPositivePattern = convertToPositivePattern;
|
|
function convertToNegativePattern(pattern) {
|
|
return '!' + pattern;
|
|
}
|
|
exports.convertToNegativePattern = convertToNegativePattern;
|
|
function isNegativePattern(pattern) {
|
|
return pattern.startsWith('!') && pattern[1] !== '(';
|
|
}
|
|
exports.isNegativePattern = isNegativePattern;
|
|
function isPositivePattern(pattern) {
|
|
return !isNegativePattern(pattern);
|
|
}
|
|
exports.isPositivePattern = isPositivePattern;
|
|
function getNegativePatterns(patterns) {
|
|
return patterns.filter(isNegativePattern);
|
|
}
|
|
exports.getNegativePatterns = getNegativePatterns;
|
|
function getPositivePatterns(patterns) {
|
|
return patterns.filter(isPositivePattern);
|
|
}
|
|
exports.getPositivePatterns = getPositivePatterns;
|
|
/**
|
|
* Returns patterns that can be applied inside the current directory.
|
|
*
|
|
* @example
|
|
* // ['./*', '*', 'a/*']
|
|
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
|
*/
|
|
function getPatternsInsideCurrentDirectory(patterns) {
|
|
return patterns.filter((pattern) => !isPatternRelatedToParentDirectory(pattern));
|
|
}
|
|
exports.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
|
|
/**
|
|
* Returns patterns to be expanded relative to (outside) the current directory.
|
|
*
|
|
* @example
|
|
* // ['../*', './../*']
|
|
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
|
*/
|
|
function getPatternsOutsideCurrentDirectory(patterns) {
|
|
return patterns.filter(isPatternRelatedToParentDirectory);
|
|
}
|
|
exports.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
|
|
function isPatternRelatedToParentDirectory(pattern) {
|
|
return pattern.startsWith('..') || pattern.startsWith('./..');
|
|
}
|
|
exports.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
|
|
function getBaseDirectory(pattern) {
|
|
return globParent(pattern, { flipBackslashes: false });
|
|
}
|
|
exports.getBaseDirectory = getBaseDirectory;
|
|
function hasGlobStar(pattern) {
|
|
return pattern.includes(GLOBSTAR);
|
|
}
|
|
exports.hasGlobStar = hasGlobStar;
|
|
function endsWithSlashGlobStar(pattern) {
|
|
return pattern.endsWith('/' + GLOBSTAR);
|
|
}
|
|
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
function isAffectDepthOfReadingPattern(pattern) {
|
|
const basename = path.basename(pattern);
|
|
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
|
|
}
|
|
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
function expandPatternsWithBraceExpansion(patterns) {
|
|
return patterns.reduce((collection, pattern) => {
|
|
return collection.concat(expandBraceExpansion(pattern));
|
|
}, []);
|
|
}
|
|
exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
|
|
function expandBraceExpansion(pattern) {
|
|
return micromatch.braces(pattern, {
|
|
expand: true,
|
|
nodupes: true
|
|
});
|
|
}
|
|
exports.expandBraceExpansion = expandBraceExpansion;
|
|
function getPatternParts(pattern, options) {
|
|
let { parts } = micromatch.scan(pattern, Object.assign(Object.assign({}, options), { parts: true }));
|
|
/**
|
|
* The scan method returns an empty array in some cases.
|
|
* See micromatch/picomatch#58 for more details.
|
|
*/
|
|
if (parts.length === 0) {
|
|
parts = [pattern];
|
|
}
|
|
/**
|
|
* The scan method does not return an empty part for the pattern with a forward slash.
|
|
* This is another part of micromatch/picomatch#58.
|
|
*/
|
|
if (parts[0].startsWith('/')) {
|
|
parts[0] = parts[0].slice(1);
|
|
parts.unshift('');
|
|
}
|
|
return parts;
|
|
}
|
|
exports.getPatternParts = getPatternParts;
|
|
function makeRe(pattern, options) {
|
|
return micromatch.makeRe(pattern, options);
|
|
}
|
|
exports.makeRe = makeRe;
|
|
function convertPatternsToRe(patterns, options) {
|
|
return patterns.map((pattern) => makeRe(pattern, options));
|
|
}
|
|
exports.convertPatternsToRe = convertPatternsToRe;
|
|
function matchAny(entry, patternsRe) {
|
|
return patternsRe.some((patternRe) => patternRe.test(entry));
|
|
}
|
|
exports.matchAny = matchAny;
|