mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 01:07:01 +08:00
Add one more deps "@typescript-eslint/utils" to top level to be used in our own custom rules (also needed override if I didn't). Bug: none Change-Id: I130415d1ec5f096ca51200df3eb688dadd963d0f Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6343232 Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org>
52 lines
1.2 KiB
JavaScript
52 lines
1.2 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)
|
|
// styled component interpolation (example ${foo => foo.bar})
|
|
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;
|
|
}
|