panuhorsmalahti / gulp-tslint

TypeScript linter plugin for Gulp
MIT License
118 stars 44 forks source link

Invalid source file for `a.pass.ts` #121

Open unional opened 7 years ago

unional commented 7 years ago

gulp-tslint version: 7.1.0 tslint version: 5.2.0 Operating system: OSX

Example gulp configuration (if applicable): With type-checking

function positiveTest(config) {
  var program = tslint.Linter.createProgram('./tsconfig.json')
  return gulp.src(`spec/${config}/*.pass.ts`)
    .pipe(gulpTslint({
      configuration: `./${config}.js`,
      formatter: 'verbose',
      program
    }))
    .pipe(gulpTslint.report());
}

Error console output:

Error:
Invalid source file: align.pass.ts. Ensure that the files supplied to lint have a .ts, .tsx, .js or .jsx extension.

    at Linter.getSourceFile (/Users/hwong/github/unional/tslint-config-unional/node_modules/tslint/lib/linter.js:207:23)
    at Linter.lint (/Users/hwong/github/unional/tslint-config-unional/node_modules/tslint/lib/linter.js:74:31)
    at /Users/hwong/github/unional/tslint-config-unional/node_modules/gulp-tslint/index.js:102:16
panuhorsmalahti commented 7 years ago

Do you get the same error when running tslint manually using the cli?

unional commented 7 years ago

Nope.

panuhorsmalahti commented 7 years ago

You should update to gulp-tslint 8, then try if the error persists.

ishitatsuyuki commented 7 years ago

I have reproduced the case. The trick here is that if you tried to lint something that isn't covered by tsconfig.json globs, it result in undefined source, triggering the failure. For my case, it was node_modules, so adjusting the glob deliberately to exclude irrelevant files solved the error.

sompylasar commented 7 years ago

Refs https://github.com/palantir/tslint/issues/2208