fix: some rules not considering options correctly#617
fix: some rules not considering options correctly#617wKoza merged 1 commit intomgechev:masterfrom rafaelss95:fix-tests
Conversation
|
@wKoza can you review? |
|
@rafaelss95 , we have an another problem with the rule |
| private validateInlineTemplate(metadata: ComponentMetadata): void { | ||
| if (this.hasInlineTemplate(metadata) && this.getTemplateLinesCount(metadata) > this.templateLinesLimit) { | ||
| const templateLinesCount = this.getTemplateLinesCount(metadata); | ||
| const msg = `Inline template lines limit exceeded. Defined limit: ${this.templateLinesLimit} / template lines: ${templateLinesCount}`; |
There was a problem hiding this comment.
It's a shame to lost the value : template lines. It's a valuable value.
There was a problem hiding this comment.
No problem, I'll put it again.
|
@wKoza Hmm, yes, I noticed this problem now. I've pushed the changes you requested. Thinking more about it... should we exclude all empty lines from calculation or only the first and last? And what about comments? I'm asking because someone, for example, requested in palantir/tslint#3672 to @Component({
selector: 'app-root',
template: `
<div>
something here
<!-- a comment here -->
</div>
`,
styleUrls: ['./app.component.css']
})
export class AppComponent {} |
|
The main reason for this rule is to increase readabilty of our components. All the HTML source code obscure the component's implementation, so, I think we can compute comments and the other empty lines. |
The following rules aren't behaving correctly at the moment:
The problem with these rules are that it's only considering the options from the second element (in position 1) of the
array, which is totally incorrect.Example for
max-inline-declarations:{ "rules": { "max-inline-declarations": [true, { "template": 2 }] } }Expected behavior:
Failure.
Actual behavior:
No failure.
This fixes the wrong behavior and respective tests, with some refactor.
PS: The spec file of
max-inline-declarationswas wrongly named.