eslint-plugin-i18n-json icon indicating copy to clipboard operation
eslint-plugin-i18n-json copied to clipboard

i18n-json/identical-keys suffix matching with similarly named files causes issues

Open chemdrew opened this issue 2 years ago • 1 comments

When multiple files with the same suffix matching another language file are included in the filePaths there is an issue matching the correct file to check.

I updated the example/multiple-files-per-locale on my fork to demonstrate this with a simple example using search-results.json and another file z-search-results.json.

When running npm run lint in that example it outputs the following errors, despite all keys matching in each file:

Screen Shot 2022-03-29 at 3 39 46 PM

I tracked this down to be an issue with the code here https://github.com/godaddy/eslint-plugin-i18n-json/blob/master/src/identical-keys.js#L10-L13 and was able to solve this use case by replacing that with const match = sourceFilePath.substr(sourceFilePath.lastIndexOf('/') + 1);

chemdrew avatar Mar 29 '22 22:03 chemdrew

Encountered this issue with settings.json and security-settings.json. Is the PR good to go?

andys8 avatar Nov 22 '23 21:11 andys8