eslint-plugin-i18n-json
eslint-plugin-i18n-json copied to clipboard
i18n-json/identical-keys suffix matching with similarly named files causes issues
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:

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);
Encountered this issue with settings.json
and security-settings.json
. Is the PR good to go?