I'm working on an angular2 project and have included grunt-tslint to improve my code. The grunt task "tslint" and default grunt task is workink fine but when I include it to the watch task it's not linting. I tried to delete every other watch task but also not working.
This are my versions:
grunt: v1.0.1
grunt-contrib-watch: 1.0.0
grunt-ts: v6.0.0-beta.3
grunt-tslint: 4.0.0
And the grunt tasks:
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
tslint: {
options: {
configuration: "tslint.json",
force: false,
fix: false
},
files: {
src: ['app/**/*.ts']
}
},
ts: {
default : {
src: ['app/**/*.ts'],
outDir: 'outDir/app/',
tsconfig: './tsconfig.json'
}
},
watch: {
tslint: {
files: ['app/**/*.ts'],
task: ['tslint']
},
ts: {
files: ['app/**/*.ts'],
tasks: ['ts']
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-tslint');
grunt.registerTask('default', [
'ts', 'tslint'
]);
grunt.registerTask('validate:ts', ['tslint']);
};
UPDATE:
Try replacing your watch task with the following instead:
watch: {
ts: {
files: ['app/**/*.ts'],
tasks: ['tslint', 'ts']
}
}
Note:
tslint
has been deleted from your watch
task.tslint
task has now been added to the tasks
array of the ts
target.Now when you run $ grunt watch
the files will be:
tslint
according to the rules defined in tslint.json
.grunt-ts
.Hope this helps!
PREVIOUS ANSWER:
One potential solution is to try reverting to the last stable version of the grunt-ts
package.
To do this:
cd
to your project directory.
Uninstall the current version of grunt-ts
:
$ npm uninstall grunt-ts --save-dev
grunt-ts
(which appears to be 5.5.1)$ npm install [email protected] --save-dev
NOTE: I recommend trying the above with a copy of your project directory to see whether its successful !