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.
Is your feature request that we implement a new rule?
No
Is your feature request related to a problem? Please describe.
I'm trying to write a new rule which is a bit resource intensive. Thinking my Rule's constructor will get called exactly once while running tslint, I added the resource intensive call on it's constructor like this:
exportclassRuleextendsLint.Rules.TypedRule{constructor(options: Lint.IOptions){super(options);console.info(options.ruleArguments);// here's my super resource intensive call}publicapplyWithProgram(sourceFile: ts.SourceFile,program: ts.Program): Lint.RuleFailure[]{returnthis.applyWithWalker(newTranslationRule(sourceFile,this.getOptions(),program));}}// tslint:disable-next-line:max-classes-per-fileclassTranslationRuleextendsLint.RuleWalker{constructor(sourceFile: ts.SourceFile,option: Lint.IOptions,privateprogram: ts.Program){super(sourceFile,option);}publicvisitCallExpression(node: ts.CallExpression): any{super.visitCallExpression(node);}}
When I ran npm run lint on my codebase, it logged it multiple times.
Describe the solution you'd like
Instead of doing new for each file, use the same instance everywhere.
Additional context
Or maybe I'm missing something myself, I'm trying to read another file on constructor using file system, it'd be great if I didn't have to read file a lot of times.
Or did I miss something? Or is there a bootstrap step even before that?
Only thing makes sense is that tslint is spinning multiple threads and running lint rules in each thread.
The text was updated successfully, but these errors were encountered:
@cyberhck You can try putting a console.log(new Error().stack) in the constructor and an Error.stackTraceLimit = Infinity; somewhere outside the class to see where this is coming from.
spinning multiple threads and running lint rules in each thread.
Hi, thanks for the response, unfortunately I don't have the code base right now, I will get to it soon and let you know, I'm just doing a simple npm run lint which calls tslint with typescript project thing (I use the stylish option, but I don't think it has anything to do with this)
I'll try to do the console.log soon and let you know :)
Sorry, this can be closed as I know tslint is moving to typescript-eslint, I left the company and have no access to the codebase since last December. Sorry.
Feature request
Is your feature request that we implement a new rule?
No
Is your feature request related to a problem? Please describe.
I'm trying to write a new rule which is a bit resource intensive. Thinking my Rule's constructor will get called exactly once while running tslint, I added the resource intensive call on it's constructor like this:
When I ran npm run lint on my codebase, it logged it multiple times.
Describe the solution you'd like
Instead of doing
new
for each file, use the same instance everywhere.Additional context
Or maybe I'm missing something myself, I'm trying to read another file on constructor using file system, it'd be great if I didn't have to read file a lot of times.
Or did I miss something? Or is there a bootstrap step even before that?
Only thing makes sense is that tslint is spinning multiple threads and running lint rules in each thread.
The text was updated successfully, but these errors were encountered: