Skip to content

Commit

Permalink
change let -> const if not reassigned, phetsims/tasks#973
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Dec 12, 2018
1 parent fdb9059 commit 001b402
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 53 deletions.
10 changes: 5 additions & 5 deletions js/HeaterCoolerBack.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ define( require => {
}, options );

// Dimensions for the rest of the stove, dependent on the desired stove width.
let burnerOpeningHeight = DEFAULT_WIDTH * OPENING_HEIGHT_SCALE;
const burnerOpeningHeight = DEFAULT_WIDTH * OPENING_HEIGHT_SCALE;

// Create the inside bowl of the burner, which is an ellipse.
let burnerInteriorShape = new Shape()
const burnerInteriorShape = new Shape()
.ellipse( DEFAULT_WIDTH / 2, burnerOpeningHeight / 4, DEFAULT_WIDTH / 2, burnerOpeningHeight / 2, 0, 0, Math.PI, false );
let burnerInterior = new Path( burnerInteriorShape, {
const burnerInterior = new Path( burnerInteriorShape, {
stroke: 'black',
fill: new LinearGradient( 0, 0, DEFAULT_WIDTH, 0 )
.addColorStop( 0, options.baseColor.darkerColor( 0.5 ) )
.addColorStop( 1, options.baseColor.brighterColor( 0.5 ) )
} );

let fireNode = new Image( fireImage, {
const fireNode = new Image( fireImage, {
centerX: burnerInterior.centerX,
top: burnerInterior.bottom,
scale: DEFAULT_WIDTH / DEFAULT_WIDTH
} );
let iceNode = new Image( iceImage, {
const iceNode = new Image( iceImage, {
centerX: burnerInterior.centerX,
top: burnerInterior.bottom,
scale: DEFAULT_WIDTH / DEFAULT_WIDTH
Expand Down
20 changes: 10 additions & 10 deletions js/HeaterCoolerFront.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,32 @@ define( require => {

// Dimensions for the rest of the stove, dependent on the specified stove width. Empirically determined, and could
// be made into options if needed.
let height = DEFAULT_WIDTH * 0.75;
let burnerOpeningHeight = DEFAULT_WIDTH * HeaterCoolerBack.OPENING_HEIGHT_SCALE;
let bottomWidth = DEFAULT_WIDTH * 0.80;
const height = DEFAULT_WIDTH * 0.75;
const burnerOpeningHeight = DEFAULT_WIDTH * HeaterCoolerBack.OPENING_HEIGHT_SCALE;
const bottomWidth = DEFAULT_WIDTH * 0.80;

// Create the body of the stove.
let stoveBodyShape = new Shape()
const stoveBodyShape = new Shape()
.ellipticalArc( DEFAULT_WIDTH / 2, burnerOpeningHeight / 4, DEFAULT_WIDTH / 2, burnerOpeningHeight / 2, 0, 0, Math.PI, false )
.lineTo( ( DEFAULT_WIDTH - bottomWidth ) / 2, height + burnerOpeningHeight / 2 )
.ellipticalArc( DEFAULT_WIDTH / 2, height + burnerOpeningHeight / 4, bottomWidth / 2, burnerOpeningHeight,
0, Math.PI, 0, true ).lineTo( DEFAULT_WIDTH, burnerOpeningHeight / 2 );

let stoveBody = new Path( stoveBodyShape, {
const stoveBody = new Path( stoveBodyShape, {
stroke: 'black',
fill: new LinearGradient( 0, 0, DEFAULT_WIDTH, 0 )
.addColorStop( 0, options.baseColor.brighterColor( 0.5 ) )
.addColorStop( 1, options.baseColor.darkerColor( 0.5 ) )
} );

// Create the label strings and scale them to support translations.
let titleOptions = { font: options.labelFont, maxWidth: options.labelMaxWidth };
let heatTitle = new Text( options.heatLabel, titleOptions );
let coolTitle = new Text( options.coolLabel, titleOptions );
let titles = [ heatTitle, coolTitle ];
const titleOptions = { font: options.labelFont, maxWidth: options.labelMaxWidth };
const heatTitle = new Text( options.heatLabel, titleOptions );
const coolTitle = new Text( options.coolLabel, titleOptions );
const titles = [ heatTitle, coolTitle ];

// Scale the titles to fit within the bucket front if necessary.
let maxTitleWidth = Math.max( coolTitle.width, heatTitle.width );
const maxTitleWidth = Math.max( coolTitle.width, heatTitle.width );
if ( maxTitleWidth > bottomWidth / 2 ) {
titles.forEach( function( title ) {
title.scale( ( bottomWidth / 2 ) / maxTitleWidth );
Expand Down
22 changes: 11 additions & 11 deletions js/accessibility/UtteranceTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define( require => {
const Utterance = require( 'SCENERY_PHET/accessibility/Utterance' );
const utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' );

var sleepTiming = null;
let sleepTiming = null;

// helper es6 functions from https://stackoverflow.com/questions/33289726/combination-of-async-function-await-settimeout/33292942
function timeout( ms ) {
Expand All @@ -30,7 +30,7 @@ define( require => {

var alerts = [];

var intervalID = null;
let intervalID = null;
QUnit.module( 'Utterance', {
before() {

Expand Down Expand Up @@ -67,12 +67,12 @@ define( require => {

assert.ok( true, 'first test' );

let alert = 'hi';
utteranceQueue.addToBack( alert );
const myAlert = 'hi';
utteranceQueue.addToBack( myAlert );


await sleep( () => {
assert.ok( alerts[ 0 ] === alert, 'basic utteranceQueue test' );
assert.ok( alerts[ 0 ] === myAlert, 'basic utteranceQueue test' );
} );

utteranceQueue.addToBack( 'alert' );
Expand Down Expand Up @@ -134,18 +134,18 @@ define( require => {

QUnit.test( 'Utterance options', async assert => {

var alert = new Utterance( {
const alert = new Utterance( {
alert: [ '1', '2', '3' ]
} );

let alert4 = () => {
const alert4 = () => {
utteranceQueue.addToBack( alert );
utteranceQueue.addToBack( alert );
utteranceQueue.addToBack( alert );
utteranceQueue.addToBack( alert );
};

let testOrder = ( messageSuffix ) => {
const testOrder = ( messageSuffix ) => {

// newest at lowest index because of unshift
assert.ok( alerts[ 3 ] === '1', 'Array order1' + messageSuffix );
Expand All @@ -165,12 +165,12 @@ define( require => {

QUnit.test( 'Utterance loopAlerts', async assert => {

var alert = new Utterance( {
const alert = new Utterance( {
alert: [ '1', '2', '3' ],
loopAlerts: true
} );

let alert7 = () => {
const alert7 = () => {
utteranceQueue.addToBack( alert );
utteranceQueue.addToBack( alert );
utteranceQueue.addToBack( alert );
Expand All @@ -180,7 +180,7 @@ define( require => {
utteranceQueue.addToBack( alert );
};

let testOrder = ( messageSuffix ) => {
const testOrder = ( messageSuffix ) => {

// newest at lowest index
assert.ok( alerts[ 6 ] === '1', 'Array order1' + messageSuffix );
Expand Down
18 changes: 9 additions & 9 deletions js/accessibility/describers/BorderAlertsDescriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ define( ( require ) => {
const utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' );

// a11y strings
let leftBorderAlertString = SceneryPhetA11yStrings.leftBorderAlert.value;
let rightBorderAlertString = SceneryPhetA11yStrings.rightBorderAlert.value;
let topBorderAlertString = SceneryPhetA11yStrings.topBorderAlert.value;
let bottomBorderAlertString = SceneryPhetA11yStrings.bottomBorderAlert.value;
const leftBorderAlertString = SceneryPhetA11yStrings.leftBorderAlert.value;
const rightBorderAlertString = SceneryPhetA11yStrings.rightBorderAlert.value;
const topBorderAlertString = SceneryPhetA11yStrings.topBorderAlert.value;
const bottomBorderAlertString = SceneryPhetA11yStrings.bottomBorderAlert.value;

let DEFAULT_TOP_BORDER_ALERT = topBorderAlertString;
const DEFAULT_TOP_BORDER_ALERT = topBorderAlertString;

/**
* Responsible for alerting when the temperature increases
Expand Down Expand Up @@ -68,7 +68,7 @@ define( ( require ) => {
alertAtBorder( position, keyCode ) {
let alertDirection;

let bordersTouching = [];
const bordersTouching = [];

// at left now, but wasn't last location
if ( position.x === this.bounds.left ) {
Expand All @@ -93,7 +93,7 @@ define( ( require ) => {
// corner case
if ( bordersTouching.length > 1 ) {
keyCode = keyCode || -1;
let possibleDirection = DirectionEnum.keyCodeToDirection( keyCode );
const possibleDirection = DirectionEnum.keyCodeToDirection( keyCode );

// if the keyCode matches a border direction, use that instead of another wall that we may also be touching
if ( possibleDirection && bordersTouching.indexOf( possibleDirection ) >= 0 ) {
Expand All @@ -108,7 +108,7 @@ define( ( require ) => {
// Then we are potentially going to alert
if ( alertDirection ) {
assert && assert( DirectionEnum.isRelativeDirection( alertDirection ), `unsupported direction: ${alertDirection}` );
let borderAlert = this[ alertDirection ];
const borderAlert = this[ alertDirection ];
assert && assert( borderAlert instanceof BorderAlert, 'sanity check' );

borderAlert.alert();
Expand Down Expand Up @@ -171,7 +171,7 @@ define( ( require ) => {
getAlert() {
let alert = this._alert;
if ( Array.isArray( alert ) ) {
let index = Util.clamp( this._numberOfTimesAlerted, 0, alert.length - 1 );
const index = Util.clamp( this._numberOfTimesAlerted, 0, alert.length - 1 );
alert = alert[ index ];
}
return alert;
Expand Down
2 changes: 1 addition & 1 deletion js/accessibility/describers/DirectionEnum.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define( function( require ) {
const sceneryPhet = require( 'SCENERY_PHET/sceneryPhet' );

// It is important that the key and value are the same, so that either way you can access the values of the enum.
let DirectionEnum = {
const DirectionEnum = {
LEFT: 'LEFT',
RIGHT: 'RIGHT',
UP: 'UP',
Expand Down
30 changes: 15 additions & 15 deletions js/accessibility/describers/MovementDescriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ define( require => {
const utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' );

// a11y strings
let downString = SceneryPhetA11yStrings.down.value;
let leftString = SceneryPhetA11yStrings.left.value;
let rightString = SceneryPhetA11yStrings.right.value;
let upString = SceneryPhetA11yStrings.up.value;
const downString = SceneryPhetA11yStrings.down.value;
const leftString = SceneryPhetA11yStrings.left.value;
const rightString = SceneryPhetA11yStrings.right.value;
const upString = SceneryPhetA11yStrings.up.value;

// constants
// in radians - threshold for diagonal movement is +/- 15 degrees from diagonals
let DIAGONAL_MOVEMENT_THRESHOLD = 15 * Math.PI / 180;
const DIAGONAL_MOVEMENT_THRESHOLD = 15 * Math.PI / 180;

// mapping from alerting direction to the radian range that fills that space in the unit circle.
// The diagnal directions take up the middle third of each quadrant, such that each "outside" third is in the range for
// a relative (primary) direction. Therefore each diagonal direction is 1/9 of the Unit circle, and each primary direction
// is 2/9 of the unit circle.
let DIRECTION_MAP = {
const DIRECTION_MAP = {
UP: new Range( -3 * Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD, -Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD ),
DOWN: new Range( Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD, 3 * Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD ),
RIGHT: new Range( -Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD, Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD ),
Expand All @@ -48,15 +48,15 @@ define( require => {
UP_RIGHT: new Range( -Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD, -Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD ),
DOWN_RIGHT: new Range( Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD, Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD )
};
let DIRECTION_MAP_KEYS = Object.keys( DIRECTION_MAP );
const DIRECTION_MAP_KEYS = Object.keys( DIRECTION_MAP );

if ( assert ) {
DIRECTION_MAP_KEYS.forEach( direction => {
assert( DirectionEnum.keys.indexOf( direction ) >= 0, `unexpected direction: ${direction}. Keys should be the same as those in DirectionEnum` );
} );
}

let DEFAULT_MOVEMENT_ALERTS = {
const DEFAULT_MOVEMENT_ALERTS = {
LEFT: leftString,
RIGHT: rightString,
UP: upString,
Expand Down Expand Up @@ -92,7 +92,7 @@ define( require => {
if ( assert ) {

for ( let i = 0; i < this.movementAlertKeys.length; i++ ) {
let key = this.movementAlertKeys[ i ];
const key = this.movementAlertKeys[ i ];
assert( DirectionEnum.keys.indexOf( key ) >= 0, `unexpected key: ${key}. Keys should be the same as those in DirectionEnum` );
assert( AlertableDef.isAlertableDef( options.movementAlerts[ key ] ) );
}
Expand Down Expand Up @@ -158,10 +158,10 @@ define( require => {
*/
alertDirectionalMovement() {

let newLocation = this.locationProperty.get();
const newLocation = this.locationProperty.get();
if ( !newLocation.equals( this.lastAlertedLocation ) ) {

let directions = this.getDirections( newLocation, this.lastAlertedLocation );
const directions = this.getDirections( newLocation, this.lastAlertedLocation );

// make sure that these alerts exist
if ( assert ) {
Expand All @@ -185,9 +185,9 @@ define( require => {
getDirections( pointA, pointB ) {
let direction;

let dx = pointA.x - pointB.x;
let dy = pointA.y - pointB.y;
let angle = Math.atan2( dy, dx );
const dx = pointA.x - pointB.x;
const dy = pointA.y - pointB.y;
const angle = Math.atan2( dy, dx );

// atan2 wraps around Math.PI, so special check for moving left from absolute value
if ( DIRECTION_MAP.LEFT.contains( Math.abs( angle ) ) ) {
Expand All @@ -196,7 +196,7 @@ define( require => {

// otherwise, angle will be in one of the ranges in DIRECTION_MAP
for ( let i = 0; i < DIRECTION_MAP_KEYS.length; i++ ) {
let entry = DIRECTION_MAP[ DIRECTION_MAP_KEYS[ i ] ];
const entry = DIRECTION_MAP[ DIRECTION_MAP_KEYS[ i ] ];
if ( entry.contains( angle ) ) {
direction = DirectionEnum[ DIRECTION_MAP_KEYS[ i ] ];
break;
Expand Down
4 changes: 2 additions & 2 deletions js/accessibility/nodes/A11yGrabDragNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ define( require => {
this.dragFocusHighlight.makeDashed();

// if ever we update the node's focusHighlight, then update the grab button's too to keep in syn.
let onHighlightChange = () => {
const onHighlightChange = () => {
this.dragFocusHighlight.setShape( this.grabFocusHighlight.shape );
};
this.grabFocusHighlight.highlightChangedEmitter.addListener( onHighlightChange );
Expand Down Expand Up @@ -212,7 +212,7 @@ define( require => {
this.listenersForGrab = options.listenersForGrab.concat( grabButtonListener );
node.addInputListener( grabButtonListener );

let dragDivListener = {
const dragDivListener = {

// Release the draggable on 'enter' key, tracking that we have released the draggable with this key so that
// we don't immediately catch the 'click' event while the enter key is down on the button
Expand Down

0 comments on commit 001b402

Please sign in to comment.