airbnb / airbnb/javascript

Reconsider capIsNew: false for new-cap

Open
#2,200 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
148k
Forks
26.6k
PR merge metrics
No merged PRs in 30d

Description

With `eslint-config-airbnb-base@8.0.0` the code
```js
class Example {}
module.exports = Example();
```
would result in the error:

example.js:2:18: A function with a name starting with an uppercase letter should only be used as a constructor. [Error/new-cap]

As a result of #1090, which set `capIsNew: false` for `new-cap`, this is no longer the case.

https://github.com/airbnb/javascript/issues/1089#issuecomment-249409624 which motivated the change only mentions adding `"capIsNewExceptions": ["Immutable.Map", "Immutable.Set", "Immutable.List"]`. Would it make sense to revert `capIsNew: false` (and perhaps adopt `"capIsNewExceptionPattern": "^Immutable.\\w"` as suggested in #1106) or was there another rationale for setting `capIsNew: false`?

Thanks,
Kevin

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the new-cap configuration change from #1090 and the rationale in the linked Airbnb issue, then reproduce the shown class and function-call example with eslint-config-airbnb-base@8.0.0. Compare reverting capIsNew with using capIsNewExceptions or capIsNewExceptionPattern, and consider the related proposal in #1106. Done means the intended behavior and configuration are agreed and covered by the project's relevant checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.