sindresorhus / eslint-plugin-unicorn

More than 100 powerful ESLint rules
MIT License
4.28k stars 367 forks source link

`unicorn/no-array-callback-reference` does not report when optional chaining #2294

Open czizzy opened 8 months ago

czizzy commented 8 months ago

this rule is not reported when optional chaining

unicorn/no-array-callback-reference

function isString(arg) {
  return typeof arg === 'string';
}

const obj = { a: [], b: [] };

obj.a.filter(isString);
obj.b?.filter(isString);

only the first filter report an error.

fisker commented 8 months ago

Remove this line should fix this

https://github.com/sindresorhus/eslint-plugin-unicorn/blob/231529aee793251f30416b93dc3d5f9bfa27ee47/rules/no-array-callback-reference.js#L238

PR welcome.