Skip to content

Commit ab6d60a

Browse files
Ladsgroupthiemowmde
authored andcommitted
Use eslints tests instead of jshint
1 parent 170f11a commit ab6d60a

15 files changed

+109
-114
lines changed

.eslintignore

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

.eslintrc.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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-underscore-dangle": "off",
23+
"no-unused-vars": "off",
24+
"one-var": "off",
25+
"operator-linebreak": "off",
26+
"quote-props": "off",
27+
"space-before-function-paren": "off",
28+
"space-infix-ops": "off",
29+
"valid-jsdoc": "off",
30+
"vars-on-top": "off"
31+
}
32+
}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ composer.lock
66

77
!.*
88
.idea/
9-
9+
node_modules/
1010
vendor/
11-
build/
11+
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+
}() );

src/values/TimeValue.js

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

tests/src/dataValues.DataValue.tests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ define( [
124124
'is instance of actual data value implementation\'s constructor'
125125
);
126126
assert.equal(
127-
typeof( instance.getType() ),
127+
typeof instance.getType(),
128128
'string',
129129
'getType method is present and returns string'
130130
);
@@ -144,7 +144,7 @@ define( [
144144
keyType;
145145

146146
for ( i in instances ) {
147-
keyType = typeof( instances[i].getSortKey() );
147+
keyType = typeof instances[i].getSortKey();
148148

149149
assert.ok(
150150
keyType === 'string' || keyType === 'number',
@@ -288,7 +288,7 @@ define( [
288288
instance = this.getInstance( constructorArgs[i] );
289289

290290
QUnit.assert.strictEqual(
291-
instance[functionName].call( instance ),
291+
instance[functionName](),
292292
constructorArgs[i][argNumber],
293293
functionName + ' must return the value that was provided as argument ' + argNumber + ' in the constructor'
294294
);

tests/src/valueFormatters/ValueFormatterStore.tests.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ define( [
6565
QUnit.test( 'registerDataTypeFormatter(): Error handling', function( assert ) {
6666
var formatterStore = new vf.ValueFormatterStore();
6767

68-
assert.throws(
68+
assert['throws'](
6969
function() {
7070
formatterStore.registerDataTypeFormatter( 'invalid', stringType.getId() );
7171
},
@@ -74,7 +74,7 @@ define( [
7474

7575
formatterStore.registerDataTypeFormatter( StringFormatter, stringType.getId() );
7676

77-
assert.throws(
77+
assert['throws'](
7878
function() {
7979
formatterStore.getFormatter( stringType );
8080
},
@@ -85,7 +85,7 @@ define( [
8585
QUnit.test( 'registerDataValueFormatter(): Error handling', function( assert ) {
8686
var formatterStore = new vf.ValueFormatterStore();
8787

88-
assert.throws(
88+
assert['throws'](
8989
function() {
9090
formatterStore.registerDataValueFormatter( 'invalid', StringValue.TYPE );
9191
},
@@ -94,7 +94,7 @@ define( [
9494

9595
formatterStore.registerDataValueFormatter( StringFormatter, StringValue.TYPE );
9696

97-
assert.throws(
97+
assert['throws'](
9898
function() {
9999
formatterStore.getFormatter( StringValue );
100100
},
@@ -133,7 +133,7 @@ define( [
133133
);
134134

135135
assert.equal(
136-
formatterStore.getFormatter( numberType.getDataValueType(), numberType.getId() ),
136+
formatterStore.getFormatter( numberType.getDataValueType(), numberType.getId() ),
137137
NullFormatter,
138138
'Still returning default formatter if no formatter is registered for a specific data '
139139
+ 'type.'
@@ -220,7 +220,7 @@ define( [
220220
* parameter. Each inner array should contain a data type, data value or data value
221221
* constructor and a ValueFormatter which is expected to be registered for it.
222222
*/
223-
function valueFormatterStoreRegistrationTest( assert, toRegister, toExpect ) {
223+
function valueFormatterStoreRegistrationTest( assert, toRegister, toExpect ) {
224224
var formatterStore = new vf.ValueFormatterStore();
225225

226226
// Register ValueFormatters as per definition:

tests/src/valueParsers/ValueParserStore.tests.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ define( [
6565
QUnit.test( 'registerDataTypeParser(): Error handling', function( assert ) {
6666
var parserStore = new vp.ValueParserStore();
6767

68-
assert.throws(
68+
assert['throws'](
6969
function() {
7070
parserStore.registerDataTypeParser( 'invalid', stringType.getId() );
7171
},
@@ -74,7 +74,7 @@ define( [
7474

7575
parserStore.registerDataTypeParser( StringParser, stringType.getId() );
7676

77-
assert.throws(
77+
assert['throws'](
7878
function() {
7979
parserStore.getParser( stringType );
8080
},
@@ -85,7 +85,7 @@ define( [
8585
QUnit.test( 'registerDataValueParser(): Error handling', function( assert ) {
8686
var parserStore = new vp.ValueParserStore();
8787

88-
assert.throws(
88+
assert['throws'](
8989
function() {
9090
parserStore.registerDataValueParser( 'invalid', StringValue.TYPE );
9191
},
@@ -94,7 +94,7 @@ define( [
9494

9595
parserStore.registerDataValueParser( StringParser, StringValue.TYPE );
9696

97-
assert.throws(
97+
assert['throws'](
9898
function() {
9999
parserStore.getParser( StringValue );
100100
},
@@ -217,7 +217,7 @@ define( [
217217
* parameter. Each inner array should contain a data type, data value or data value
218218
* constructor and a ValueParser which is expected to be registered for it.
219219
*/
220-
function valueParserStoreRegistrationTest( assert, toRegister, toExpect ) {
220+
function valueParserStoreRegistrationTest( assert, toRegister, toExpect ) {
221221
var parserStore = new vp.ValueParserStore();
222222

223223
// Register ValueParsers as per definition:

tests/src/values/DecimalValue.tests.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ define( [
3333
*/
3434
getConstructorArguments: function() {
3535
return [
36-
[0],
37-
[1],
38-
[1e30],
39-
[1.5e30],
40-
[1.5e-30],
41-
[-1],
42-
[-1.5e-30],
43-
['+0'],
44-
['+1'],
45-
['-0'],
46-
['-1'],
47-
['+100000000000000000'],
48-
['-100000000000000000'],
49-
['-0.1'],
50-
['+0.1']
36+
[ 0 ],
37+
[ 1 ],
38+
[ 1e30 ],
39+
[ 1.5e30 ],
40+
[ 1.5e-30 ],
41+
[ -1 ],
42+
[ -1.5e-30 ],
43+
[ '+0' ],
44+
[ '+1' ],
45+
[ '-0' ],
46+
[ '-1' ],
47+
[ '+100000000000000000' ],
48+
[ '-100000000000000000' ],
49+
[ '-0.1' ],
50+
[ '+0.1' ]
5151
];
5252
}
5353

tests/src/values/QuantityValue.tests.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ define( [
3434
*/
3535
getConstructorArguments: function() {
3636
return [
37-
[new dv.DecimalValue( 0 ), 'some unit', new dv.DecimalValue( 0 ), new dv.DecimalValue( 0 )],
38-
[new dv.DecimalValue( 0 ), 'some unit', new dv.DecimalValue( -1 ), new dv.DecimalValue( 1 )],
39-
[new dv.DecimalValue( 5 ), 'some unit', new dv.DecimalValue( 4 ), new dv.DecimalValue( 6 )],
40-
[new dv.DecimalValue( 6 ), 'some unit', null, null],
41-
[new dv.DecimalValue( 7 ), 'some unit']
37+
[ new dv.DecimalValue( 0 ), 'some unit', new dv.DecimalValue( 0 ), new dv.DecimalValue( 0 ) ],
38+
[ new dv.DecimalValue( 0 ), 'some unit', new dv.DecimalValue( -1 ), new dv.DecimalValue( 1 ) ],
39+
[ new dv.DecimalValue( 5 ), 'some unit', new dv.DecimalValue( 4 ), new dv.DecimalValue( 6 ) ],
40+
[ new dv.DecimalValue( 6 ), 'some unit', null, null ],
41+
[ new dv.DecimalValue( 7 ), 'some unit' ]
4242
];
4343
}
4444

0 commit comments

Comments
 (0)