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

sort-keys: Misplaced comments in tsconfig.json #261

Open
LangLangBart opened this issue Sep 20, 2023 · 1 comment
Open

sort-keys: Misplaced comments in tsconfig.json #261

LangLangBart opened this issue Sep 20, 2023 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@LangLangBart
Copy link

description

  • sort-keys misplaces the comments in a tsconfig.json

reproduction

  • create a package.json
{
  "dependencies": {
    "eslint": "^8.49.0",
    "eslint-plugin-jsonc": "^2.9.0"
  },
  "eslintConfig": {
    "plugins": [
      "eslint-plugin-jsonc"
    ],
    "parser": "jsonc-eslint-parser",
    "rules": {
      "jsonc/sort-keys": [
        "error",
        {
          "pathPattern": "^compilerOptions$",
          "order": [
            "target",
            "strict"
          ]
        }
      ]
    }
  }
}
  • create a tsconfig.json
{
  "compilerOptions": {
    "strict": true, /* Enable all strict type-checking options. */
    "target": "esnext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
  }
}
  • after applying the rule the tsconfig.json transforms into:
{
  "compilerOptions": { /* Enable all strict type-checking options. */
    "target": "esnext",
    "strict": true /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
  }
}

reference

@ota-meshi
Copy link
Owner

It looks like a bug, but I think we need to think about how we handle comments.
If you have an idea, please consider submitting a pull request.

@ota-meshi ota-meshi added the help wanted Extra attention is needed label Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants