Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot disable "template-no-call-expression" rules. #848

Closed
Zarepheth opened this issue Jun 6, 2019 · 1 comment
Closed

Cannot disable "template-no-call-expression" rules. #848

Zarepheth opened this issue Jun 6, 2019 · 1 comment

Comments

@Zarepheth
Copy link

Zarepheth commented Jun 6, 2019

Describe the bug

tslint processes the template-no-call-expression rule even when it is set to false and also when a tslint:disable:template-no-call-expression comment is added to either the template (using an HTML comment) or the component's class file (using a TypeScript comment).

As a result, tslint spams me with Call expressions are not allowed in templates except in output handlers.

Context and configuration

Please share:

  • Which rule is causing the problem
    template-no-call-expression
  • What's the content of your tsconfig.json
{
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": false,
    "preserveWhiteSpace": false,
    "strictInjectionParameters": true,
    "strictMetadataEmit": true,
    "trace": true
  },
  "compileOnSave": false,
  "compilerOptions": {
    "allowJs": true,
    "alwaysStrict": true,
    "baseUrl": "Client",
    "checkJs": false,
    "declaration": false,
    "downlevelIteration": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["dom", "dom.iterable", "es6"],
    "module": "es2015",
    "moduleResolution": "node",
    "newLine": "CRLF",
    "outDir": "dist/out-tsc",
    "pretty": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "strictPropertyInitialization": false,
    "target": "es5"
  },
  "exclude": ["bin", "dist", "karma.conf.js", "node_modules", "obj", "protractor.conf.js", "wwwroot"],
  "include": ["Client"],
  "typeAcquisition": {
    "enable": true,
    "include": ["bootstrap", "jquery"]
  }
}
  • What's the content of ~/.codelyzer.js (if applicable)
    no .codelyzer.js file.

To Reproduce

Not yet reproduced in a minimal project, but components use separate template files, in the same subdirectory as the component's class. Template contains method calls in some property bindings (for HTML elements, Angular directives, and child components) or in interpolations {{ ... }}. Where the bound properties are not annotated with @Output() in their declarations, tslint reports: Call expressions are not allowed in templates except in output handlers even when the rule should be turned off.

Expected behavior

I expect tslint with codelyzer to enforce all non-disabled rules, while ignoring and not reporting errors for rules that are disabled.

Code

In the code below, tsling with codelyzer reports an error at isValueNoChoice(inputValue). If the rule were enabled, I would expect this error. When the rule is disabled, I do not.

<select class="form-control-sm px-1 "
  [ngClass]="valueControlCssClasses"
  [class.text-muted]="isValueNoChoice(inputValue)" [(ngModel)]="inputValue"   
  (change)="onValueChange($event)">
    <option class="text-muted" [value]="dropdownNoChoiceOption.value"
      *ngIf="dropdownNoChoiceOption">{{ dropdownNoChoiceOption.text }}</option>
    <option class="text-dark" *ngFor="let choice of dropdownChoices" [value]="choice.value || choice.text">{{ choice.text }}</option>
</select>

Environment

From package.json:

    "angular-tslint-rules": "^1.14.0",
    "codelyzer": "^4.5.0",
    "prettier": "^1.17.1",
    "tslint": "^5.16.0",
    "tslint-config-prettier": "^1.18.0",
    "tslint-plugin-prettier": "^2.0.1",

ng --version output: 6.9.0

Angular CLI: 7.3.9
Node: 10.1.0
OS: win32 x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.9
@angular-devkit/build-angular     0.13.9
@angular-devkit/build-optimizer   0.13.9
@angular-devkit/build-webpack     0.13.9
@angular-devkit/core              7.3.9
@angular-devkit/schematics        7.3.9
@angular/cli                      7.3.9
@ngtools/webpack                  7.3.9
@schematics/angular               7.3.9
@schematics/update                0.13.9
rxjs                              6.5.2
typescript                        3.2.4
webpack                           4.29.0

Partial tslint.json file:

{
  "extends": ["angular-tslint-rules", "tslint-plugin-prettier" /*, "tslint-config-prettier" */],
  "rulesDirectory": ["node_modules/codelyzer"],
  "linterOptions": {
    "exclude": [
      "*.*proj",
      "*.config",
      "*.user",
      "**/.vs/**/*",
      "**/.vscode/**/*",
      "**/bin/**/*",
      "**/node_modules/**/*",
      "**/obj/**/*",
      "**/Properties/**/*",
      "**/wwwroot/**/*",
      "./desktop.ini",
      "./Client/polyfills.ts"
    ]
  },
  "jsRules": true,
  "rules": {
    "prettier": true,
    "no-unused-css": false,
    "prefer-inline-decorator": [false],
    "prefer-template": [false, "allow-single-concat"],
    "template-conditional-complexity": false,
    "template-cyclomatic-complexity": false,
    "template-no-call-expression": false,
    "template-use-track-by-function": false,
    "trackBy-function": false,
    "use-view-encapsulation": false,
    // many more rules ...
  }
}

Edit : fix spelling of rule name from template-no-call-expressssion to template-no-call-expression. Even with the corrected name, still having the same problem.

@Zarepheth Zarepheth changed the title Cannot disable "template-no-call-expressssion" rules. Cannot disable "template-no-call-expression" rules. Jun 6, 2019
@rafaelss95
Copy link
Collaborator

Duplicate of #821.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants