mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Tests for linting
This commit is contained in:
3
tools/tests/apps/linting-app/.jshintrc
Normal file
3
tools/tests/apps/linting-app/.jshintrc
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"undef": true
|
||||
}
|
||||
1
tools/tests/apps/linting-app/.meteor/.gitignore
vendored
Normal file
1
tools/tests/apps/linting-app/.meteor/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
local
|
||||
1
tools/tests/apps/linting-app/.meteor/.id
Normal file
1
tools/tests/apps/linting-app/.meteor/.id
Normal file
@@ -0,0 +1 @@
|
||||
1da9lx3m24vwv1kt1w0a
|
||||
8
tools/tests/apps/linting-app/.meteor/packages
Normal file
8
tools/tests/apps/linting-app/.meteor/packages
Normal file
@@ -0,0 +1,8 @@
|
||||
# Meteor packages used by this project, one per line.
|
||||
#
|
||||
# 'meteor add' and 'meteor remove' will edit this file for you,
|
||||
# but you can also edit it by hand.
|
||||
|
||||
meteor-platform
|
||||
my-package
|
||||
jshint
|
||||
2
tools/tests/apps/linting-app/.meteor/platforms
Normal file
2
tools/tests/apps/linting-app/.meteor/platforms
Normal file
@@ -0,0 +1,2 @@
|
||||
browser
|
||||
server
|
||||
1
tools/tests/apps/linting-app/.meteor/release
Normal file
1
tools/tests/apps/linting-app/.meteor/release
Normal file
@@ -0,0 +1 @@
|
||||
none
|
||||
56
tools/tests/apps/linting-app/.meteor/versions
Normal file
56
tools/tests/apps/linting-app/.meteor/versions
Normal file
@@ -0,0 +1,56 @@
|
||||
autoupdate@1.2.2
|
||||
base64@1.0.3
|
||||
binary-heap@1.0.3
|
||||
blaze@2.1.2
|
||||
blaze-tools@1.0.3
|
||||
boilerplate-generator@1.0.3
|
||||
callback-hook@1.0.3
|
||||
check@1.0.5
|
||||
compiler-plugin@1.0.0
|
||||
ddp@1.2.0
|
||||
ddp-client@1.2.0
|
||||
ddp-common@1.2.0
|
||||
ddp-server@1.2.0
|
||||
deps@1.0.7
|
||||
diff-sequence@1.0.0
|
||||
ejson@1.0.6
|
||||
fastclick@1.0.6
|
||||
geojson-utils@1.0.3
|
||||
html-tools@1.0.4
|
||||
htmljs@1.0.4
|
||||
http@1.1.0
|
||||
id-map@1.0.3
|
||||
jquery@1.11.3_2
|
||||
jshint@0.0.1
|
||||
json@1.0.3
|
||||
launch-screen@1.0.3
|
||||
linter-plugin@1.0.0
|
||||
livedata@1.0.13
|
||||
logging@1.0.8
|
||||
meteor@1.1.6
|
||||
meteor-platform@1.2.2
|
||||
minifiers@1.1.5
|
||||
minimongo@1.0.8
|
||||
mobile-status-bar@1.0.4
|
||||
mongo@1.1.0
|
||||
mongo-id@1.0.0
|
||||
my-package@0.0.0
|
||||
npm-mongo@1.4.32_1
|
||||
observe-sequence@1.0.6
|
||||
ordered-dict@1.0.3
|
||||
random@1.0.3
|
||||
reactive-dict@1.1.0
|
||||
reactive-var@1.0.5
|
||||
reload@1.1.3
|
||||
retry@1.0.3
|
||||
routepolicy@1.0.5
|
||||
session@1.1.0
|
||||
spacebars@1.0.6
|
||||
spacebars-compiler@1.0.6
|
||||
templating@1.1.1
|
||||
tracker@1.0.7
|
||||
ui@1.0.6
|
||||
underscore@1.0.3
|
||||
url@1.0.4
|
||||
webapp@1.2.1
|
||||
webapp-hashing@1.0.3
|
||||
3
tools/tests/apps/linting-app/a.html
Normal file
3
tools/tests/apps/linting-app/a.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<body>
|
||||
no content
|
||||
</body>
|
||||
1
tools/tests/apps/linting-app/client/client.js
Normal file
1
tools/tests/apps/linting-app/client/client.js
Normal file
@@ -0,0 +1 @@
|
||||
GlobalVar = {};
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"undef": true
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
PackageGlobalVar = {};
|
||||
@@ -0,0 +1,3 @@
|
||||
PackageGlobalVar = {};
|
||||
PermittedGlobal = {};
|
||||
Package.minimongo.accessPackageVarInMeteor = "is OK";
|
||||
11
tools/tests/apps/linting-app/packages/my-package/package.js
Normal file
11
tools/tests/apps/linting-app/packages/my-package/package.js
Normal file
@@ -0,0 +1,11 @@
|
||||
Package.describe({
|
||||
summary: "test local package for using linting"
|
||||
});
|
||||
|
||||
Package.onUse(function (api) {
|
||||
api.addFiles('package-client.js', 'client');
|
||||
api.addFiles('package-server.js', 'server');
|
||||
api.addFiles('.jshintrc');
|
||||
|
||||
api.use('jshint');
|
||||
});
|
||||
1
tools/tests/apps/linting-app/server/server.js
Normal file
1
tools/tests/apps/linting-app/server/server.js
Normal file
@@ -0,0 +1 @@
|
||||
GlobalVar = {};
|
||||
144
tools/tests/linter-plugins.js
Normal file
144
tools/tests/linter-plugins.js
Normal file
@@ -0,0 +1,144 @@
|
||||
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('Linting 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'/
|
||||
];
|
||||
|
||||
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();
|
||||
});
|
||||
Reference in New Issue
Block a user