Tslint: tsconfig.json excludes should win over paths

Created on 5 Jan 2018  ·  3Comments  ·  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.8.0
  • __TypeScript version__: 2.6.2
  • __Running TSLint via__: CLI

TypeScript code being linted

asn1.js

with tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "target": "es2017",
    "allowJs": true,
    "moduleResolution": "node",
    "noEmitOnError": false,
    "noEmit": true,
    "sourceMap": true,
    "baseUrl": ".",
    "module": "es6",
    "paths": {
      "npm:asn1js": [ "node_modules/asn1js" ],
    }
  },
  "exclude": [
    "tmp",
    "dist",
    "node_modules"
  ]
}

with tslint.json configuration:

{
  "extends": [
    "tslint:recommended"
  ]
}

Actual behavior

Running

$ node_modules/.bin/tslint --project tsconfig.json

I get

ERROR: /code/my_project/node_modules/asn1js/build/asn1.js[8, 5]: variable name must be in lowerCamelCase, PascalCase or UPPER_CASE
ERROR: /code/my_project/node_modules/asn1js/build/asn1.js[8, 55]: if statements must be braced
ERROR: /code/my_project/node_modules/asn1js/build/asn1.js[10, 5]: variable name must be in lowerCamelCase, PascalCase or UPPER_CASE
ERROR: /code/my_project/node_modules/asn1js/build/asn1.js[10, 233]: if statements must be braced
...

Expected behavior

I expect tslint to obey the exclude: [ "node_modules" ]. If I remove the "npm:asn1js" entry from paths, I get no tslint errors.

API Accepting PRs Bug 🌹 R.I.P. 🌹

Most helpful comment

I've also tried

// tsconfig.json
{
  "exclude": [
    "node_modules",
    "node_modules/**/*.{j,t}s"
  ]
}

and

// tsconfig.json
{
  "linterOptions": {
    "exclude": [
      "node_modules/**/*.{j,t}s"
    ]
  }
}

to no avail.

If I run

node_modules/.bin/tslint --project tsconfig.json --exclude "node_modules/**/*.{j,t}s"

it works great.

All 3 comments

I've also tried

// tsconfig.json
{
  "exclude": [
    "node_modules",
    "node_modules/**/*.{j,t}s"
  ]
}

and

// tsconfig.json
{
  "linterOptions": {
    "exclude": [
      "node_modules/**/*.{j,t}s"
    ]
  }
}

to no avail.

If I run

node_modules/.bin/tslint --project tsconfig.json --exclude "node_modules/**/*.{j,t}s"

it works great.

💀 _It's time!_ 💀

TSLint is being deprecated and no longer accepting pull requests for major new changes or features. See #4534. 😱

If you'd like to see this change implemented, you have two choices:

  • Recommended: Check if this is available in ESLint + typescript-eslint
  • _Not Recommended: Fork TSLint locally_ 🤷‍♂️

👋 It was a pleasure open sourcing with you!

_If you believe this message was posted here in error, please comment so we can re-open the issue!_

🤖 Beep boop! 👉 TSLint is deprecated 👈 _(#4534)_ and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

Was this page helpful?
0 / 5 - 0 ratings