Skip to content

Commit

Permalink
var -> const using eslint auto fix, phetsims/tasks#1012
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Sep 19, 2019
1 parent f9412b8 commit e9824fd
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 143 deletions.
2 changes: 1 addition & 1 deletion js/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ define( require => {
*/
static getPhetioDocumentation( currentPhetioDocumentation, parameters ) {
const paramToDocString = param => {
var docText = param.phetioDocumentation && !_.endsWith( param.phetioDocumentation, '.' ) ? '. ' + param.phetioDocumentation : '';
const docText = param.phetioDocumentation && !_.endsWith( param.phetioDocumentation, '.' ) ? '. ' + param.phetioDocumentation : '';

return `<li>${param.name}: ${param.phetioType.typeName}${docText}</li>`;
};
Expand Down
2 changes: 1 addition & 1 deletion js/BooleanPropertyTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define( require => {
QUnit.module( 'BooleanProperty' );
QUnit.test( 'BooleanProperty', function( assert ) {

var p = null;
let p = null;

// isValidValue
window.assert && assert.throws( function() {
Expand Down
32 changes: 16 additions & 16 deletions js/DerivedPropertyTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ define( require => {
QUnit.module( 'DerivedProperty' );

QUnit.test( 'Test stale values in DerivedProperty', function( assert ) {
var a = new Property( 1 );
var b = new Property( 2 );
var c = new DerivedProperty( [ a, b ], function( a, b ) {return a + b;} );
const a = new Property( 1 );
const b = new Property( 2 );
const c = new DerivedProperty( [ a, b ], function( a, b ) {return a + b;} );
a.value = 7;
assert.equal( c.value, 9 );
} );

QUnit.test( 'Test DerivedProperty.unlink', function( assert ) {

var widthProperty = new Property( 2 );
var heightProperty = new Property( 3 );
var areaProperty = new DerivedProperty( [ widthProperty, heightProperty ],
const widthProperty = new Property( 2 );
const heightProperty = new Property( 3 );
const areaProperty = new DerivedProperty( [ widthProperty, heightProperty ],
function( width, height ) { return width * height; } );
var listener = function( area ) { /*console.log( 'area = ' + area );*/ };
const listener = function( area ) { /*console.log( 'area = ' + area );*/ };
areaProperty.link( listener );

assert.equal( widthProperty.changedEmitter.getListenerCount(), 1 );
Expand All @@ -52,20 +52,20 @@ define( require => {


QUnit.test( 'DerivedProperty.valueEquals', function( assert ) {
var propA = new Property( 'a' );
var propB = new Property( 'b' );
var prop = DerivedProperty.valueEquals( propA, propB );
const propA = new Property( 'a' );
const propB = new Property( 'b' );
const prop = DerivedProperty.valueEquals( propA, propB );
assert.equal( prop.value, false );
propA.value = 'b';
assert.equal( prop.value, true );
} );

QUnit.test( 'DerivedProperty and/or', function( assert ) {

var propA = new Property( false );
var propB = new Property( false );
var propC = new Property( false );
var propD = new Property( 0 ); // dependency with an invalid (non-boolean) type
const propA = new Property( false );
const propB = new Property( false );
const propC = new Property( false );
const propD = new Property( 0 ); // dependency with an invalid (non-boolean) type

// fail: 'and' with non-boolean Property
window.assert && assert.throws( function() { return DerivedProperty.and( [ propA, propD ] ); },
Expand All @@ -76,8 +76,8 @@ define( require => {
'DerivedProperty.or requires booleans Property values' );

// correct usages of 'and' and 'or'
var and = DerivedProperty.and( [ propA, propB, propC ] );
var or = DerivedProperty.or( [ propA, propB, propC ] );
const and = DerivedProperty.and( [ propA, propB, propC ] );
const or = DerivedProperty.or( [ propA, propB, propC ] );

assert.equal( and.value, false );
assert.equal( or.value, false );
Expand Down
54 changes: 27 additions & 27 deletions js/DynamicPropertyTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ define( require => {
QUnit.module( 'DynamicProperty' );

QUnit.test( 'Basics', function( assert ) {
var aProperty = new Property( 5 ); // eslint-disable-line no-undef
var bProperty = new Property( 2 ); // eslint-disable-line no-undef
var propertyProperty = new Property( aProperty ); // eslint-disable-line no-undef
var dynamicProperty = new DynamicProperty( propertyProperty ); // eslint-disable-line no-undef
const aProperty = new Property( 5 ); // eslint-disable-line no-undef
const bProperty = new Property( 2 ); // eslint-disable-line no-undef
const propertyProperty = new Property( aProperty ); // eslint-disable-line no-undef
const dynamicProperty = new DynamicProperty( propertyProperty ); // eslint-disable-line no-undef

assert.equal( dynamicProperty.value, aProperty.value );

Expand All @@ -34,14 +34,14 @@ define( require => {
} );

QUnit.test( 'Derive (string)', function( assert ) {
var a = {
const a = {
property: new Property( 5 ) // eslint-disable-line no-undef
};
var b = {
const b = {
property: new Property( 2 ) // eslint-disable-line no-undef
};
var mainProperty = new Property( a ); // eslint-disable-line no-undef
var dynamicProperty = new DynamicProperty( mainProperty, { // eslint-disable-line no-undef
const mainProperty = new Property( a ); // eslint-disable-line no-undef
const dynamicProperty = new DynamicProperty( mainProperty, { // eslint-disable-line no-undef
derive: 'property'
} );

Expand All @@ -59,14 +59,14 @@ define( require => {
} );

QUnit.test( 'Derive (function)', function( assert ) {
var a = {
const a = {
property: new Property( 5 ) // eslint-disable-line no-undef
};
var b = {
const b = {
property: new Property( 2 ) // eslint-disable-line no-undef
};
var mainProperty = new Property( a ); // eslint-disable-line no-undef
var dynamicProperty = new DynamicProperty( mainProperty, { // eslint-disable-line no-undef
const mainProperty = new Property( a ); // eslint-disable-line no-undef
const dynamicProperty = new DynamicProperty( mainProperty, { // eslint-disable-line no-undef
derive: function( ob ) {
return ob.property;
}
Expand All @@ -86,10 +86,10 @@ define( require => {
} );

QUnit.test( 'Bidirectional', function( assert ) {
var firstProperty = new Property( 5 ); // eslint-disable-line no-undef
var secondProperty = new Property( 10 ); // eslint-disable-line no-undef
var numberPropertyProperty = new Property( firstProperty ); // eslint-disable-line no-undef
var dynamicProperty = new DynamicProperty( numberPropertyProperty, { bidirectional: true } ); // eslint-disable-line no-undef
const firstProperty = new Property( 5 ); // eslint-disable-line no-undef
const secondProperty = new Property( 10 ); // eslint-disable-line no-undef
const numberPropertyProperty = new Property( firstProperty ); // eslint-disable-line no-undef
const dynamicProperty = new DynamicProperty( numberPropertyProperty, { bidirectional: true } ); // eslint-disable-line no-undef

dynamicProperty.value = 2; // allowed now that it is bidrectional, otherwise prohibited
assert.equal( firstProperty.value, 2 );
Expand All @@ -103,10 +103,10 @@ define( require => {
} );

QUnit.test( 'Mapping (with bidirectional)', function( assert ) {
var firstProperty = new Property( 5 ); // eslint-disable-line no-undef
var secondProperty = new Property( 10 ); // eslint-disable-line no-undef
var numberPropertyProperty = new Property( firstProperty ); // eslint-disable-line no-undef
var dynamicProperty = new DynamicProperty( numberPropertyProperty, { // eslint-disable-line no-undef
const firstProperty = new Property( 5 ); // eslint-disable-line no-undef
const secondProperty = new Property( 10 ); // eslint-disable-line no-undef
const numberPropertyProperty = new Property( firstProperty ); // eslint-disable-line no-undef
const dynamicProperty = new DynamicProperty( numberPropertyProperty, { // eslint-disable-line no-undef
bidirectional: true,
map: function( number ) {
return '' + number;
Expand All @@ -131,9 +131,9 @@ define( require => {
} );

QUnit.test( 'Attempted setters to nonbidrectional', function( assert ) {
var property = new Property( 5 );
var propertyProperty = new Property( property );
var dynamicProperty = new DynamicProperty( propertyProperty );
const property = new Property( 5 );
const propertyProperty = new Property( property );
const dynamicProperty = new DynamicProperty( propertyProperty );

window.assert && assert.throws( function() {
dynamicProperty.value = 10;
Expand All @@ -147,17 +147,17 @@ define( require => {
} );

QUnit.test( 'Bidirectional prevention of pingponging', function( assert ) {
var callbackCount = 0;
let callbackCount = 0;

var sourceProperty = new Property( 0 );
const sourceProperty = new Property( 0 );
sourceProperty.link( function() {
if ( callbackCount++ > 500 ) {
throw new Error( 'Infinite loop detected' );
}
} );

var wrapperProperty = new Property( sourceProperty );
var dynamicProperty = new DynamicProperty( wrapperProperty, {
const wrapperProperty = new Property( sourceProperty );
const dynamicProperty = new DynamicProperty( wrapperProperty, {
bidirectional: true,
// NOT a true inverse
map: n => n + 2,
Expand Down
54 changes: 27 additions & 27 deletions js/Events.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ define( require => {
assert && assert( typeof eventName === 'string', 'eventName should be a string' );
assert && assert( typeof callback === 'function', 'callback should be a function' );

var array = this._eventListeners[ eventName ];
const array = this._eventListeners[ eventName ];
return !!array && array.indexOf( callback ) >= 0;
},

Expand All @@ -128,7 +128,7 @@ define( require => {
assert && assert( typeof eventName === 'string', 'eventName should be a string' );
assert && assert( typeof callback === 'function', 'callback should be a function' );

var array = this._staticEventListeners[ eventName ];
const array = this._staticEventListeners[ eventName ];
return !!array && array.indexOf( callback ) >= 0;
},

Expand All @@ -137,7 +137,7 @@ define( require => {
* @public
*/
removeAllEventListeners: function() {
var eventName;
let eventName;
for ( eventName in this._eventListeners ) {
cleanArray( this._eventListeners[ eventName ] );
}
Expand All @@ -155,16 +155,16 @@ define( require => {
trigger: function( eventName ) {
assert && assert( typeof eventName === 'string', 'eventName should be a string' );

var listeners = this._eventListeners[ eventName ];
var staticListeners = this._staticEventListeners[ eventName ];
let listeners = this._eventListeners[ eventName ];
const staticListeners = this._staticEventListeners[ eventName ];

// listener quantities for normal and static
var count = listeners ? listeners.length : 0;
var staticCount = staticListeners ? staticListeners.length : 0;
const count = listeners ? listeners.length : 0;
const staticCount = staticListeners ? staticListeners.length : 0;

// only compute our arguments suffix once, instead of in our inner loop
var suffix;
var hasNoArguments = arguments.length === 1;
let suffix;
const hasNoArguments = arguments.length === 1;
if ( !hasNoArguments && ( count > 0 || staticCount > 0 ) ) {
suffix = Array.prototype.slice.call( arguments, 1 );
}
Expand All @@ -174,10 +174,10 @@ define( require => {
listeners = listeners.slice();
}

var i;
let i;

for ( i = 0; i < count; i++ ) {
var listener = listeners[ i ];
const listener = listeners[ i ];

//Simple case of no arguments, call it separately for improved performance in case it is faster (untested)
if ( hasNoArguments ) {
Expand All @@ -191,7 +191,7 @@ define( require => {
}

for ( i = 0; i < staticCount; i++ ) {
var staticListener = staticListeners[ i ];
const staticListener = staticListeners[ i ];

//Simple case of no arguments, call it separately for improved performance in case it is faster (untested)
if ( hasNoArguments ) {
Expand All @@ -215,19 +215,19 @@ define( require => {
assert && assert( arguments.length === 1 );
assert && assert( typeof eventName === 'string', 'eventName should be a string' );

var listeners = this._eventListeners[ eventName ];
var staticListeners = this._staticEventListeners[ eventName ];
let listeners = this._eventListeners[ eventName ];
const staticListeners = this._staticEventListeners[ eventName ];

// listener quantities for normal and static
var count = listeners ? listeners.length : 0;
var staticCount = staticListeners ? staticListeners.length : 0;
const count = listeners ? listeners.length : 0;
const staticCount = staticListeners ? staticListeners.length : 0;

// make a copy of non-static listeners, in case callback removes listener
if ( count > 0 ) {
listeners = listeners.slice();
}

var i;
let i;

for ( i = 0; i < count; i++ ) {
listeners[ i ]();
Expand All @@ -253,19 +253,19 @@ define( require => {
assert && assert( arguments.length === 2 );
assert && assert( typeof eventName === 'string', 'eventName should be a string' );

var listeners = this._eventListeners[ eventName ];
var staticListeners = this._staticEventListeners[ eventName ];
let listeners = this._eventListeners[ eventName ];
const staticListeners = this._staticEventListeners[ eventName ];

// listener quantities for normal and static
var count = listeners ? listeners.length : 0;
var staticCount = staticListeners ? staticListeners.length : 0;
const count = listeners ? listeners.length : 0;
const staticCount = staticListeners ? staticListeners.length : 0;

// make a copy of non-static listeners, in case callback removes listener
if ( count > 0 ) {
listeners = listeners.slice();
}

var i;
let i;

for ( i = 0; i < count; i++ ) {
listeners[ i ]( param1 );
Expand All @@ -292,19 +292,19 @@ define( require => {
assert && assert( arguments.length === 3 );
assert && assert( typeof eventName === 'string', 'eventName should be a string' );

var listeners = this._eventListeners[ eventName ];
var staticListeners = this._staticEventListeners[ eventName ];
let listeners = this._eventListeners[ eventName ];
const staticListeners = this._staticEventListeners[ eventName ];

// listener quantities for normal and static
var count = listeners ? listeners.length : 0;
var staticCount = staticListeners ? staticListeners.length : 0;
const count = listeners ? listeners.length : 0;
const staticCount = staticListeners ? staticListeners.length : 0;

// make a copy of non-static listeners, in case callback removes listener
if ( count > 0 ) {
listeners = listeners.slice();
}

var i;
let i;

for ( i = 0; i < count; i++ ) {
listeners[ i ]( param1, param2 );
Expand Down
Loading

0 comments on commit e9824fd

Please sign in to comment.