panuhorsmalahti / gulp-tslint

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

how ro call tslint with parameter using gulp-tslint ? #136

Open sirentek opened 7 years ago

sirentek commented 7 years ago

gulp-tslint version: 8.1.2 tslint version: 5.6 Operating system: Windows10

Example gulpclass.ts task:


import * as tslint from 'gulp-tslint';
.....

  @Task()
  private analyseTypescript() {
    let options = { 
      summarizeFailureOutput: true 
    };

    return gulp.src(['./src/**/*.ts', '!**/*.d.ts', '!node_modules/**'])
      .pipe(tslint.default())
      .pipe(tslint.default.report(options));
  }

Console output: Warning: The 'no-use-before-declare' rule requires type information.

adding type-check parameter in command line solves it: tslint --type-check --project tslint.json =>Warning goes away.

how could we add type-check parameter in gulp-tslint ? I couldn't find a similar example..

Thanks!

davehensley commented 6 years ago

Usually the project configuration (--project) is tsconfig.json, whereas tslint.json is (obviously) the tslint configuration (--config).

Anyway, you just need to add another pipe:

.pipe(tslint({program: require("tslint").Linter.createProgram("./tsconfig.json")}))

Link