Closed rsmith-cs-ux closed 4 years ago
Oh interesting! Never new of this rule. Does your lint rules run on dependencies as well?
Apparently it does? Our initial reaction when seeing it was "how rude rule! We don't control that library." but I guess because we're calling the function within our code it doesn't like it ¯_(ツ)_/¯
I've be using it like this.changeset = new Changeset(this.user, lookupValidator(userValidator));
without any issues. That should satisfy your lint rule!
When we do that though, we get error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.
. I could force the cast, but that doesn't feel right either.
Oh I see, sorry I misunderstood the problem 😄
import { Changeset as changeset } from 'ember-changeset';
How about this?
That is another workaround. I locally have added the exception to our lint rule but I was thinking it would be better to handle it at this level for others. If I'm the only one hitting the issue though I'm happy to leave it alone :)
Happy to provide another solution alongside exporting Changeset
func (or accept a PR for one that effectively exports but calls original Changeset
function). How common is this lint rule?
Happy to accept a PR reexporting a changeset
function. Closing for now.
Hi there!
When constructing a Changeset, the capitalization of the function doesn't play well with es-lint rules for
new-cap
seen here: https://eslint.org/docs/rules/new-cap.If it could be changed to be lowercase, or follow a standard constructor with the
new
keyword then this wouldn't need a special exception rule in the eslint config.Thanks!