Skip to content

Commit 01b2352

Browse files
committed
Merge pull request #1327 from SergioCrisostomo/eslint
Add ESLint, code stye polish
2 parents ad17ac4 + 0682c60 commit 01b2352

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2326
-1480
lines changed

.eslintrc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root: true
2+
3+
extends: 'eslint:recommended'
4+
5+
rules:
6+
no-cond-assign: 0
7+
no-constant-condition: 0
8+
no-console: 0
9+
no-empty: 0
10+
no-extra-semi: 0
11+
no-octal: 0
12+
no-undef: 0
13+
no-unused-vars: 0
14+
linebreak-style: [2, unix]
15+
no-trailing-spaces: 2
16+
no-unneeded-ternary: 2
17+
quotes: [2, single, avoid-escape]
18+
semi: 2
19+
semi-spacing: 2
20+
mootools-indent: [2, tab, {SwitchCase: 1, VariableDeclarator: 1, IndentRootIIFE: false}]
21+
mootools-whitespace: 2

Gruntfile.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
"use strict";
1+
'use strict';
22

3-
module.exports = function(grunt) {
3+
module.exports = function(grunt){
44

55
require('load-grunt-tasks')(grunt);
66
var browser = process.env.BROWSER;
77
var travisBuild = process.env.BUILD;
88
var pullRequest = process.env.TRAVIS_PULL_REQUEST;
99

1010
grunt.initConfig({
11+
eslint: {
12+
target: ['Gruntfile.js', 'Specs/**/*.js', 'Source/**/*.js'],
13+
options: {
14+
rulePaths: ['Tests/eslint/rules']
15+
}
16+
},
17+
1118
'connect': {
1219
testserver: {
1320
options: {
@@ -16,11 +23,11 @@ module.exports = function(grunt) {
1623
// to avoid https://github.com/joyent/libuv/issues/826
1724
port: 8000,
1825
hostname: '0.0.0.0',
19-
middleware: function(connect, options) {
26+
middleware: function(connect, options){
2027
return [
21-
function(req, resp, next) {
28+
function(req, resp, next){
2229
// cache get requests to speed up tests on travis
23-
if (req.method === 'GET') {
30+
if (req.method === 'GET'){
2431
resp.setHeader('Cache-control', 'public, max-age=3600');
2532
}
2633

@@ -37,7 +44,7 @@ module.exports = function(grunt) {
3744

3845
options: {
3946
name: {
40-
More: 'Source/',
47+
More: 'Source/',
4148
Core: 'node_modules/mootools-core/'
4249
}
4350
},
@@ -86,8 +93,8 @@ module.exports = function(grunt) {
8693
singleRun: true,
8794
frameworks: ['jasmine', 'sinon'],
8895
files: [
89-
'Tests/Utilities/*.js',
90-
'mootools-*.js',
96+
'Tests/Utilities/*.js',
97+
'mootools-*.js',
9198
{pattern: 'Tests/Specs/assets/*.*', included: false, served: true}
9299
],
93100
sauceLabs: {
@@ -194,7 +201,7 @@ module.exports = function(grunt) {
194201
version: '6',
195202
deviceOrientation: 'portrait'
196203
}
197-
},
204+
}
198205
},
199206

200207
continuous: {
@@ -221,8 +228,8 @@ module.exports = function(grunt) {
221228

222229
});
223230

224-
var compatBuild = ['clean', 'packager:all', 'packager:specs'];
225-
var nocompatBuild = ['clean', 'packager:morenocompat', 'packager:specs-nocompat'];
231+
var compatBuild = ['clean', 'eslint', 'packager:all', 'packager:specs'];
232+
var nocompatBuild = ['clean', 'eslint', 'packager:morenocompat', 'packager:specs-nocompat'];
226233

227234
var tasks = travisBuild == 'default' ? compatBuild : nocompatBuild;
228235
tasks = pullRequest != 'false' ? tasks.concat('karma:continuous') : tasks.concat('karma:sauceTask');

Source/Class/Chain.Wait.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,39 @@ provides: [Chain.Wait]
2525

2626
(function(){
2727

28-
var wait = {
29-
wait: function(duration){
30-
return this.chain(function(){
31-
this.callChain.delay(duration == null ? 500 : duration, this);
32-
return this;
33-
}.bind(this));
34-
}
35-
};
28+
var wait = {
29+
wait: function(duration){
30+
return this.chain(function(){
31+
this.callChain.delay(duration == null ? 500 : duration, this);
32+
return this;
33+
}.bind(this));
34+
}
35+
};
3636

37-
Chain.implement(wait);
37+
Chain.implement(wait);
3838

39-
if (this.Fx) Fx.implement(wait);
39+
if (this.Fx) Fx.implement(wait);
4040

41-
if (this.Element && Element.implement && this.Fx){
42-
Element.implement({
41+
if (this.Element && Element.implement && this.Fx){
42+
Element.implement({
4343

44-
chains: function(effects){
45-
Array.from(effects || ['tween', 'morph', 'reveal']).each(function(effect){
46-
effect = this.get(effect);
47-
if (!effect) return;
48-
effect.setOptions({
49-
link:'chain'
50-
});
51-
}, this);
52-
return this;
53-
},
44+
chains: function(effects){
45+
Array.from(effects || ['tween', 'morph', 'reveal']).each(function(effect){
46+
effect = this.get(effect);
47+
if (!effect) return;
48+
effect.setOptions({
49+
link:'chain'
50+
});
51+
}, this);
52+
return this;
53+
},
5454

55-
pauseFx: function(duration, effect){
56-
this.chains(effect).get(effect || 'tween').wait(duration);
57-
return this;
58-
}
55+
pauseFx: function(duration, effect){
56+
this.chains(effect).get(effect || 'tween').wait(duration);
57+
return this;
58+
}
5959

60-
});
61-
}
60+
});
61+
}
6262

6363
})();

Source/Class/Class.Singleton.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ provides: [Class.Singleton]
2121
*/
2222

2323
Class.Singleton = new Class({
24-
24+
2525
initialize : function(descriptor){
2626
// here we keep reference of the single instance
2727
var singleton;
@@ -34,18 +34,18 @@ Class.Singleton = new Class({
3434
return singleton;
3535
}
3636
// Obviously we instantiate that class for the first time.
37-
// Create brand new object & extend it with the prototype of the
37+
// Create brand new object & extend it with the prototype of the
3838
// original `constructor`.
3939
singleton = Object.append({}, constructor.prototype);
4040
singleton.constructor = constructor;
41-
// We also need to call the constructor as a function, passing the
41+
// We also need to call the constructor as a function, passing the
4242
// arguments object.
43-
var return_value = constructor.apply(singleton, arguments);
44-
// In case the `constructor` returns something other than `this` -
43+
var returnValue = constructor.apply(singleton, arguments);
44+
// In case the `constructor` returns something other than `this` -
4545
// return that value; otherwise return the `singleton`.
46-
singleton = typeof return_value == 'object' ? return_value : singleton;
46+
singleton = typeof returnValue == 'object' ? returnValue : singleton;
4747
return singleton;
4848
};
4949
}
50-
50+
5151
});

Source/Drag/Drag.Move.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ Drag.Move = new Class({
6262
this.addEvent('start', this.checkDroppables, true);
6363
this.overed = null;
6464
},
65-
66-
setContainer: function(container) {
65+
66+
setContainer: function(container){
6767
this.container = document.id(container);
6868
if (this.container && typeOf(this.container) != 'element'){
6969
this.container = document.id(this.container.getDocument().body);

Source/Drag/Drag.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ var Drag = this.Drag = new Class({
135135

136136
start: function(event){
137137
if (this.options.unDraggableTags.contains(event.target.get('tag'))) return;
138-
138+
139139
var options = this.options;
140140

141141
if (event.rightClick) return;

Source/Drag/Slider.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ var Slider = this.Slider = new Class({
168168
if (range) this.set(Array.pick([pos, this.step]).limit(this.min,this.max), silently);
169169
return this;
170170
},
171-
171+
172172
setModulus: function(){
173173
var decimals = ((this.stepSize + '').split('.')[1] || []).length,
174174
modulus = 1 + '';

Source/Drag/Sortables.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ var Sortables = this.Sortables = new Class({
105105
return list;
106106
}, this));
107107
},
108-
109-
getDroppableCoordinates: function (element){
108+
109+
getDroppableCoordinates: function(element){
110110
var offsetParent = element.getOffsetParent();
111111
var position = element.getPosition(offsetParent);
112112
var scroll = {
@@ -121,7 +121,7 @@ var Sortables = this.Sortables = new Class({
121121
position.y -= scroll.w.y;
122122
}
123123

124-
return position;
124+
return position;
125125
},
126126

127127
getClone: function(event, element){
@@ -227,7 +227,7 @@ var Sortables = this.Sortables = new Class({
227227
this.clone.destroy();
228228
self.reset();
229229
}
230-
230+
231231
},
232232

233233
reset: function(){

Source/Element/Element.Event.Pseudos.Keys.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ DOMEvent.defineKeys({
8080
'107': '+',
8181
'109': '-', // subtract
8282
'189': '-' // dash
83-
})
83+
});
8484

8585
})();

Source/Element/Element.Measure.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,16 @@ Element.implement({
100100
} else if (parent){
101101
try { //safari sometimes crashes here, so catch it
102102
dim = getSize(this, options);
103-
}catch(e){}
103+
} catch (e){}
104104
}
105105

106106
return Object.append(dim, (dim.x || dim.x === 0) ? {
107-
width: dim.x,
108-
height: dim.y
109-
} : {
110-
x: dim.width,
111-
y: dim.height
112-
}
113-
);
107+
width: dim.x,
108+
height: dim.y
109+
} : {
110+
x: dim.width,
111+
y: dim.height
112+
});
114113
},
115114

116115
getComputedSize: function(options){

0 commit comments

Comments
 (0)