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

Create scoped variables in loops instead of re-using #93

Merged
merged 1 commit into from
Jun 23, 2022
Merged
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
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