mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
There were a few problems here: - compiler.lint actually did things that could seriously fail (eg loading plugins) but used its buildmessage context to return *linter warnings*. So actual errors got lumped in with warnings and didn't prevent builds. Fixed this by changing compiler.lint to return linter warnings as a return value and use its implicit buildmessage context only for build errors - We weren't checking for errors after compiler.getMinifiers even though that loaded plugins and could fail - We were using _.isEmpty(app.sourceProcessors.linter) to decide in lintBundle if we should say "no linter warnings" or "no linters were run", but this is a SourceProcessorSet now, not a dictionary, so we should have used the isEmpty method instead (so we were getting unnecessary "No linting errors" messages when there were no linters) - compiler.compile still tried to run getSourcesFunc even if initializing the SourceProcessorSets failed - Printing linter warnings in the runner looked different depending on whether it was right after doing a client refresh or not - We were doing a temporary log of "Linting your app" and immediately logging "Linted your app". The point of temporary logs is to display while long processes run, but since linting is integrated, this didn't really make sense. (Really we need to better integrate the progress bar and runlog, since progress fulfills most of the needs formerly done by the runlog.)
147 lines
4.0 KiB
JavaScript
147 lines
4.0 KiB
JavaScript
var selftest = require('../selftest.js');
|
|
var files = require('../files.js');
|
|
|
|
var Sandbox = selftest.Sandbox;
|
|
|
|
var MONGO_LISTENING =
|
|
{ stdout: " [initandlisten] waiting for connections on port" };
|
|
|
|
function startRun(sandbox, ...args) {
|
|
var run = sandbox.run(...args);
|
|
run.match('myapp');
|
|
run.match('proxy');
|
|
run.tellMongo(MONGO_LISTENING);
|
|
run.match("MongoDB");
|
|
return run;
|
|
};
|
|
|
|
function matchLintingMessages(run, messages, initial) {
|
|
run.match('Linted your app.');
|
|
messages.forEach(message => run.match(message));
|
|
if (initial) {
|
|
run.match('Started your app.');
|
|
run.match('App running at');
|
|
} else {
|
|
run.match('Meteor server restarted');
|
|
}
|
|
}
|
|
|
|
selftest.define('linter plugins - linting app with local packages', () => {
|
|
const s = new Sandbox({ fakeMongo: true });
|
|
|
|
// Create an app that uses coffeescript and less.
|
|
s.createApp('myapp', 'linting-app');
|
|
s.cd('myapp');
|
|
|
|
const run = startRun(s);
|
|
|
|
matchLintingMessages(run, [
|
|
/While linting files .* app .*Server/,
|
|
/server\.js:1:1: 'GlobalVar'/,
|
|
/While linting files .* app .*Client/,
|
|
/client\.js:1:1: 'GlobalVar'/,
|
|
/While linting files .* my-package .*Server/,
|
|
/package-server\.js:1:1: 'PackageGlobalVar'/,
|
|
/package-server\.js:2:1: 'PermittedGlobal'/,
|
|
/While linting files .* my-package .*Client/,
|
|
/package-client\.js:1:1: 'PackageGlobalVar'/
|
|
], true);
|
|
|
|
s.write('.jshintrc', JSON.stringify({
|
|
undef: false
|
|
}));
|
|
|
|
matchLintingMessages(run, [
|
|
/While linting files .* my-package .*Server/,
|
|
/package-server\.js:1:1: 'PackageGlobalVar'/,
|
|
/package-server\.js:2:1: 'PermittedGlobal'/,
|
|
/While linting files .* my-package .*Client/,
|
|
/package-client\.js:1:1: 'PackageGlobalVar'/
|
|
]);
|
|
|
|
s.write('packages/my-package/.jshintrc', JSON.stringify({
|
|
undef: true,
|
|
predef: ['PermittedGlobal']
|
|
}));
|
|
|
|
// no warnings should be printed
|
|
matchLintingMessages(run, [
|
|
/While linting files .* my-package .*Server/,
|
|
/package-server\.js:1:1: 'PackageGlobalVar'/,
|
|
/While linting files .* my-package .*Client/,
|
|
/package-client\.js:1:1: 'PackageGlobalVar'/
|
|
]);
|
|
|
|
run.stop();
|
|
});
|
|
|
|
|
|
selftest.define('linter plugins - linting app with local packages with `meteor lint`', () => {
|
|
const s = new Sandbox({ fakeMongo: true });
|
|
|
|
// Create an app that uses coffeescript and less.
|
|
s.createApp('myapp', 'linting-app');
|
|
s.cd('myapp');
|
|
|
|
const run = s.run('lint');
|
|
|
|
const messages = [
|
|
/While linting files .* app .*Server/,
|
|
/server\.js:1:1: 'GlobalVar'/,
|
|
/While linting files .* app .*Client/,
|
|
/client\.js:1:1: 'GlobalVar'/,
|
|
/While linting files .* my-package .*Server/,
|
|
/package-server\.js:1:1: 'PackageGlobalVar'/,
|
|
/package-server\.js:2:1: 'PermittedGlobal'/,
|
|
/While linting files .* my-package .*Client/,
|
|
/package-client\.js:1:1: 'PackageGlobalVar'/
|
|
];
|
|
|
|
messages.forEach(message => run.matchErr(message));
|
|
run.expectExit(1);
|
|
});
|
|
|
|
selftest.define('linter plugins - linting package with `meteor lint`', () => {
|
|
const s = new Sandbox({ fakeMongo: true });
|
|
|
|
// Create an app that uses coffeescript and less.
|
|
s.createApp('myapp', 'linting-app');
|
|
s.cd('myapp/packages/my-package');
|
|
|
|
const run = s.run('lint');
|
|
|
|
const messages = [
|
|
/While linting files .* my-package .*Server/,
|
|
/package-server\.js:1:1: 'PackageGlobalVar'/,
|
|
/package-server\.js:2:1: 'PermittedGlobal'/,
|
|
/While linting files .* my-package .*Client/,
|
|
/package-client\.js:1:1: 'PackageGlobalVar'/,
|
|
/While linting files .* my-package .*Cordova/,
|
|
/package-client\.js:1:1: 'PackageGlobalVar'/
|
|
];
|
|
|
|
messages.forEach(message => run.matchErr(message));
|
|
|
|
run.forbid('app');
|
|
|
|
run.expectExit(1);
|
|
});
|
|
|
|
selftest.define('linter plugins - running with --no-lint', () => {
|
|
const s = new Sandbox({ fakeMongo: true });
|
|
|
|
// Create an app that uses coffeescript and less.
|
|
s.createApp('myapp', 'linting-app');
|
|
s.cd('myapp');
|
|
|
|
const run = startRun(s, '--no-lint');
|
|
|
|
run.forbid('Linting');
|
|
run.forbid('linting');
|
|
run.forbid('is not defined');
|
|
|
|
run.match('Started your app');
|
|
|
|
run.stop();
|
|
});
|