You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
The private constructor is flagged as unnecessary.
Expected behavior
The private constructor is not flagged.
There are cases where a class shouldn't be constructible (factory classes or something) where it would make sense to have an empty constructor with the private/etc modifier to prevent it from being constructed externally. Right now, this private empty constructor is flagged by the unnecessary-constructor rule. In my estimation, this constructor is necessary, because it performs a task that would not performed were it not included (makes the constructor inaccessible).
The text was updated successfully, but these errors were encountered:
ericbf
changed the title
Rule unnecessary-constructor should not flag empty private constructor
[unnecessary-constructor] Should not flag empty private constructor
Feb 7, 2019
ericbf
changed the title
[unnecessary-constructor] Should not flag empty private constructor
[unnecessary-constructor] Incorrectly flagging accessibility-restricting constructors
Feb 7, 2019
hello, i am new to this open source world but have been coding in js and typescript for around 2-3 years now. i can look into this bug and if possible can make necessary changes to it.
so can i start working on it ?
This commit checks the modifiers of each constructor declaration. If it has any modifier that isn't `public`, then it's actually necessary and shouldn't be flagged by unnecessary-constructor rule.
Bug Report
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
The private constructor is flagged as unnecessary.
Expected behavior
The private constructor is not flagged.
There are cases where a class shouldn't be constructible (factory classes or something) where it would make sense to have an empty constructor with the private/etc modifier to prevent it from being constructed externally. Right now, this private empty constructor is flagged by the
unnecessary-constructor
rule. In my estimation, this constructor is necessary, because it performs a task that would not performed were it not included (makes the constructor inaccessible).The text was updated successfully, but these errors were encountered: