Skip to content
This repository was archived by the owner on Dec 15, 2020. It is now read-only.

Commit b43e3bc

Browse files
Ladsgroupmanicki
authored andcommitted
Move from jshint to eslint and fix travis builds (#68)
1 parent 82b69c7 commit b43e3bc

File tree

13 files changed

+194
-198
lines changed

13 files changed

+194
-198
lines changed

.eslintignore

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

.eslintrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "wikimedia",
3+
"env": {
4+
"browser": true,
5+
"jquery": true,
6+
"qunit": true
7+
},
8+
"globals": {
9+
"dataTypes": false,
10+
"define": false
11+
},
12+
"rules": {
13+
"no-underscore-dangle": "off"
14+
}
15+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
vendor/
66
composer.phar
77
composer.lock
8+
node_modules/
89

910
!.*
1011
.idea/

.jshintrc

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

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ language: php
33
env:
44
- QUNIT=false
55

6+
dist: trusty
7+
68
php:
79
- 5.5
810
- 5.6
11+
- 7
912
- hhvm
1013

1114
matrix:
@@ -15,6 +18,7 @@ matrix:
1518

1619
before_script:
1720
- composer install --prefer-source
21+
- npm install eslint eslint-config-wikimedia
1822

1923
script: bash ./build/travis/script.sh
2024

build/travis/script.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ if [ "$QUNIT" == true ]; then
66

77
cd js/lib/TestRunner
88
phantomjs runTests.phantom.js ../../../tests/qunit/runTests.html
9+
cd -
910

10-
else
11+
fi
1112

12-
phpunit
13-
14-
fi
13+
composer test
14+
./node_modules/.bin/eslint .

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"php": ">=5.5.0"
2727
},
2828
"require-dev": {
29-
"mediawiki/mediawiki-codesniffer": "~0.7"
29+
"mediawiki/mediawiki-codesniffer": "~0.7",
30+
"phpunit/phpunit": "~4.8"
3031
},
3132
"autoload": {
3233
"files" : [
@@ -37,6 +38,9 @@
3738
}
3839
},
3940
"scripts": {
41+
"test": [
42+
"phpunit"
43+
],
4044
"phpcs": [
4145
"vendor/bin/phpcs src/* tests/* --standard=phpcs.xml -sp"
4246
]

js/config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @license GPL-2.0+
66
* @author H. Snater < mediawiki@snater.com >
77
*/
8-
this.config = ( function() {
8+
this.config = ( function () {
99
'use strict';
1010

1111
return {
@@ -19,15 +19,15 @@ this.config = ( function() {
1919
shim: {
2020
qunit: {
2121
exports: 'QUnit',
22-
init: function() {
22+
init: function () {
2323
QUnit.config.autoload = false;
2424
QUnit.config.autostart = false;
2525
}
2626
},
2727

2828
'qunit.parameterize': {
2929
exports: 'QUnit.cases',
30-
deps: ['qunit']
30+
deps: [ 'qunit' ]
3131
},
3232

3333
'dataType/__namespace': {
@@ -36,12 +36,12 @@ this.config = ( function() {
3636

3737
'dataTypes/DataType': {
3838
exports: 'dataTypes',
39-
deps: ['jquery', 'dataTypes/__namespace', 'qunit.parameterize']
39+
deps: [ 'jquery', 'dataTypes/__namespace', 'qunit.parameterize' ]
4040
},
4141

4242
'dataTypes/DataTypeStore': {
4343
exports: 'dataTypes',
44-
deps: ['jquery', 'dataTypes/__namespace', 'dataTypes/DataType']
44+
deps: [ 'jquery', 'dataTypes/__namespace', 'dataTypes/DataType' ]
4545
}
4646
},
4747
tests: [
@@ -50,4 +50,4 @@ this.config = ( function() {
5050
]
5151
};
5252

53-
} )();
53+
}() );

js/dataTypes/DataType.js

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,79 @@
1-
( function( $, dt ) {
1+
( function ( $, dt ) {
22
'use strict';
33

4-
/**
5-
* Base constructor for objects representing a data type.
6-
* @class dataTypes.DataType
7-
* @abstract
8-
* @since 0.1
9-
* @license GPL-2.0+
10-
* @author Daniel Werner
11-
* @author H. Snater < mediawiki@snater.com >
12-
*
13-
* @constructor
14-
* @param {string} dataTypeId
15-
* @param {string} dataValueType
16-
*
17-
* @throws {Error} if data type id is not provided as a string.
18-
* @throws {Error} if data value type is not provided as a string.
19-
*/
20-
var SELF = dt.DataType = function DtDataType( dataTypeId, dataValueType ) {
21-
if ( !dataTypeId || typeof dataTypeId !== 'string' ) {
22-
throw new Error( 'A data type\'s ID has to be a string' );
23-
}
4+
/**
5+
* Base constructor for objects representing a data type.
6+
* @class dataTypes.DataType
7+
* @abstract
8+
* @since 0.1
9+
* @license GPL-2.0+
10+
* @author Daniel Werner
11+
* @author H. Snater < mediawiki@snater.com >
12+
*
13+
* @constructor
14+
* @param {string} dataTypeId
15+
* @param {string} dataValueType
16+
*
17+
* @throws {Error} if data type id is not provided as a string.
18+
* @throws {Error} if data value type is not provided as a string.
19+
*/
20+
var SELF = dt.DataType = function DtDataType( dataTypeId, dataValueType ) {
21+
if ( !dataTypeId || typeof dataTypeId !== 'string' ) {
22+
throw new Error( 'A data type\'s ID has to be a string' );
23+
}
2424

25-
if ( typeof dataValueType !== 'string' ) {
26-
throw new Error( 'A data value type has to be given in form of a string' );
27-
}
25+
if ( typeof dataValueType !== 'string' ) {
26+
throw new Error( 'A data value type has to be given in form of a string' );
27+
}
2828

29-
this._id = dataTypeId;
30-
this._dataValueType = dataValueType;
31-
};
29+
this._id = dataTypeId;
30+
this._dataValueType = dataValueType;
31+
};
3232

33-
$.extend( SELF.prototype, {
34-
/**
35-
* DataType identifier.
36-
* @property {string}
37-
* @private
38-
*/
39-
_id: null,
33+
$.extend( SELF.prototype, {
34+
/**
35+
* DataType identifier.
36+
* @property {string}
37+
* @private
38+
*/
39+
_id: null,
4040

41-
/**
42-
* DataValue identifier.
43-
* @property {string}
44-
* @private
45-
*/
46-
_dataValueType: null,
41+
/**
42+
* DataValue identifier.
43+
* @property {string}
44+
* @private
45+
*/
46+
_dataValueType: null,
4747

48-
/**
49-
* Returns the data type's identifier.
50-
*
51-
* @return {string}
52-
*/
53-
getId: function() {
54-
return this._id;
55-
},
48+
/**
49+
* Returns the data type's identifier.
50+
*
51+
* @return {string}
52+
*/
53+
getId: function () {
54+
return this._id;
55+
},
56+
57+
/**
58+
* Returns the DataValue used by this data type.
59+
*
60+
* @return {string}
61+
*/
62+
getDataValueType: function () {
63+
return this._dataValueType;
64+
}
65+
} );
5666

5767
/**
58-
* Returns the DataValue used by this data type.
68+
* Creates a new DataType object from a given JSON structure.
69+
* @static
5970
*
60-
* @return {string}
71+
* @param {string} dataTypeId
72+
* @param {Object} json
73+
* @return {dataTypes.DataType}
6174
*/
62-
getDataValueType: function() {
63-
return this._dataValueType;
64-
}
65-
} );
66-
67-
/**
68-
* Creates a new DataType object from a given JSON structure.
69-
* @static
70-
*
71-
* @param {string} dataTypeId
72-
* @param {Object} json
73-
* @return {dataTypes.DataType}
74-
*/
75-
SELF.newFromJSON = function( dataTypeId, json ) {
76-
return new SELF( dataTypeId, json.dataValueType );
77-
};
75+
SELF.newFromJSON = function ( dataTypeId, json ) {
76+
return new SELF( dataTypeId, json.dataValueType );
77+
};
7878

7979
}( jQuery, dataTypes ) );

0 commit comments

Comments
 (0)