Skip to content

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

@chemdrew

Description

@chemdrew

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions