panuhorsmalahti / gulp-tslint

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

Warning shown when running gulp-tslint with type checking enabled #110

Closed greimela closed 6 years ago

greimela commented 7 years ago

gulp-tslint version: 7.1.0 tslint version: 4.5.1 typescript version: 2.1.6 Operating system: Ubuntu 16.04


When running gulp-tslint with type checking enabled, the task prints the warning shown in the console output below. What is the reason for these warnings? Any rules specified are checked correctly, as far as I can see.

Console output:

[17:01:51] Starting 'lint:typescript'...
Warning: Cannot read property 'exports' of undefined
[17:01:52] Finished 'lint:typescript' after 1.58 s

Used gulp configuration:

gulp.task('lint:typescript', () => {
    const program = tslint.Linter.createProgram('./tsconfig.json');
    return gulp.src(['src/foo.ts'])
        .pipe(gulpTslint({ program }))
        .pipe(gulpTslint.report({ summarizeFailureOutput: true }));
});

Content of src/foo.ts:

import * as fs from 'fs';
export const foo = {
    test: fs.readFile,
};
panuhorsmalahti commented 7 years ago

Does the error persist with gulp-tslint 8?

greimela commented 7 years ago

Sorry for the late answer, but we were not able to migrate to tslint 5 yet. Therefore I could not test it with gulp-tslint 8 by now.

greimela commented 7 years ago

Follow-up: I was able to fix the error by using ts.getPreEmitDiagnostics(program) as suggested in #105.