mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-03 18:41:15 +08:00
This also adds CC-BY-4.0 to the list of accepted licenses. DISABLE_THIRD_PARTY_CHECK=update dependencies Bug: chromium:1083142 Change-Id: I8612de2fba52dae32eeb71af79d5aacfde52142b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2220097 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Mathias Bynens <mathias@chromium.org>
67 lines
1.5 KiB
JavaScript
67 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const _ = require('lodash');
|
|
const isCustomPropertySet = require('../utils/isCustomPropertySet');
|
|
const isStandardSyntaxSelector = require('../utils/isStandardSyntaxSelector');
|
|
|
|
/**
|
|
* Check whether a Node is a standard rule
|
|
*
|
|
* @param {import('postcss').Rule} rule
|
|
* @returns {boolean}
|
|
*/
|
|
module.exports = function (rule) {
|
|
// Get full selector
|
|
const selector = _.get(rule, 'raws.selector.raw', rule.selector);
|
|
|
|
if (!isStandardSyntaxSelector(rule.selector)) {
|
|
return false;
|
|
}
|
|
|
|
// Custom property set (e.g. --custom-property-set: {})
|
|
if (isCustomPropertySet(rule)) {
|
|
return false;
|
|
}
|
|
|
|
// Called Less mixin (e.g. a { .mixin() })
|
|
// @ts-ignore TODO TYPES support LESS and SASS types somehow
|
|
if (rule.mixin) {
|
|
return false;
|
|
}
|
|
|
|
// Less detached rulesets
|
|
if (selector.startsWith('@') && selector.endsWith(':')) {
|
|
return false;
|
|
}
|
|
|
|
// Ignore Less &:extend rule
|
|
// @ts-ignore TODO TYPES support LESS and SASS types somehow
|
|
if (rule.extend) {
|
|
return false;
|
|
}
|
|
|
|
// Ignore mixin or &:extend rule
|
|
// https://github.com/shellscape/postcss-less/blob/master/lib/less-parser.js#L52
|
|
// @ts-ignore TODO TYPES support LESS and SASS types somehow
|
|
if (rule.params && rule.params[0]) {
|
|
return false;
|
|
}
|
|
|
|
// Non-outputting Less mixin definition (e.g. .mixin() {})
|
|
if (selector.endsWith(')') && !selector.includes(':')) {
|
|
return false;
|
|
}
|
|
|
|
// Less guards
|
|
if (/when\s+(not\s+)*\(/.test(selector)) {
|
|
return false;
|
|
}
|
|
|
|
// Ignore Scss nested properties
|
|
if (selector.endsWith(':')) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
};
|