Exemplo n.º 1
0
 fs.readFile(filePath, 'utf8', function (err, contents) {
     if (err) {
         // don't care if there was an error
         // let's just move on with our lives
         resolve();
         return;
     }
     try {
         var configuration = tslint_1.findConfiguration(null, filePath);
         var linter = new Linter(filePath, contents, {
             configuration: configuration,
             formatter: null,
             formattersDirectory: null,
             rulesDirectory: null,
         }, program);
         var lintResult = linter.lint();
         if (lintResult && lintResult.failures) {
             var diagnostics = logger_tslint_1.runTsLintDiagnostics(context, lintResult.failures);
             logger_diagnostics_1.printDiagnostics(context, logger_diagnostics_1.DiagnosticsType.TsLint, diagnostics, true, false);
         }
     }
     catch (e) {
         logger_1.Logger.debug("Linter " + e);
     }
     resolve();
 });
Exemplo n.º 2
0
	const tsl = es.through(function(file) {
		const configuration = tslint.findConfiguration(null, '.');
		const options = { configuration, formatter: 'json', rulesDirectory: 'build/lib/tslint' };
		const contents = file.contents.toString('utf8');
		const linter = new tslint(file.relative, contents, options);
		const result = linter.lint();

		if (result.failureCount > 0) {
			reportFailures(result.failures);
			errorCount += result.failureCount;
		}

		this.emit('data', file);
	});
Exemplo n.º 3
0
        grunt.util.async.reduce(this.filesSrc, true, function (success, filepath, callback) {
            if (!grunt.file.exists(filepath)) {
                grunt.log.warn('Source file "' + filepath + '" not found.');
            } else {
                var configuration = specifiedConfiguration;
                if (configuration == null || typeof configuration === "string") {
                    configuration = Linter.findConfiguration(configuration, filepath);
                }
                options.configuration = configuration;

                var contents = grunt.file.read(filepath);
                var linter = new Linter(filepath, contents, options);
                var result = linter.lint();

                if (result.failureCount > 0) {
                    var outputString = "";
                    var outputFile = options.outputFile;
                    var appendToOutput = options.appendToOutput;

                    failed += result.failureCount;

                    if (outputFile != null && grunt.file.exists(outputFile)) {
                        if (appendToOutput) {
                            outputString = grunt.file.read(outputFile);
                        } else {
                            grunt.file.delete(outputFile);
                        }
                    }
                    result.output.split("\n").forEach(function (line) {
                        if (line !== "") {
                            if (outputFile != null) {
                                outputString += line + "\n";
                            } else {
                                grunt.log.error(line);
                            }
                        }
                    });
                    if (outputFile != null) {
                        grunt.file.write(outputFile, outputString);
                    }
                    success = false;
                }
            }

            // Using setTimout as process.nextTick() doesn't flush
            setTimeout(function () {
                callback(null, success);
            }, 1);

        }, function (err, success) {
Exemplo n.º 4
0
	var tsl = es.through(function(file) {
		var configuration = tslint.findConfiguration(null, '.');
		var options = {
			formatter: 'json',
			configuration: configuration,
			rulesDirectory: 'build/lib/tslint',
		};
		var contents = file.contents.toString('utf8');
		var linter = new tslint(file.relative, contents, options);
		var result = linter.lint();
		if (result.failureCount > 0) {
			result.failures.forEach(failureReporter);
			errorCount += result.failureCount;
		}
		this.emit('data', file);
	});