mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Run appropriate linters
This commit is contained in:
@@ -30,7 +30,7 @@ JsHintLinter.prototype.processFilesForTarget = function (files) {
|
||||
return;
|
||||
}
|
||||
// require configuration file to be called '.jshintrc'
|
||||
if (path.extname(file.getBaseName()) !== 'js') {
|
||||
if (path.extname(file.getBasename()) !== 'js') {
|
||||
file.error("Unrecognized configuration file name. Configuration file should be called .jshintrc");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
var archinfo = require('./archinfo.js');
|
||||
var buildmessage = require('./buildmessage.js');
|
||||
var files = require('./files.js');
|
||||
var buildmessage = require('./buildmessage.js');
|
||||
var _ = require('underscore');
|
||||
|
||||
exports.BuildPluginDefintion = function (options, factoryFunction) {
|
||||
|
||||
@@ -11,6 +11,7 @@ var watch = require('./watch.js');
|
||||
var Console = require('./console.js').Console;
|
||||
var files = require('./files.js');
|
||||
var colonConverter = require('./colon-converter.js');
|
||||
var linterPluginModule = require('./linter-plugin.js');
|
||||
|
||||
var compiler = exports;
|
||||
|
||||
@@ -395,8 +396,43 @@ var compileUnibuild = function (options) {
|
||||
};
|
||||
});
|
||||
|
||||
// For each file choose the longest extension handled by linters.
|
||||
var longestMatchingExt = {};
|
||||
_.each(wrappedSourceItems, function (wrappedSource) {
|
||||
var filename = files.pathBasename(wrappedSource.relPath);
|
||||
var parts = filename.split('.');
|
||||
for (var i = 1; i < parts.length; i++) {
|
||||
var extension = parts.slice(i).join('.');
|
||||
if (_.has(linterPluginsByExtension, extension)) {
|
||||
longestMatchingExt[wrappedSource.relPath] = extension;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
// Run linters on files.
|
||||
_.each(linterPluginsByExtension, function (linters, ext) {
|
||||
// XXX would run linters here
|
||||
var sourcesToLint = [];
|
||||
_.each(wrappedSourceItems, function (wrappedSource) {
|
||||
var relPath = wrappedSource.relPath;
|
||||
var hash = wrappedSource.hash;
|
||||
var fileWatchSet = wrappedSource.watchset;
|
||||
var source = wrappedSource.source;
|
||||
|
||||
// only run linters matching the longest handled extension
|
||||
if (longestMatchingExt[relPath] !== ext)
|
||||
return;
|
||||
|
||||
sourcesToLint.push(new linterPluginModule.LintingFile(wrappedSource));
|
||||
});
|
||||
|
||||
_.each(linters, function (linterDef) {
|
||||
// skip linters not relevant to the arch we are compiling for
|
||||
if (! linterDef.relevantForArch(inputSourceArch.arch))
|
||||
return;
|
||||
|
||||
var linter = linterDef.instantiatePlugin();
|
||||
linter.run(sourcesToLint);
|
||||
});
|
||||
});
|
||||
|
||||
_.each(wrappedSourceItems, function (wrappedSource) {
|
||||
|
||||
@@ -8,10 +8,15 @@ exports.LinterPlugin = function (pluginDefinition, userPlugin) {
|
||||
self.pluginDefinition = pluginDefinition;
|
||||
};
|
||||
_.extend(exports.LinterPlugin.prototype, {
|
||||
run: function () {}
|
||||
run: function (lintingFiles) {
|
||||
var self = this;
|
||||
self.userPlugin.processFilesForTarget(lintingFiles);
|
||||
}
|
||||
});
|
||||
|
||||
var LintingFile = function (source) {
|
||||
var LintingFile = exports.LintingFile = function (source) {
|
||||
buildPluginModule.InputFile.call(this);
|
||||
|
||||
var self = this;
|
||||
self._source = source;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user