Skip to content

Commit

Permalink
refactor duplicated "a11y." usage, phetsims/friction#182
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Sep 30, 2019
1 parent 13d7649 commit b7aa053
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions eslint/rules/string-require-statement-match.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
module.exports = function( context ) {
'use strict';

const ChipperStringUtils = require( '../../js/common/ChipperStringUtils' );

// Adapted from Stack Overflow, see http://stackoverflow.com/questions/25085306/javascript-space-separated-string-to-camelcase
function toCamelCase( string ) {
let out = '';
Expand Down Expand Up @@ -56,8 +58,8 @@ module.exports = function( context ) {
let key = rhs.substring( lastSlash + 1 );

// For a11y strings, no need to prefix vars with "a11y"
if ( key.indexOf( 'a11y.' ) === 0 ) {
key = key.replace( 'a11y.', '' );
if ( ChipperStringUtils.isA11yStringKey( key ) ) {
key = key.replace( ChipperStringUtils.A11Y_MARKER, '' );
}

// Convert various separators to whitespace
Expand Down
9 changes: 8 additions & 1 deletion js/common/ChipperStringUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,14 @@
*/
forEachString( map, func ) {
forEachStringImplementation( '', map, func );
}
},

/**
* The start of any a11y specific string key.
* @public
* @type {string}
*/
A11Y_MARKER: A11Y_MARKER
};

/**
Expand Down

0 comments on commit b7aa053

Please sign in to comment.