SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-152952%22%20slang%3D%22en-US%22%3ERules%20in%20config%2Ftslint.json%20file%20of%20SPFx%20scaffolding%20are%20being%20ignored.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-152952%22%20slang%3D%22en-US%22%3E%3CP%3EI%20ran%20the%20current%20Yeoman%20SharePoint%20generator%2C%20and%20got%20the%20following%20ts-lint%20file%20in%20the%20config%20directory%20(with%20a%20few%20minor%20tweaks%20added).%26nbsp%3B%20From%20what%20I%20can%20tell%20the%20trailing-comma%20rule%20should%20be%20disabled%20(it's%20set%20to%20false)%2C%20but%20it's%20not.%20I'm%20still%20getting%20red%20squigglies%20when%20I%20don't%20have%20a%20trailing%20comma%20(see%20below).%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat's%20just%20one%20example%20of%20a%20number%20of%20tslint%20scaffolding%20rules%20that%20appear%20to%20be%20ignored.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20am%20I%20missing%3F%20Thanks!%20%3A)%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E(I%20have%20also%20posted%20%3CA%20href%3D%22https%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F235288%2Fhow-do-i-disable-trailing-comma-tslint-rule-in-spfx-scaffolding%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20question%20in%20SharePoint%20StackExchange%3C%2FA%3E.)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdev.office.com%2Fjson-schemas%2Fcore-build%2Ftslint.schema.json%22%2C%0A%20%20%2F%2F%20Display%20errors%20as%20warnings%0A%20%20%22displayAsWarning%22%3A%20true%2C%0A%20%20%2F%2F%20The%20TSLint%20task%20may%20have%20been%20configured%20with%20several%20custom%20lint%20rules%0A%20%20%2F%2F%20before%20this%20config%20file%20is%20read%20(for%20example%20lint%20rules%20from%20the%20tslint-microsoft-contrib%0A%20%20%2F%2F%20project).%20If%20true%2C%20this%20flag%20will%20deactivate%20any%20of%20these%20rules.%0A%20%20%22removeExistingRules%22%3A%20true%2C%0A%20%20%2F%2F%20When%20true%2C%20the%20TSLint%20task%20is%20configured%20with%20some%20default%20TSLint%20%22rules.%22%3A%0A%20%20%22useDefaultConfigAsBase%22%3A%20false%2C%0A%20%20%2F%2F%20Since%20removeExistingRules%3Dtrue%20and%20useDefaultConfigAsBase%3Dfalse%2C%20there%20will%20be%20no%20lint%20rules%0A%20%20%2F%2F%20which%20are%20active%2C%20other%20than%20the%20list%20of%20rules%20below.%0A%20%20%22lintConfig%22%3A%20%7B%0A%20%20%20%20%2F%2F%20Opt-in%20to%20Lint%20rules%20which%20help%20to%20eliminate%20bugs%20in%20JavaScript%0A%20%20%20%20%22rules%22%3A%20%7B%0A%20%20%20%20%20%20%22class-name%22%3A%20false%2C%0A%20%20%20%20%20%20%22export-name%22%3A%20false%2C%0A%20%20%20%20%20%20%22forin%22%3A%20false%2C%0A%20%20%20%20%20%20%22label-position%22%3A%20false%2C%0A%20%20%20%20%20%20%22member-access%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-arg%22%3A%20false%2C%0A%20%20%20%20%20%20%22no-console%22%3A%20false%2C%0A%20%20%20%20%20%20%22no-construct%22%3A%20false%2C%0A%2F%2F%20%20%20%20%20%20%22no-duplicate-switch-case%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-duplicate-variable%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-eval%22%3A%20false%2C%0A%20%20%20%20%20%20%22no-function-expression%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-internal-module%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-shadowed-variable%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-switch-case-fall-through%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-unnecessary-semicolons%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-unused-expression%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-use-before-declare%22%3A%20true%2C%0A%20%20%20%20%20%20%22no-with-statement%22%3A%20true%2C%0A%20%20%20%20%20%20%22semicolon%22%3A%20true%2C%0A%20%20%20%20%20%20%22trailing-comma%22%3A%20false%2C%0A%20%20%20%20%20%20%22typedef%22%3A%20false%2C%0A%20%20%20%20%20%20%22typedef-whitespace%22%3A%20false%2C%0A%20%20%20%20%20%20%22use-named-parameter%22%3A%20true%2C%0A%20%20%20%20%20%20%22typeof-compare%22%3A%20true%2C%0A%20%20%20%20%20%20%22variable-name%22%3A%20false%2C%0A%20%20%20%20%20%20%22whitespace%22%3A%20false%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20775px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F28089i38458294FD4E9279%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22SS1.png%22%20title%3D%22SS1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-152952%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESPFx%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-153823%22%20slang%3D%22en-US%22%3ERe%3A%20Rules%20in%20config%2Ftslint.json%20file%20of%20SPFx%20scaffolding%20are%20being%20ignored.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-153823%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F115870%22%20target%3D%22_blank%22%3E%40Tracy%20Sterling%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELooking%20at%20the%20second%20image%2C%20I%20assume%20that%20you%20are%20referring%20to%20TSLint%20using%20the%20Visual%20Studio%20Code%20extension.%20If%20so.%20please%20check%20the%20%3CA%20href%3D%22https%3A%2F%2Fjoelfmrodrigues.wordpress.com%2F2017%2F12%2F06%2Ftslint-spfx%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eblog%20post%3C%2FA%3EI%20have%20published%20some%20time%20ago%20with%20a%20simple%20fix%20for%20this.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHope%20it%20helps%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

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 this question in SharePoint StackExchange.)

 

  "$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
    }
  }
}

SS1.png

1 Reply
Highlighted
Solution

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