--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx const FOO = "FOO"; console.log(FOO, FOO2); const FOO2 = "FOO2", a = "FOO3", FOO4 = "FOO4"; console.log(FOO, FOO4); let foo = "foo"; const B = "B"; export default B; export const A = "A"; const BAR = "BAR"; export const bar = { foo: BAR, bar: BAR, }; const C = "C"; export const d = { foo: C }; const D ="D"; export const e = { D }; ``` # Diagnostics ``` invalid.js:4:7 lint/style/noShoutyConstants FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Redundant constant declaration. 2 │ console.log(FOO, FOO2); 3 │ > 4 │ const FOO2 = "FOO2", a = "FOO3", FOO4 = "FOO4"; │ ^^^^^^^^^^^^^ 5 │ 6 │ console.log(FOO, FOO4); i Used here. 1 │ const FOO = "FOO"; > 2 │ console.log(FOO, FOO2); │ ^^^^ 3 │ 4 │ const FOO2 = "FOO2", a = "FOO3", FOO4 = "FOO4"; i You should avoid declaring constants with a string that's the same value as the variable name. It introduces a level of unnecessary indirection when it's only two additional characters to inline. i Unsafe fix: Use the constant value directly 1 1 │ const FOO = "FOO"; 2 │ - console.log(FOO,·FOO2); 2 │ + console.log(FOO,·"FOO2"); 3 3 │ 4 │ - const·FOO2·=·"FOO2",·a·=·"FOO3",·FOO4·=·"FOO4"; 4 │ + const·a·=·"FOO3",·FOO4·=·"FOO4"; 5 5 │ 6 6 │ console.log(FOO, FOO4); ``` ``` invalid.js:4:34 lint/style/noShoutyConstants FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Redundant constant declaration. 2 │ console.log(FOO, FOO2); 3 │ > 4 │ const FOO2 = "FOO2", a = "FOO3", FOO4 = "FOO4"; │ ^^^^^^^^^^^^^ 5 │ 6 │ console.log(FOO, FOO4); i Used here. 4 │ const FOO2 = "FOO2", a = "FOO3", FOO4 = "FOO4"; 5 │ > 6 │ console.log(FOO, FOO4); │ ^^^^ 7 │ 8 │ let foo = "foo"; i You should avoid declaring constants with a string that's the same value as the variable name. It introduces a level of unnecessary indirection when it's only two additional characters to inline. i Unsafe fix: Use the constant value directly 2 2 │ console.log(FOO, FOO2); 3 3 │ 4 │ - const·FOO2·=·"FOO2",·a·=·"FOO3",·FOO4·=·"FOO4"; 4 │ + const·FOO2·=·"FOO2",·a·=·"FOO3"; 5 5 │ 6 │ - console.log(FOO,·FOO4); 6 │ + console.log(FOO,·"FOO4"); 7 7 │ 8 8 │ let foo = "foo"; ``` ``` invalid.js:20:7 lint/style/noShoutyConstants FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Redundant constant declaration. 18 │ }; 19 │ > 20 │ const C = "C"; │ ^^^^^^^ 21 │ 22 │ export const d = { i Used here. 22 │ export const d = { > 23 │ foo: C │ ^ 24 │ }; 25 │ i You should avoid declaring constants with a string that's the same value as the variable name. It introduces a level of unnecessary indirection when it's only two additional characters to inline. i Unsafe fix: Use the constant value directly 18 18 │ }; 19 19 │ 20 │ - const·C·=·"C"; 21 │ - 22 20 │ export const d = { 23 │ - → foo:·C 21 │ + → foo:·"C" 24 22 │ }; 25 23 │ ``` ``` invalid.js:26:7 lint/style/noShoutyConstants FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Redundant constant declaration. 24 │ }; 25 │ > 26 │ const D ="D"; │ ^^^^^^ 27 │ export const e = { 28 │ D i Used here. 26 │ const D ="D"; 27 │ export const e = { > 28 │ D │ ^ 29 │ }; i You should avoid declaring constants with a string that's the same value as the variable name. It introduces a level of unnecessary indirection when it's only two additional characters to inline. i Unsafe fix: Use the constant value directly 23 23 │ foo: C 24 24 │ }; 25 │ - 26 │ - const·D·="D"; 27 25 │ export const e = { 28 │ - → D 26 │ + → 27 │ + → D:"D" 29 28 │ }; ```