Forum Discussion

Tracy Sterling's avatar
Tracy Sterling
Copper Contributor
Feb 06, 2018
Solved

Rules in config/tslint.json file of SPFx scaffolding are being ignored.

I ran the current Yeoman SharePoint generator, and got the following ts-lint file in the config directory (with a few minor tweaks added).  From what I can tell the trailing-comma rule should be disabled (it's set to false), but it's not. I'm still getting red squigglies when I don't have a trailing comma (see below). 

 

That's just one example of a number of tslint scaffolding rules that appear to be ignored. 

What am I missing? Thanks! :-)

(I have also posted https://sharepoint.stackexchange.com/questions/235288/how-do-i-disable-trailing-comma-tslint-rule-in-spfx-scaffolding.)

 

  "$schema": "https://dev.office.com/json-schemas/core-build/tslint.schema.json",
  // Display errors as warnings
  "displayAsWarning": true,
  // The TSLint task may have been configured with several custom lint rules
  // before this config file is read (for example lint rules from the tslint-microsoft-contrib
  // project). If true, this flag will deactivate any of these rules.
  "removeExistingRules": true,
  // When true, the TSLint task is configured with some default TSLint "rules.":
  "useDefaultConfigAsBase": false,
  // Since removeExistingRules=true and useDefaultConfigAsBase=false, there will be no lint rules
  // which are active, other than the list of rules below.
  "lintConfig": {
    // Opt-in to Lint rules which help to eliminate bugs in JavaScript
    "rules": {
      "class-name": false,
      "export-name": false,
      "forin": false,
      "label-position": false,
      "member-access": true,
      "no-arg": false,
      "no-console": false,
      "no-construct": false,
//      "no-duplicate-switch-case": true,
      "no-duplicate-variable": true,
      "no-eval": false,
      "no-function-expression": true,
      "no-internal-module": true,
      "no-shadowed-variable": true,
      "no-switch-case-fall-through": true,
      "no-unnecessary-semicolons": true,
      "no-unused-expression": true,
      "no-use-before-declare": true,
      "no-with-statement": true,
      "semicolon": true,
      "trailing-comma": false,
      "typedef": false,
      "typedef-whitespace": false,
      "use-named-parameter": true,
      "typeof-compare": true,
      "variable-name": false,
      "whitespace": false
    }
  }
}

  • Hi Tracy Sterling,

     

    Looking at the second image, I assume that you are referring to TSLint using the Visual Studio Code extension. If so. please check the blog post I have published some time ago with a simple fix for this. 

    Hope it helps

     

1 Reply

  • Hi Tracy Sterling,

     

    Looking at the second image, I assume that you are referring to TSLint using the Visual Studio Code extension. If so. please check the blog post I have published some time ago with a simple fix for this. 

    Hope it helps

     

Resources