Search code examples
typescriptlodasheslint

lodash's flow() breaks add() in TypeScript


import _ from 'lodash'

const x = _.add(3, 2) // no linting error

const foo = _.flow(
  _.add, // @typescript-eslint/unbound-method
  square,
)

Full error description at https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/unbound-method.md.

Why does using lodash's flow() break it's own add() and is there a solution to this?


Solution

  • Turns out this error comes from the recommended-requiring-type-checking eslint configuration.

    This configuration is more opinionated than the base typescript eslint. As a result, I feel comfortable overriding this rule:

    .eslintrc.js

    ...
    rules: {
        '@typescript-eslint/unbound-method': 'off', // conflicts with lodash's add()
    }