Tslint: TSlint doesn't handle dots in filenames (e.g. *.spec.ts)

Created on 12 Jan 2017  路  8Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 4.3.1
  • __TypeScript version__: 2.1.4
  • __Running TSLint via__: CLI

TypeScript code being linted

*.spec.{ts,tsx} files. Using the following command:

tslint -e '**/lib/**' --project tsconfig.json --type-check 'packages/**/*.{ts,tsx}'

with tslint.json configuration:

{
  "extends": ["tslint:latest", "tslint-react"],
  "rules": {
    "interface-over-type-literal": false,
    "jsx-no-multiline-js": false,
    "member-access": false,
    "no-consecutive-blank-lines": false,
    "object-literal-sort-keys": false,
    "ordered-imports": false,
    "quotemark": [true, "jsx-double"]
  }
}

Actual behavior

TSlint shouts at me that:

Error: 
Invalid source file: packages/redux-forms-react/src/__tests__/connectField.spec.tsx. Ensure that the files supplied to lint have a .ts, .tsx, .js or .jsx extension.

Expected behavior

TSlint should be able to correctly test *.spec.{ts,tsx} files.

Most helpful comment

I have the same issue with latest tslint as of today

All 8 comments

@oreqizer have you tried './packages/**/*.{ts,tsx}'? Because packages might be resolved as node module.

aahhh I figured it out - I had **/__tests__/** ignored in tsconfig.json. didn't think that would affect TSlint. closing then!

thanks

This should probably be an error in the API. Seems like TSLint doesn't look at the files list if a tsconfig.json is provided.

@oreqizer Had the same issue, it should be stated somewhere.

Any progress on this? Or is there a workaround?

@DevWurm this is a relatively old issue, please file a new issue with the provided template if you're still hitting this problem with the latest tslint

I have the same issue with latest tslint as of today

If you are running into this problem, when updating an angular-cli project, make sure you delete any "files"-entries from the "lint"-section in .angular-cli.json.

old:

"lint": [
    {
      "files": "src/**/*.ts",
      "project": "src/tsconfig.app.json"
    },
    {
      "files": "src/**/*.ts",
      "project": "src/tsconfig.spec.json"
    },
    {
      "files": "src/**/*.ts",
      "project": "e2e/tsconfig.e2e.json"
    }
  ],

new:

  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
Was this page helpful?
0 / 5 - 0 ratings