diff --git a/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/invalid.js.snap b/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/invalid.js.snap new file mode 100644 index 000000000000..e342e803386b --- /dev/null +++ b/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/invalid.js.snap @@ -0,0 +1,119 @@ +--- +source: crates/biome_js_analyze/tests/spec_tests.rs +expression: invalid.js +--- +# Input +```jsx +Array(); + +Array(0, 1, 2); + +Array(...args); + +new Array(); + +new Array(0, 1, 2); + +new Array(...args); + +``` + +# Diagnostics +``` +invalid.js:1:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Don't use Array constructors. + + > 1 │ Array(); + │ ^^^^^^^^ + 2 │ + 3 │ Array(0, 1, 2); + + i The array literal notation [] is preferable. + + +``` + +``` +invalid.js:3:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Don't use Array constructors. + + 1 │ Array(); + 2 │ + > 3 │ Array(0, 1, 2); + │ ^^^^^^^^^^^^^^^ + 4 │ + 5 │ Array(...args); + + i The array literal notation [] is preferable. + + +``` + +``` +invalid.js:5:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Don't use Array constructors. + + 3 │ Array(0, 1, 2); + 4 │ + > 5 │ Array(...args); + │ ^^^^^^^^^^^^^^^ + 6 │ + 7 │ new Array(); + + i The array literal notation [] is preferable. + + +``` + +``` +invalid.js:7:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Don't use Array constructors. + + 5 │ Array(...args); + 6 │ + > 7 │ new Array(); + │ ^^^^^^^^^^^^ + 8 │ + 9 │ new Array(0, 1, 2); + + i The array literal notation [] is preferable. + + +``` + +``` +invalid.js:9:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Don't use Array constructors. + + 7 │ new Array(); + 8 │ + > 9 │ new Array(0, 1, 2); + │ ^^^^^^^^^^^^^^^^^^^ + 10 │ + 11 │ new Array(...args); + + i The array literal notation [] is preferable. + + +``` + +``` +invalid.js:11:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Don't use Array constructors. + + 9 │ new Array(0, 1, 2); + 10 │ + > 11 │ new Array(...args); + │ ^^^^^^^^^^^^^^^^^^^ + 12 │ + + i The array literal notation [] is preferable. + + +``` diff --git a/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/valid.js.snap b/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/valid.js.snap new file mode 100644 index 000000000000..c32e2cfbae03 --- /dev/null +++ b/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/valid.js.snap @@ -0,0 +1,19 @@ +--- +source: crates/biome_js_analyze/tests/spec_tests.rs +expression: valid.js +--- +# Input +```jsx +Array(500); + +Array(someOtherArray.length); + +new Array(500); + +new Array(someOtherArray.length); + +[0, 1, 2]; + +const createArray = (Array) => new Array(); + +```