Skip to content

Commit 1b6d718

Browse files
authored
Merge pull request #114 from wmde/eslint
Use eslints tests instead of jshint
2 parents 05f2d96 + 9dd5f9f commit 1b6d718

21 files changed

+137
-145
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lib/jquery/**
2+
lib/qunit/**
3+
lib/qunit.parameterize/**
4+
lib/require/**
5+
node_modules/**
6+
vendor/**

.eslintrc.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"extends": "wikimedia",
3+
"env": {
4+
"browser": true,
5+
"jquery": true
6+
},
7+
"globals": {
8+
"dataValues": false,
9+
"define": false,
10+
"globeCoordinate": false,
11+
"module": "false",
12+
"QUnit": false,
13+
"util": false,
14+
"valueFormatters": false,
15+
"valueParsers": false,
16+
"wikibase": false
17+
},
18+
"rules": {
19+
"computed-property-spacing": "off",
20+
"indent": "off",
21+
"keyword-spacing": "off",
22+
"no-loop-func": "off",
23+
"no-underscore-dangle": "off",
24+
"no-unused-vars": "off",
25+
"one-var": "off",
26+
"operator-linebreak": "off",
27+
"quote-props": "off",
28+
"space-before-function-paren": "off",
29+
"space-infix-ops": "off",
30+
"valid-jsdoc": "off",
31+
"vars-on-top": "off"
32+
}
33+
}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ composer.lock
77
!.*
88
.idea/
99

10+
node_modules/
1011
vendor/
11-
build/
12+
build/

.jshintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 46 deletions
This file was deleted.

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ php:
44
- 5.5
55

66
env:
7-
- RUNJOB=jshint
7+
- RUNJOB=eslint
88
- RUNJOB=qunit
99

10+
before_script:
11+
- nvm install 4
12+
1013
script: bash ./build/travis/script.sh
1114

1215
notifications:

build/travis/script.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
set -x
44

5-
if [[ $RUNJOB == jshint ]]; then
6-
npm install jshint
7-
jshint src/ lib/ tests/
5+
if [[ $RUNJOB == eslint ]]; then
6+
npm install eslint
7+
npm install --save eslint-config-wikimedia
8+
./node_modules/.bin/eslint .
89
exit $?
910
fi
1011

config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ this.config = ( function() {
3838
},
3939
'qunit.parameterize': {
4040
exports: 'QUnit.cases',
41-
deps: ['qunit']
41+
deps: [ 'qunit' ]
4242
},
4343

4444
'util/util.inherit': {
@@ -50,17 +50,17 @@ this.config = ( function() {
5050
},
5151
'globeCoordinate/globeCoordinate.GlobeCoordinate': {
5252
exports: 'globeCoordinate.GlobeCoordinate',
53-
deps: ['globeCoordinate/globeCoordinate']
53+
deps: [ 'globeCoordinate/globeCoordinate' ]
5454
},
5555
'globeCoordinate/globeCoordinate.Formatter': {
5656
exports: 'globeCoordinate.Formatter',
57-
deps: ['globeCoordinate/globeCoordinate']
57+
deps: [ 'globeCoordinate/globeCoordinate' ]
5858
},
5959

6060
'dataValues/dataValues': {
6161
exports: 'dataValues'
6262
},
63-
'dataValues/DataValue': ['dataValues/dataValues', 'jquery', 'util/util.inherit'],
63+
'dataValues/DataValue': [ 'dataValues/dataValues', 'jquery', 'util/util.inherit' ],
6464

6565
'values/BoolValue': [
6666
'dataValues/dataValues', 'jquery', 'dataValues/DataValue', 'util/util.inherit'
@@ -109,7 +109,7 @@ this.config = ( function() {
109109
},
110110
'valueFormatters/ValueFormatterStore': {
111111
exports: 'valueFormatters.ValueFormatterStore',
112-
deps: ['valueFormatters/valueFormatters', 'jquery']
112+
deps: [ 'valueFormatters/valueFormatters', 'jquery' ]
113113
},
114114

115115
'formatters/NullFormatter': [
@@ -136,7 +136,7 @@ this.config = ( function() {
136136
},
137137
'valueParsers/ValueParserStore': {
138138
exports: 'valueParsers.ValueParserStore',
139-
deps: ['valueParsers/valueParsers', 'jquery']
139+
deps: [ 'valueParsers/valueParsers', 'jquery' ]
140140
},
141141

142142
'parsers/BoolParser': [
@@ -163,7 +163,7 @@ this.config = ( function() {
163163
'parsers/ValueParser',
164164
'values/StringValue'
165165
],
166-
'parsers/ValueParser': ['valueParsers/valueParsers', 'util/util.inherit', 'jquery'],
166+
'parsers/ValueParser': [ 'valueParsers/valueParsers', 'util/util.inherit', 'jquery' ],
167167

168168
// TODO: These tests should not require any specific DataValue constructor but rather
169169
// use mocks. Properly define the module after removing the dependencies:
@@ -232,4 +232,4 @@ this.config = ( function() {
232232
]
233233
};
234234

235-
} )();
235+
}() );

lib/TestRunner/TestRunner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ this.TestRunner = ( function( console ) {
169169
}
170170
}
171171
return params;
172-
} )( window.location.search.substr( 1 ).split( '&' ) );
172+
}( window.location.search.substr( 1 ).split( '&' ) ) );
173173

174174
for( var i = 0; i < testModules.length; i++ ) {
175175
if( testModules[i] === queryString.test ) {
176-
return [queryString.test];
176+
return [ queryString.test ];
177177
}
178178
}
179179

lib/globeCoordinate/globeCoordinate.Formatter.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@
9191
longitude = globeCoordinate.toDecimal( longitude, precision );
9292
}
9393

94-
return ''
95-
+ latitude
94+
return String( latitude )
9695
+ this._options.latLongCombinator
9796
+ longitude;
9897
},
@@ -112,14 +111,13 @@
112111
if( number === undefined ) {
113112
return '';
114113
}
115-
return number + sign;
114+
return String( number ) + sign;
116115
};
117116

118117
var latDeg = globeCoordinate.toDegree( lat, precision ),
119118
longDeg = globeCoordinate.toDegree( lon, precision );
120119

121-
return ''
122-
+ text( Math.abs( latDeg.degree ), this._options.degree )
120+
return text( Math.abs( latDeg.degree ), this._options.degree )
123121
+ text( latDeg.minute, this._options.minute )
124122
+ text( latDeg.second, this._options.second )
125123
+ ( ( lat < 0 ) ? this._options.south : this._options.north )

lib/globeCoordinate/globeCoordinate.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ this.globeCoordinate = ( function() {
7676
// JavaScript may cause some disturbance regarding rounding and precision. The
7777
// result should not have a higher floating point number precision than the
7878
// applied precision.
79-
var degreeFloat = ( '' + result.degree ).split( '.' ),
80-
precisionFloat = ( '' + precision ).split( '.' );
79+
var degreeFloat = String( result.degree ).split( '.' ),
80+
precisionFloat = String( precision ).split( '.' );
8181

8282
if(
8383
degreeFloat[1] && precisionFloat[1]
@@ -128,21 +128,20 @@ this.globeCoordinate = ( function() {
128128
return string;
129129
}
130130

131-
return ''
132-
+ new Array( length - exploded[0].length + 1 ).join( '0' )
131+
return new Array( length - exploded[0].length + 1 ).join( '0' )
133132
+ exploded[0]
134133
+ ( ( exploded[1] ) ? '.' + exploded[1] : '' );
135134
}
136135

137-
latISO = ''
138-
+ ( ( ( latitude < 0 ) ? '-' : '+' ) + pad( lat.degree, 2 ) )
139-
+ ( ( precision < 1 ) ? pad( lat.minute, 2 ) : '' )
140-
+ ( ( precision < 1 / 60 ) ? pad( lat.second, 2 ) : '' );
136+
latISO = ( latitude < 0 ? '-' : '+' )
137+
+ pad( lat.degree, 2 )
138+
+ ( precision < 1 ? pad( lat.minute, 2 ) : '' )
139+
+ ( precision < 1 / 60 ? pad( lat.second, 2 ) : '' );
141140

142-
lonISO = ''
143-
+ ( ( ( longitude < 0 ) ? '-' : '+' ) + pad( lon.degree, 3 ) )
144-
+ ( ( precision < 1 ) ? pad( lon.minute, 2 ) : '' )
145-
+ ( ( precision < 1 / 60 ) ? pad( lon.second, 2 ) : '' );
141+
lonISO = ( longitude < 0 ? '-' : '+' )
142+
+ pad( lon.degree, 3 )
143+
+ ( precision < 1 ? pad( lon.minute, 2 ) : '' )
144+
+ ( precision < 1 / 60 ? pad( lon.second, 2 ) : '' );
146145

147146
// Synchronize precision (longitude degree needs to be 1 digit longer):
148147
if( lonISO.indexOf( '.' ) !== -1 && latISO.indexOf( '.' ) === -1 ) {
@@ -163,4 +162,4 @@ this.globeCoordinate = ( function() {
163162

164163
};
165164

166-
} )();
165+
}() );

src/values/TimeValue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( timesta
108108
if( key === 'calendarModel' && !SELF.getCalendarModelKeyByUri( value ) ) {
109109
throw new Error( 'Setting ' + key + ': No valid calendar model URI provided' );
110110
}
111-
if( $.inArray( key, ['precision', 'before', 'after', 'timezone'] ) !== -1
111+
if( $.inArray( key, [ 'precision', 'before', 'after', 'timezone' ] ) !== -1
112112
&& typeof value !== 'number'
113113
) {
114114
throw new Error( 'Setting ' + key + ': Expected "number" type' );

tests/lib/globeCoordinate/globeCoordinate.Formatter.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ define( [
1818
'1, 1': new GlobeCoordinate( { latitude: 1, longitude: 1, precision: 1 } ),
1919
'-10, -1.5': new GlobeCoordinate( { latitude: -10, longitude: -1.5, precision: 0.1 } ),
2020
'20, 0': new GlobeCoordinate( { latitude: 24, longitude: -1.5, precision: 10 } ),
21-
'15, 20' : new GlobeCoordinate( { latitude: 15, longitude: 20 } )
21+
'15, 20': new GlobeCoordinate( { latitude: 15, longitude: 20 } )
2222
},
2323
degreeTexts= {
2424
'1°N, 1°E': new GlobeCoordinate( { latitude: 1, longitude: 1, precision: 1 } ),

tests/lib/globeCoordinate/globeCoordinate.GlobeCoordinate.tests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ define( [
1717
assert.expect( 10 );
1818
var c;
1919

20-
assert.throws(
20+
assert['throws'](
2121
function() { c = new globeCoordinate.GlobeCoordinate( '' ); },
2222
'Trying to instantiate with an empty value throws an error.'
2323
);
2424

25-
assert.throws(
25+
assert['throws'](
2626
function() { c = new globeCoordinate.GlobeCoordinate( 'some string' ); },
2727
'Trying to instantiate with an invalid value (some string) throws an error.'
2828
);
2929

30-
assert.throws(
30+
assert['throws'](
3131
function() { c = new globeCoordinate.GlobeCoordinate( '190° 30" 1.123\'' ); },
3232
'Trying to instantiate with an invalid value (190° 30" 1.123\') throws an error.'
3333
);
3434

35-
assert.throws(
35+
assert['throws'](
3636
function() { c = new globeCoordinate.GlobeCoordinate( { latitude: 20 } ); },
3737
'Trying to instantiate with an invalid value ({ latitude: 20 }) throws an error.'
3838
);

0 commit comments

Comments
 (0)