# eslint no-array-constructor: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: eslint 9.39.5
- Rule: no-array-constructor (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): real, severity high. The program redefines `Array` to a custom function that returns an object with a `custom` property. The rule's documentation explicitly warns that `Array` may be redefined, yet the autofix replaces `Array(1, 2)` with the array literal `[1, 2]`, which calls the built-in Array constructor instead of the redefined function. This changes the runtime behavior from printing 'redefined' to 'literal', a silent wrong result in plausible code.
- Program: minimized from 4 to 3 lines

## Reproducer

```js
Array = function(...args) { return { length: args.length, custom: true }; };
const arr = Array(1, 2);
console.log(arr.custom ? 'redefined' : 'literal');
```

## Commands

```sh
node prog.js
npx eslint --no-config-lookup --rule 'no-array-constructor: error' --fix prog.js
node prog.js
```

## Observed

```
stdout before:
redefined
stdout after:
literal
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 14:14:38.421849225 -0400
+++ fixed.js	2026-10-22 14:14:40.739903377 -0400
@@ -1,3 +1,3 @@
 Array = function(...args) { return { length: args.length, custom: true }; };
-const arr = Array(1, 2);
+const arr = [1, 2];
 console.log(arr.custom ? 'redefined' : 'literal');
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original `Array` constructor was overridden to return plain objects with a `custom` property; calling `Array(1, 2)` produced such an object, making `arr.custom` truthy. The fix replaced that call with `[1, 2]`, which creates a real array instance lacking the `custom` property, so `arr.custom` becomes falsy and the output changes from "redefined" to "literal". This alters observable behavior because the redefined constructor’s side effect (adding `custom`) is lost when using the literal syntax instead of the constructor call.

## Upstream search

Queries: "no-array-constructor fix", "no-array-constructor array constructor call", "no-array-constructor new Array expression", "no-array-constructor Array literal replacement"

- related: https://github.com/eslint/eslint/issues/19608
  Rule change request to implement autofix for no-array-constructor, same rule but different construct (Array() vs redefined Array)
- related: https://github.com/eslint/eslint/issues/17517
  Similar bug in no-new-object rule where autofix changes behavior when constructor is redefined, same class of defect
- related: https://github.com/eslint/eslint/issues/19494
  Bug in no-array-constructor not detecting Array in sequence expression, same rule but different construct

<details><summary>All hits</summary>

- [github, open] Change Request: Make rules TypeScript syntax-aware — https://github.com/eslint/eslint/issues/19173
- [github, closed] Bug: npm audit fix managed to break eslint and I'm not quite sure what is wrong. — https://github.com/eslint/eslint/issues/20560
- [github, closed] Rule Change: [no-array-constructor] Switch suggestions to full fixes — https://github.com/eslint/eslint/issues/19608
- [github, closed] Bug: `no-undef` `no-unused-vars` — https://github.com/eslint/eslint/issues/19982
- [github, closed] Change Request: autoformat docs — https://github.com/eslint/eslint/issues/17504
- [github, closed] Change Request: track dependencies of eslint.config.js to invalidate cache & typescript support — https://github.com/eslint/eslint/issues/18337
- [github, closed] ESlint error "Switch cases without blocks are disallowed. eslint (no-restricted-syntax)" — https://github.com/eslint/eslint/issues/18200
- [github, closed] ESLint hangs indefinitely, no errors — https://github.com/eslint/eslint/issues/18449
- [github, closed] Bug: `no-new-object` has incorrect advice when `Object` constructor is called with an argument — https://github.com/eslint/eslint/issues/17517
- [github, closed] Bug: `.eslintrc.js` is ignored again — https://github.com/eslint/eslint/issues/17090
- [github, closed] Bug: false positive from no-useless-assignment in Vue SFC — https://github.com/eslint/eslint/issues/20486
- [github, closed] Docs: rewrite examples with `var` using `const` and `let` — https://github.com/eslint/eslint/issues/19240
- [github, closed] Bug: Cannot read properties of undefined (reading 'name') after upgrade to 9.39.0 — https://github.com/eslint/eslint/issues/20276
- [github, closed] Bug: [no-array-constructor] Does not detect Array in a sequence expression — https://github.com/eslint/eslint/issues/19494
- [github, closed] Bug: Getting a "parsing error" when a class definition contains an assignment of a function to a property — https://github.com/eslint/eslint/issues/19536
- [github, closed] Docs: Clearly mark rules that are frozen — https://github.com/eslint/eslint/issues/18694
- [github, closed] Error arfter upgrade 7.11.0 ->7.12.0 " The "path" argument must be of type string. Received undefined" — https://github.com/eslint/eslint/issues/13789
- [github, closed] Warn on deprecated rules — https://github.com/eslint/eslint/issues/7443
- [github, closed] First line is always an error after upgrading eslint to 3.4.0 — https://github.com/eslint/eslint/issues/7003
- [github, closed] Indent rule - Reports incorrectly for function expressions containing Flowtype annotations — https://github.com/eslint/eslint/issues/8990

</details>
