fix(rome_js_analyze): fix noShoutyConstants with empty string
Closes
MODIFY
crates/rome_js_analyze/src/semantic_analyzers/style/no_shouty_constants.rs
crates/rome_js_analyze/src/semantic_analyzers/style/no_shouty_constants.rs
@@ -66,11 +66,12 @@ fn is_id_and_string_literal_inner_text_equal(
.as_js_string_literal_expression()?;
let literal_text = literal.inner_string_text().ok()?;
- for (from_id, from_literal) in id_text.chars().zip(literal_text.chars()) {
- if from_id != from_literal {
+ if id_text.len() != usize::from(literal_text.len()) {
return None;
}
- if from_id.is_lowercase() || from_literal.is_lowercase() {
+
+ for (from_id, from_literal) in id_text.chars().zip(literal_text.chars()) {
+ if from_id != from_literal || from_id.is_lowercase() {
return None;
}
}

MODIFY
crates/rome_js_analyze/tests/specs/style/noShoutyConstants.js
crates/rome_js_analyze/tests/specs/style/noShoutyConstants.js
@@ -27,3 +27,18 @@ const D ="D";
export const e = {
D
};
+
+const Empty = "";
+export const E = Empty;
+
+const NotMatching = "DoesNotMatch";
+export const F = NotMatching;
+
+const matchingLowercase = "matchingLowercase";
+export const G = matchingLowercase;
+
+const AL = "ALPHA";
+export const H = AL;
+
+const ALPHA = "AL";
+export const I = ALPHA;

fix(rome_js_analyze): fix noShoutyConstants with empty string (#3868)

Closes https://github.com/rome/tools/issues/3867