Skip to content

Commit c5626c0

Browse files
committed
Make lint checks pass.
1 parent e27e57e commit c5626c0

9 files changed

+276
-93
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#.editorconfig
2+
# Meteor adapted EditorConfig, http://EditorConfig.org
3+
# By RaiX 2013
4+
5+
root = true
6+
7+
[*.js]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 2
12+
trim_trailing_whitespace = true
13+
charset = utf-8
14+
max_line_length = 80
15+
indent_brace_style = 1TBS
16+
spaces_around_operators = true
17+
quote_type = auto
18+
# curly_bracket_next_line = true

.jshintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
client/compatibility
2+
packages

.jshintrc

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
//.jshintrc
2+
{
3+
// JSHint Meteor Configuration File
4+
// Match the Meteor Style Guide
5+
//
6+
// By @raix with contributions from @aldeed and @awatson1978
7+
// Source https://github.com/raix/Meteor-jshintrc
8+
//
9+
// See http://jshint.com/docs/ for more details
10+
11+
"maxerr" : 50, // {int} Maximum error before stopping
12+
13+
// Enforcing
14+
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
15+
"camelcase" : true, // true: Identifiers must be in camelCase
16+
"curly" : true, // true: Require {} for every new block or scope
17+
"eqeqeq" : true, // true: Require triple equals (===) for comparison
18+
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
19+
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
20+
"indent" : 2, // {int} Number of spaces to use for indentation
21+
"latedef" : false, // true: Require variables/functions to be defined before being used
22+
"newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
23+
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
24+
"noempty" : true, // true: Prohibit use of empty blocks
25+
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
26+
"plusplus" : false, // true: Prohibit use of `++` & `--`
27+
"quotmark" : false, // Quotation mark consistency:
28+
// false : do nothing (default)
29+
// true : ensure whatever is used is consistent
30+
// "single" : require single quotes
31+
// "double" : require double quotes
32+
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
33+
"unused" : true, // true: Require all defined variables be used
34+
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
35+
"trailing" : true, // true: Prohibit trailing whitespaces
36+
"maxparams" : false, // {int} Max number of formal params allowed per function
37+
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
38+
"maxstatements" : false, // {int} Max number statements per function
39+
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
40+
"maxlen" : 80, // {int} Max number of characters per line
41+
42+
// Relaxing
43+
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
44+
"boss" : false, // true: Tolerate assignments where comparisons would be expected
45+
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
46+
"eqnull" : false, // true: Tolerate use of `== null`
47+
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
48+
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
49+
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
50+
// (ex: `for each`, multiple try/catch, function expression…)
51+
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
52+
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
53+
"funcscope" : false, // true: Tolerate defining variables inside control statements"
54+
"globalstrict" : true, // true: Allow global "use strict" (also enables 'strict')
55+
"iterator" : false, // true: Tolerate using the `__iterator__` property
56+
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
57+
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
58+
"laxcomma" : false, // true: Tolerate comma-first style coding
59+
"loopfunc" : false, // true: Tolerate functions being defined in loops
60+
"multistr" : false, // true: Tolerate multi-line strings
61+
"proto" : false, // true: Tolerate using the `__proto__` property
62+
"scripturl" : false, // true: Tolerate script-targeted URLs
63+
"smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
64+
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
65+
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
66+
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
67+
"validthis" : false, // true: Tolerate using this in a non-constructor function
68+
69+
// Environments
70+
"browser" : true, // Web Browser (window, document, etc)
71+
"couch" : false, // CouchDB
72+
"devel" : true, // Development/debugging (alert, confirm, etc)
73+
"dojo" : false, // Dojo Toolkit
74+
"jquery" : false, // jQuery
75+
"mootools" : false, // MooTools
76+
"node" : false, // Node.js
77+
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
78+
"prototypejs" : false, // Prototype and Scriptaculous
79+
"rhino" : false, // Rhino
80+
"worker" : false, // Web Workers
81+
"wsh" : false, // Windows Scripting Host
82+
"yui" : false, // Yahoo User Interface
83+
//"meteor" : false, // Meteor.js
84+
85+
// Legacy
86+
"nomen" : false, // true: Prohibit dangling `_` in variables
87+
"onevar" : false, // true: Allow only one `var` statement per function
88+
"passfail" : false, // true: Stop on first error
89+
"white" : false, // true: Check against strict whitespace and indentation rules
90+
91+
// Custom globals, from http://docs.meteor.com, in the order they appear there
92+
"globals" : {
93+
"Meteor": false,
94+
"DDP": false,
95+
"Mongo": false, //Meteor.Collection renamed to Mongo.Collection
96+
"Session": false,
97+
"Accounts": false,
98+
"Template": false,
99+
"Blaze": false, //UI is being renamed Blaze
100+
"UI": false,
101+
"Match": false,
102+
"check": false,
103+
"Tracker": false, //Deps renamed to Tracker
104+
"Deps": false,
105+
"ReactiveVar": false,
106+
"EJSON": false,
107+
"HTTP": false,
108+
"Email": false,
109+
"Assets": false,
110+
"Handlebars": false, // https://github.com/meteor/meteor/wiki/Handlebars
111+
"Package": false,
112+
"App": false, //mobile-config.js
113+
114+
// Meteor internals
115+
"DDPServer": false,
116+
"global": false,
117+
"Log": false,
118+
"MongoInternals": false,
119+
"process": false,
120+
"WebApp": false,
121+
"WebAppInternals": false,
122+
123+
// globals useful when creating Meteor packages
124+
"Npm": false,
125+
"Tinytest": false,
126+
127+
// common Meteor packages
128+
"Random": false,
129+
"_": false, // Underscore.js
130+
"$": false, // jQuery
131+
"Router": false // iron-router
132+
}
133+
}

accounts-anonymous-client-tests.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
"use strict";
2+
/* globals AccountsAnonymous */
3+
14
Tinytest.addAsync('AccountsAnonymous - login()', function (test, onComplete) {
25
Meteor.logout(function (err) {
36
test.isUndefined(err);
47
test.isNull(Meteor.userId(), 'Logged out user should be null');
58
AccountsAnonymous.login(function (err) {
69
test.isUndefined(err);
7-
var firstUserId = Meteor.userId()
10+
var firstUserId = Meteor.userId();
811
test.isNotNull(firstUserId, 'Logged in user should not be null');
912
AccountsAnonymous.login(function (err) {
1013
test.instanceOf(err, Meteor.Error);
1114
test.equal(err.error, AccountsAnonymous._ALREADY_LOGGED_IN_ERROR);
12-
var secondUserId = Meteor.userId()
15+
var secondUserId = Meteor.userId();
1316
test.equal(secondUserId, firstUserId);
1417
Meteor.logout(function (err) {
1518
test.isUndefined(err);
1619
test.isNull(Meteor.userId(), 'Logged out user should be null');
1720
AccountsAnonymous.login(function (err) {
1821
test.isUndefined(err);
19-
var thirdUserId = Meteor.userId()
22+
var thirdUserId = Meteor.userId();
2023
test.isNotNull(thirdUserId);
2124
test.notEqual(thirdUserId, secondUserId);
2225
onComplete();

accounts-anonymous-client.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"use strict";
2+
/* globals AccountsAnonymous */
3+
14
AccountsAnonymous.login = function (callback) {
25
callback = callback || function () {};
36
if (Meteor.userId()) {
@@ -9,12 +12,12 @@ AccountsAnonymous.login = function (callback) {
912
methodArguments: [{
1013
anonymous: true
1114
}],
12-
userCallback: function (error, result) {
15+
userCallback: function (error) {
1316
if (error) {
14-
callback && callback(error);
17+
if (callback) { callback(error); }
1518
} else {
16-
callback && callback();
19+
if (callback) { callback(); }
1720
}
1821
}
1922
});
20-
}
23+
};

accounts-anonymous-server-tests.js

Lines changed: 79 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,87 @@
1-
Tinytest.add('AccountsAnonymous - onAbandoned', function (test) {
2-
AccountsMultiple._unregisterAll();
3-
AccountsAnonymous._init();
4-
AccountsAnonymous.onAbandoned(function (user) {
5-
actualCalls++;
6-
actualId = user._id;
7-
});
8-
var actualCalls = 0;
9-
var expectedCalls = 0;
10-
var expectedId;
11-
var actualId;
12-
var connection = DDP.connect(Meteor.absoluteUrl());
13-
var anonId, pwId;
14-
try {
15-
// User not logged in.
16-
anonId = connection.call('login', { anonymous: true }).id;
17-
test.equal(actualCalls, expectedCalls);
1+
"use strict";
2+
/* globals AccountsMultiple, AccountsAnonymous */
183

19-
// Anonymous user logged in.
20-
expectedId = anonId;
21-
pwId = connection.call('createUser', { email: 'testuser@example.com', password: 'password' }).id;
22-
Meteor.users.remove(pwId);
23-
expectedCalls++;
24-
test.equal(actualCalls, expectedCalls);
25-
test.equal(actualId, anonId);
26-
} finally {
27-
connection.disconnect();
28-
anonId && Meteor.users.remove(anonId);
29-
pwId && Meteor.users.remove(pwId);
4+
Tinytest.add(
5+
'AccountsAnonymous - onAbandoned',
6+
function (test) {
7+
AccountsMultiple._unregisterAll();
8+
AccountsAnonymous._init();
9+
AccountsAnonymous.onAbandoned(function (user) {
10+
actualCalls++;
11+
actualId = user._id;
12+
});
13+
var actualCalls = 0;
14+
var expectedCalls = 0;
15+
var expectedId;
16+
var actualId;
17+
var connection = DDP.connect(Meteor.absoluteUrl());
18+
var anonId, pwId;
19+
try {
20+
// User not logged in.
21+
anonId = connection.call('login', { anonymous: true }).id;
22+
test.equal(actualCalls, expectedCalls);
23+
24+
// Anonymous user logged in.
25+
expectedId = anonId;
26+
pwId = connection.call('createUser',
27+
{ email: 'testuser@example.com', password: 'password' }
28+
).id;
29+
Meteor.users.remove(pwId);
30+
expectedCalls++;
31+
test.equal(actualCalls, expectedCalls);
32+
test.equal(actualId, anonId);
33+
} finally {
34+
connection.disconnect();
35+
if (anonId) { Meteor.users.remove(anonId); }
36+
if (pwId) { Meteor.users.remove(pwId); }
37+
}
3038
}
31-
});
39+
);
3240

33-
Tinytest.add('AccountsAnonymous - onAbandoned - user already removed', function (test) {
34-
AccountsMultiple._unregisterAll();
35-
AccountsAnonymous._init();
36-
var onAbandonedCalls = 0;
37-
AccountsAnonymous.onAbandoned(function (user) {
38-
onAbandonedCalls++;
39-
});
41+
Tinytest.add(
42+
'AccountsAnonymous - onAbandoned - user already removed',
43+
function (test) {
44+
AccountsMultiple._unregisterAll();
45+
AccountsAnonymous._init();
46+
var onAbandonedCalls = 0;
47+
AccountsAnonymous.onAbandoned(function (/* user (unused) */) {
48+
onAbandonedCalls++;
49+
});
4050

41-
var debugCalls = 0;
42-
var origDebug = Meteor._debug;
43-
Meteor._debug = function(/*arguments*/) {
44-
debugCalls++
45-
origDebug.apply(this, arguments);
46-
};
51+
var debugCalls = 0;
52+
var origDebug = Meteor._debug;
53+
Meteor._debug = function(/*arguments*/) {
54+
debugCalls++;
55+
origDebug.apply(this, arguments);
56+
};
4757

48-
var anonId, pwId;
49-
var connection = DDP.connect(Meteor.absoluteUrl());
50-
try {
51-
// Create an anonymous user
52-
anonId = connection.call('login', { anonymous: true }).id;
58+
var anonId, pwId;
59+
var connection = DDP.connect(Meteor.absoluteUrl());
60+
try {
61+
// Create an anonymous user
62+
anonId = connection.call('login', { anonymous: true }).id;
5363

54-
// Add a one-off validateLoginAttempt handler that removes it.
55-
var validateLoginStopper = Accounts.validateLoginAttempt(function() {
56-
validateLoginStopper.stop();
57-
Meteor.users.remove(anonId);
58-
return true;
59-
});
64+
// Add a one-off validateLoginAttempt handler that removes it.
65+
var validateLoginStopper = Accounts.validateLoginAttempt(function() {
66+
validateLoginStopper.stop();
67+
Meteor.users.remove(anonId);
68+
return true;
69+
});
6070

61-
// When we login as a new user, the above handler will remove the attempting
62-
// user. onAbandoned will still fire but no errors should occur.
63-
pwId = connection.call('createUser', { email: 'testuser@example.com', password: 'password' }).id;
64-
Meteor.users.remove(pwId);
65-
test.equal(onAbandonedCalls, 1);
66-
test.equal(debugCalls, 0);
67-
} finally {
68-
connection.disconnect();
69-
Meteor._debug = origDebug;
70-
anonId && Meteor.users.remove(anonId);
71-
pwId && Meteor.users.remove(pwId);
71+
// When we login as a new user, the above handler will remove the
72+
// attempting user. onAbandoned will still fire but no errors should
73+
// occur.
74+
pwId = connection.call('createUser',
75+
{ email: 'testuser@example.com', password: 'password' }
76+
).id;
77+
Meteor.users.remove(pwId);
78+
test.equal(onAbandonedCalls, 1);
79+
test.equal(debugCalls, 0);
80+
} finally {
81+
connection.disconnect();
82+
Meteor._debug = origDebug;
83+
if (anonId) { Meteor.users.remove(anonId); }
84+
if (pwId) { Meteor.users.remove(pwId); }
85+
}
7286
}
73-
});
87+
);

0 commit comments

Comments
 (0)