Question about new `new-cap` rule
- Lingua principale
- JavaScript
- Stelle
- 148k
- Fork
- 26.6k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
- Original discussion: https://github.com/airbnb/javascript/issues/1089#issuecomment-249409943
- Patch: https://github.com/airbnb/javascript/pull/1090
---
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`](http://eslint.org/docs/rules/new-cap#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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Leggi prima la discussione originale e la patch collegata, poi esamina la nuova documentazione di new-cap di ESLint relativa a capIsNewExceptionPattern e capIsNewExceptions. Decidi se la modifica debba essere annullata o generalizzata per coprire in modo coerente l'API di Immutable.js; il lavoro è completato quando il comportamento scelto è chiaro per Map, Set, List, Record, Seq, Collection e i tipi correlati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- eslint, javascript
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100