Skip to content

Question about new new-cap rule #1106

@dandean

Description

@dandean

I don't want to bikeshed on this, but I do have some concerns about this rule change I'd like to bring up.

My biggest concern is that it will lead to more people overriding the new-cap rule than in the past because this new rule is so limited in scope. This would be the opposite of the intended outcome of #1089.

  • This rule creates exceptions for Immutable.{Map,Set,List}
  • The Immutable API contains many more types (Record, Seq, Collection, OrderedMap, etc)

The result is that eslint will tell people to use new for new Immutable.Record() AND to NOT use new for Immutable.Map(). The only way to make this consistent is to override the rule in your local environment, and this will be incredibly common.

My suggestion is to either:

  • revert the rule change
  • re-implement the rule to use capIsNewExceptionPattern instead of capIsNewExceptions in order to target the entire Immutable.js API with a regular expression.

If this interests you I'm happy to submit a patch for either choice.

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