Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
build: Create scoped variables in loops instead of re-using
Browse files Browse the repository at this point in the history
Closes #93.
  • Loading branch information
edg2s authored Jun 23, 2022
1 parent d1b22a7 commit 2a1bb9f
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/banana.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ module.exports = function bananaChecker( dir, options, logErr ) {
skipIncompleteMessageDocumentation: []
}, options );

let message;
let index;
let offset;

const jsonFilenameRegex = /(.*)\.json$/;
const translatedData = {};
const documentationMessageBlanks = [];
Expand Down Expand Up @@ -108,8 +104,8 @@ module.exports = function bananaChecker( dir, options, logErr ) {
let missing = sourceMessageKeys.slice( 0 );
let stack, originalParameters;

for ( index in keys ) {
message = keys[ index ];
for ( const index in keys ) {
const message = keys[ index ];
if ( sourceMessages[ message ] === undefined ) {
// An unused translation. This happens on commits that remove messages,
// which are typically removed from en.json and qqq.json, letting
Expand All @@ -129,7 +125,6 @@ module.exports = function bananaChecker( dir, options, logErr ) {
}

if ( originalParameters ) {
// eslint-disable-next-line no-loop-func
stack = originalParameters.filter( function ( originalParameter ) {
return !languageMessages[ message ].includes( originalParameter );
} );
Expand Down Expand Up @@ -186,9 +181,9 @@ module.exports = function bananaChecker( dir, options, logErr ) {
}

while ( sourceMessageKeys.length > 0 ) {
message = sourceMessageKeys[ 0 ];
const message = sourceMessageKeys[ 0 ];

offset = documentationMessageKeys.indexOf( message );
const offset = documentationMessageKeys.indexOf( message );

if ( offset !== -1 ) {

Expand Down Expand Up @@ -284,7 +279,7 @@ module.exports = function bananaChecker( dir, options, logErr ) {
}
}

for ( index in translatedData ) {
for ( const index in translatedData ) {
// eslint-disable-next-line no-prototype-builtins
if ( !translatedData.hasOwnProperty( index ) ) {
continue;
Expand Down Expand Up @@ -346,7 +341,7 @@ module.exports = function bananaChecker( dir, options, logErr ) {
}

if ( options.requireCompleteTranslationLanguages.length ) {
for ( index in translatedData ) {
for ( const index in translatedData ) {
if (
// eslint-disable-next-line no-prototype-builtins
!translatedData.hasOwnProperty( index ) ||
Expand All @@ -368,21 +363,21 @@ module.exports = function bananaChecker( dir, options, logErr ) {
}

if ( options.requireCompleteTranslationMessages.length ) {
for ( index in translatedData ) {
for ( const index in translatedData ) {
// eslint-disable-next-line no-prototype-builtins
if ( !translatedData.hasOwnProperty( index ) ) {
continue;
}

for ( message in translatedData[ index ].missing ) {
for ( const message in translatedData[ index ].missing ) {
if (
// eslint-disable-next-line no-prototype-builtins
!translatedData[ index ].missing.hasOwnProperty( sourceMessageKeys[ message ] )
) {
continue;
}

offset = options.requireCompleteTranslationMessages.indexOf(
const offset = options.requireCompleteTranslationMessages.indexOf(
sourceMessageKeys[ message ]
);

Expand Down

0 comments on commit 2a1bb9f

Please sign in to comment.