eslint-plugin-jsonc
eslint-plugin-jsonc copied to clipboard
sort-keys: Misplaced comments in tsconfig.json
description
-
sort-keys
misplaces the comments in atsconfig.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
- https://github.com/antfu/eslint-config/issues/248
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.