Skip to content

Rule proposal: forbid use of blacklisted lodash methods #221

@serhalp

Description

@serhalp

forbid-methods

This rule forbids the use of a configured set of lodash methods.

Rule Details

This rule takes one argument:

  • The first (required), which methods to forbid calling

The following patterns are considered warnings:

/* eslint lodash/forbid-methods: [2, ['get'] */
var result = _.get(user, 'name');
/* eslint lodash/forbid-methods: [2, ['get'] */
var result = _(user).omit('id').get('name')
/* eslint lodash/forbid-methods: [2, ['keys', 'values'] */
var result = _.keys(user);

The following patterns are not considered warnings:

/* eslint lodash/forbid-methods: [2, ['keys', 'values'] */
var result = _.get(user, 'name');
/* eslint lodash/forbid-methods: [2, ['get'] */
var result = _.keys(user);

When Not To Use It

If you do not want to forbid the use of any lodash methods, then you can disable this rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions