eslint / json

JSON language plugin for ESLint
Apache License 2.0
46 stars 4 forks source link

New Rule: no-empty-string-values #54

Closed dananaprey closed 2 weeks ago

dananaprey commented 2 weeks ago

Rule details

Detect empty string values in JSON

What type of rule is this?

Suggests an alternate way of doing something

Example code

Real life example:

I have a JSON file for application localization

{
  "localizationKey1": "Some translation 1",
  "localizationKey2": "",
  "localizationKey3": "Some translation 3",
  ...
}

I want to prevent empty translations values ​​to avoid missing text in the application

This rule should help

Participation

Additional comments

Similar rules, if necessary, can be made for values {}, [], null

I am also willing to submit a pull requests to implement this rules

nzakas commented 2 weeks ago

Similar to #55, I'm not sure if this is generic enough to be included in the plugin. Empty string values are completely valid and I'm not sure represent an error in most cases.

@eslint/eslint-team what do you think?

JoshuaKGoldberg commented 2 weeks ago

Agreed. From the broad perspective of JSON & common JSON uses, there's nothing inherently wrong with an empty string. Same with any arbitrary nullish/empty value. That's a library-specific thing. I'm -1 on building any into @eslint/json so early into project, if ever.

mdjermanovic commented 2 weeks ago

I agree that empty string values are generally valid so this doesn't seem generic enough to be included in the plugin.

dananaprey commented 2 weeks ago

Thanks for answers!