Skip to content

Use eslints tests instead of jshint #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lib/jquery/**
lib/qunit/**
lib/qunit.parameterize/**
lib/require/**
node_modules/**
vendor/**
33 changes: 33 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": "wikimedia",
"env": {
"browser": true,
"jquery": true
},
"globals": {
"dataValues": false,
"define": false,
"globeCoordinate": false,
"module": "false",
"QUnit": false,
"util": false,
"valueFormatters": false,
"valueParsers": false,
"wikibase": false
},
"rules": {
"computed-property-spacing": "off",
"indent": "off",
"keyword-spacing": "off",
"no-loop-func": "off",
"no-underscore-dangle": "off",
"no-unused-vars": "off",
"one-var": "off",
"operator-linebreak": "off",
"quote-props": "off",
"space-before-function-paren": "off",
"space-infix-ops": "off",
"valid-jsdoc": "off",
"vars-on-top": "off"
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ composer.lock
!.*
.idea/

node_modules/
vendor/
build/
build/
3 changes: 0 additions & 3 deletions .jshintignore

This file was deleted.

46 changes: 0 additions & 46 deletions .jshintrc

This file was deleted.

5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ php:
- 5.5

env:
- RUNJOB=jshint
- RUNJOB=eslint
- RUNJOB=qunit

before_script:
- nvm install 4

script: bash ./build/travis/script.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be replaced with composer test, and the .sh files deleted, just as in all other code repositories we maintain. But this can be done in a later patch.


notifications:
Expand Down
7 changes: 4 additions & 3 deletions build/travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

set -x

if [[ $RUNJOB == jshint ]]; then
npm install jshint
jshint src/ lib/ tests/
if [[ $RUNJOB == eslint ]]; then
npm install eslint
npm install --save eslint-config-wikimedia
./node_modules/.bin/eslint .
exit $?
fi

Expand Down
16 changes: 8 additions & 8 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ this.config = ( function() {
},
'qunit.parameterize': {
exports: 'QUnit.cases',
deps: ['qunit']
deps: [ 'qunit' ]
},

'util/util.inherit': {
Expand All @@ -50,17 +50,17 @@ this.config = ( function() {
},
'globeCoordinate/globeCoordinate.GlobeCoordinate': {
exports: 'globeCoordinate.GlobeCoordinate',
deps: ['globeCoordinate/globeCoordinate']
deps: [ 'globeCoordinate/globeCoordinate' ]
},
'globeCoordinate/globeCoordinate.Formatter': {
exports: 'globeCoordinate.Formatter',
deps: ['globeCoordinate/globeCoordinate']
deps: [ 'globeCoordinate/globeCoordinate' ]
},

'dataValues/dataValues': {
exports: 'dataValues'
},
'dataValues/DataValue': ['dataValues/dataValues', 'jquery', 'util/util.inherit'],
'dataValues/DataValue': [ 'dataValues/dataValues', 'jquery', 'util/util.inherit' ],

'values/BoolValue': [
'dataValues/dataValues', 'jquery', 'dataValues/DataValue', 'util/util.inherit'
Expand Down Expand Up @@ -109,7 +109,7 @@ this.config = ( function() {
},
'valueFormatters/ValueFormatterStore': {
exports: 'valueFormatters.ValueFormatterStore',
deps: ['valueFormatters/valueFormatters', 'jquery']
deps: [ 'valueFormatters/valueFormatters', 'jquery' ]
},

'formatters/NullFormatter': [
Expand All @@ -136,7 +136,7 @@ this.config = ( function() {
},
'valueParsers/ValueParserStore': {
exports: 'valueParsers.ValueParserStore',
deps: ['valueParsers/valueParsers', 'jquery']
deps: [ 'valueParsers/valueParsers', 'jquery' ]
},

'parsers/BoolParser': [
Expand All @@ -163,7 +163,7 @@ this.config = ( function() {
'parsers/ValueParser',
'values/StringValue'
],
'parsers/ValueParser': ['valueParsers/valueParsers', 'util/util.inherit', 'jquery'],
'parsers/ValueParser': [ 'valueParsers/valueParsers', 'util/util.inherit', 'jquery' ],

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

} )();
}() );
4 changes: 2 additions & 2 deletions lib/TestRunner/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ this.TestRunner = ( function( console ) {
}
}
return params;
} )( window.location.search.substr( 1 ).split( '&' ) );
}( window.location.search.substr( 1 ).split( '&' ) ) );

for( var i = 0; i < testModules.length; i++ ) {
if( testModules[i] === queryString.test ) {
return [queryString.test];
return [ queryString.test ];
}
}

Expand Down
8 changes: 3 additions & 5 deletions lib/globeCoordinate/globeCoordinate.Formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
longitude = globeCoordinate.toDecimal( longitude, precision );
}

return ''
+ latitude
return String( latitude )
+ this._options.latLongCombinator
+ longitude;
},
Expand All @@ -112,14 +111,13 @@
if( number === undefined ) {
return '';
}
return number + sign;
return String( number ) + sign;
};

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

return ''
+ text( Math.abs( latDeg.degree ), this._options.degree )
return text( Math.abs( latDeg.degree ), this._options.degree )
+ text( latDeg.minute, this._options.minute )
+ text( latDeg.second, this._options.second )
+ ( ( lat < 0 ) ? this._options.south : this._options.north )
Expand Down
25 changes: 12 additions & 13 deletions lib/globeCoordinate/globeCoordinate.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ this.globeCoordinate = ( function() {
// JavaScript may cause some disturbance regarding rounding and precision. The
// result should not have a higher floating point number precision than the
// applied precision.
var degreeFloat = ( '' + result.degree ).split( '.' ),
precisionFloat = ( '' + precision ).split( '.' );
var degreeFloat = String( result.degree ).split( '.' ),
precisionFloat = String( precision ).split( '.' );

if(
degreeFloat[1] && precisionFloat[1]
Expand Down Expand Up @@ -128,21 +128,20 @@ this.globeCoordinate = ( function() {
return string;
}

return ''
+ new Array( length - exploded[0].length + 1 ).join( '0' )
return new Array( length - exploded[0].length + 1 ).join( '0' )
+ exploded[0]
+ ( ( exploded[1] ) ? '.' + exploded[1] : '' );
}

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

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

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

};

} )();
}() );
2 changes: 1 addition & 1 deletion src/values/TimeValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( timesta
if( key === 'calendarModel' && !SELF.getCalendarModelKeyByUri( value ) ) {
throw new Error( 'Setting ' + key + ': No valid calendar model URI provided' );
}
if( $.inArray( key, ['precision', 'before', 'after', 'timezone'] ) !== -1
if( $.inArray( key, [ 'precision', 'before', 'after', 'timezone' ] ) !== -1
&& typeof value !== 'number'
) {
throw new Error( 'Setting ' + key + ': Expected "number" type' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define( [
'1, 1': new GlobeCoordinate( { latitude: 1, longitude: 1, precision: 1 } ),
'-10, -1.5': new GlobeCoordinate( { latitude: -10, longitude: -1.5, precision: 0.1 } ),
'20, 0': new GlobeCoordinate( { latitude: 24, longitude: -1.5, precision: 10 } ),
'15, 20' : new GlobeCoordinate( { latitude: 15, longitude: 20 } )
'15, 20': new GlobeCoordinate( { latitude: 15, longitude: 20 } )
},
degreeTexts= {
'1°N, 1°E': new GlobeCoordinate( { latitude: 1, longitude: 1, precision: 1 } ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ define( [
assert.expect( 10 );
var c;

assert.throws(
assert['throws'](
function() { c = new globeCoordinate.GlobeCoordinate( '' ); },
'Trying to instantiate with an empty value throws an error.'
);

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

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

assert.throws(
assert['throws'](
function() { c = new globeCoordinate.GlobeCoordinate( { latitude: 20 } ); },
'Trying to instantiate with an invalid value ({ latitude: 20 }) throws an error.'
);
Expand Down
Loading