mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 01:07:01 +08:00
Stylelint v16 deprecated CJS so I moved our lint script to ESM, and fixed all the deprecation warning. The only place I needed to silence them were tests, as we import CJS there. Bug: none Change-Id: Iae4d2df76c855a9738b774a2d035f22509770215 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6138610 Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
68 lines
1.3 KiB
JavaScript
68 lines
1.3 KiB
JavaScript
// NOTICE: This file is generated by Rollup. To modify it,
|
|
// please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
|
|
'use strict';
|
|
|
|
const valueParser = require('postcss-value-parser');
|
|
const blurInterpolation = require('./blurInterpolation.cjs');
|
|
const isStandardSyntaxValue = require('./isStandardSyntaxValue.cjs');
|
|
|
|
/**
|
|
* Get Dimension from value node;
|
|
* `unit` and `number` return null if neither is found
|
|
*
|
|
* @param {import('postcss-value-parser').Node} node
|
|
*
|
|
* @returns {{unit: null, number: null} | valueParser.Dimension}
|
|
*/
|
|
function getDimension(node) {
|
|
if (!node || !node.value) {
|
|
return {
|
|
unit: null,
|
|
number: null,
|
|
};
|
|
}
|
|
|
|
// Ignore non-word nodes
|
|
if (node.type !== 'word') {
|
|
return {
|
|
unit: null,
|
|
number: null,
|
|
};
|
|
}
|
|
|
|
// Ignore non standard syntax
|
|
if (!isStandardSyntaxValue(node.value)) {
|
|
return {
|
|
unit: null,
|
|
number: null,
|
|
};
|
|
}
|
|
|
|
// Ignore HEX
|
|
if (node.value.startsWith('#')) {
|
|
return {
|
|
unit: null,
|
|
number: null,
|
|
};
|
|
}
|
|
|
|
// Remove non standard stuff
|
|
const value = blurInterpolation(node.value, '')
|
|
// ignore hack unit
|
|
.replace('\\0', '')
|
|
.replace('\\9', '');
|
|
|
|
const parsedUnit = valueParser.unit(value);
|
|
|
|
if (!parsedUnit) {
|
|
return {
|
|
unit: null,
|
|
number: null,
|
|
};
|
|
}
|
|
|
|
return parsedUnit;
|
|
}
|
|
|
|
module.exports = getDimension;
|