eslint / json

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

New Rule: indent #39

Closed LJNeon closed 1 month ago

LJNeon commented 1 month ago

Rule details

Should function similarly to the indent rule for JavaScript.

What type of rule is this?

Suggests an alternate way of doing something

Example code

There are many different standard indentations:

  1. No whitespace
    {"a":5,"b":true}
  2. Tabs
    {
    "a": 5,
    "b": true
    }
  3. Two-space
    {
    "a": 5,
    "b": true
    }
  4. Four-space
    {
    "a": 5,
    "b": true
    }

    and so on.

Participation

Additional comments

Could easily follow the standard set by JSON.stringify()s space option. If that doesn't seem like a good idea, then could follow the standard set by eslint's indent rule.

aladdin-add commented 1 month ago

hi, thanks for the issue! however, formatting-rules have been deprecated in eslint (https://eslint.org/blog/2023/10/deprecating-formatting-rules/). We might want to follow the same strategy here.

LJNeon commented 1 month ago

In the case of eslint they were deprecated and moved to their own package. But there's no @stylistic/json package for the same to happen here.

nzakas commented 1 month ago

We're not going to be adding formatting rules to this package. Please use a formatter like Prettier for this purpose.