Files
react-native-devtools-frontend/node_modules/postcss-less/lib/nodes/variable.js
T
Mathias Bynens 79e2cf0633 Add stylelint dependency
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>
2020-06-11 06:20:04 +00:00

35 lines
930 B
JavaScript

/* eslint no-param-reassign: off */
const afterPattern = /:$/;
const beforePattern = /^:(\s+)?/;
// const bracketsPattern = /\{/;
module.exports = (node) => {
const { name, params = '' } = node;
// situations like @page :last { color: red } should default to the built-in AtRule
// LESS variables are @name : value; < note that for them to be valid LESS vars, they must end in
// a semicolon.
if (node.name.slice(-1) !== ':') {
return;
}
if (afterPattern.test(name)) {
const [match] = name.match(afterPattern);
node.name = name.replace(match, '');
node.raws.afterName = match + (node.raws.afterName || '');
node.variable = true;
node.value = node.params;
}
if (beforePattern.test(params)) {
const [match] = params.match(beforePattern);
node.value = params.replace(match, '');
node.raws.afterName = (node.raws.afterName || '') + match;
node.variable = true;
}
};