Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New rule: Normalize string keys #32

Closed
1 task done
bmeck opened this issue Oct 4, 2024 · 3 comments · Fixed by #63
Closed
1 task done

New rule: Normalize string keys #32

bmeck opened this issue Oct 4, 2024 · 3 comments · Fixed by #63

Comments

@bmeck
Copy link
Contributor

bmeck commented Oct 4, 2024

Rule details

Normalize string keys

What type of rule is this?

Suggests an alternate way of doing something

Example code

Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize , there are examples of unicode that are similar in character. Generally this could mean that there is a key mismatch on 2 apparently similar strings. Suggesting using a normalized form to avoid this potential issue would be good so that the following 2 object don't have mismatched keys:

{
  "Amélie": 1
}
{
  "Amélie": 2
}

There are valid use cases for these key mismatches, but they are generally very specific in scope.

Participation

  • I am willing to submit a pull request to implement this rule.

Additional comments

Similar mismatches or deception such as using Bidi mixing / zero width characters etc. are potentially in the same vein but likely would be a different scope since those have associated CVEs.

@bmeck bmeck added the feature label Oct 4, 2024
@bmeck bmeck changed the title New Rule: (fill in) New rule: Normalize string keys Oct 4, 2024
@nzakas
Copy link
Member

nzakas commented Oct 4, 2024

Ah interesting. I agree this would be good to catch. I'm wondering if this should be part of no-duplicate-keys via an option or a completely separate rule. What do you think?

@bmeck
Copy link
Contributor Author

bmeck commented Oct 4, 2024

@nzakas I think duplicate keys via a config would be sane but the name of that role is a bit awkward since this occurs without having more than 1 key.

@nzakas
Copy link
Member

nzakas commented Oct 4, 2024

Fair point. A new rule it is! Maybe no-unnormalized-keys?

@nzakas nzakas added the accepted label Oct 4, 2024
bmeck added a commit to bmeck/eslint-json that referenced this issue Oct 7, 2024
@fasttime fasttime added this to Triage Nov 12, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Nov 12, 2024
@fasttime fasttime moved this from Needs Triage to Implementing in Triage Nov 12, 2024
nzakas pushed a commit that referenced this issue Nov 20, 2024
nzakas pushed a commit that referenced this issue Nov 21, 2024
@github-project-automation github-project-automation bot moved this from Implementing to Complete in Triage Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Complete
2 participants