mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-06 12:01:40 +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>
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
import hasInterpolation from './hasInterpolation.mjs';
|
|
|
|
/**
|
|
* Check whether a value is standard
|
|
*
|
|
* @param {string} value
|
|
* @returns {boolean}
|
|
*/
|
|
export default function isStandardSyntaxValue(value) {
|
|
let normalizedValue = value;
|
|
|
|
// Ignore operators before variables (example -$variable)
|
|
if (/^[-+*/]/.test(value.charAt(0))) {
|
|
normalizedValue = normalizedValue.slice(1);
|
|
}
|
|
|
|
// SCSS variable (example $variable)
|
|
if (normalizedValue.startsWith('$')) {
|
|
return false;
|
|
}
|
|
|
|
// SCSS namespace (example namespace.$variable)
|
|
if (/^.+\.\$/.test(value)) {
|
|
return false;
|
|
}
|
|
|
|
// SCSS namespace (example namespace.function-name())
|
|
if (/^.+\.[-\w]+\(/.test(value)) {
|
|
return false;
|
|
}
|
|
|
|
// Less variable
|
|
if (normalizedValue.startsWith('@')) {
|
|
return false;
|
|
}
|
|
|
|
// SCSS or Less interpolation
|
|
if (hasInterpolation(normalizedValue)) {
|
|
return false;
|
|
}
|
|
|
|
// WebExtension replacement keyword used by Chrome/Firefox
|
|
// more information: https://developer.chrome.com/extensions/i18n
|
|
// and https://github.com/stylelint/stylelint/issues/4707
|
|
if (/__MSG_\S+__/.test(value)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|