# es/no-array-prototype-flat

disallow the Array.prototype.{flat,flatMap} method

  • ✅ The following configurations enable this rule: plugin:es/no-new-in-es2019, plugin:es/restrict-to-es3, plugin:es/restrict-to-es5, plugin:es/restrict-to-es2015, plugin:es/restrict-to-es2016, plugin:es/restrict-to-es2017, and plugin:es/restrict-to-es2018

This rule reports ES2019 Array.prototype.{flat,flatMap} methods (opens new window) as errors.

This rule is silent by default because it's hard to know types. You need to configure the aggressive mode or TypeScript in order to enable this rule.

# 💡 Examples

⛔ Examples of incorrect code for this rule:

/*eslint es/no-array-prototype-flat: [error, { aggressive: true }] */ foo.flat(0) foo.flatMap(e => [e, 2 * e])
Now loading...

# 🔧 Options

This rule has an option.

rules:
  es/no-array-prototype-flat: [error, { aggressive: false }]

# aggressive: boolean

Configure the aggressive mode for only this rule. This is prior to the settings.es.aggressive setting.

# 📚 References