ESLint JSON processor and rules
When editing the `package.json` file, I'm getting the following errors within VSCode:  <details> <summary>Error</summary> ```sh [Error - 17:00:33] ESLint stack trace: [Error - 17:00:33] SyntaxError: Unexpected token } in JSON at position 1279 Occurred while linting C:\Sources\eslint-formatter-checklist\package.json:1 Rule: "json-files/sort-package-json" at JSON.parse (<anonymous>) at editStringJSON (C:\Sources\eslint-formatter-checklist\node_modules\sort-package-json\index.js:327:17) at sortPackageJson (C:\Sources\eslint-formatter-checklist\node_modules\sort-package-json\index.js:349:10) at AssignmentExpression (C:\Sources\eslint-formatter-checklist\node_modules\eslint-plugin-json-files\lib\rules\sort-package-json.js:28:26) at ruleErrorHandler (C:\Sources\eslint-formatter-checklist\node_modules\eslint\lib\linter\linter.js:1114:28) at C:\Sources\eslint-formatter-checklist\node_modules\eslint\lib\linter\safe-emitter.js:45:58 at Array.forEach (<anonymous>) at Object.emit (C:\Sources\eslint-formatter-checklist\node_modules\eslint\lib\linter\safe-emitter.js:45:38) at NodeEventGenerator.applySelector (C:\Sources\eslint-formatter-checklist\node_modules\eslint\lib\linter\node-event-generator.js:297:26) at NodeEventGenerator.applySelectors (C:\Sources\eslint-formatter-checklist\node_modules\eslint\lib\linter\node-event-generator.js:326:22) ``` </details> This happens in VSCode (v1.70.2) with ESLint extension (v2.2.6) installed, and the following configurations: <details> <summary><code>.vscode/settings.json</code></summary> ```json { "editor.codeActionsOnSave": { "source.fixAll": true }, "eslint.validate": ["json", "jsonc"] } ``` </details> <details> <summary>ESLint configuration</summary> ```json5 { "root": true, "overrides": [ { "files": ["package.json"], "plugins": ["json-files"], "rules": { "json-files/sort-package-json": "error" } } ] } ``` (Removed some unneeded configurations) </details> ## Current situation The reason this happens is when I edit an `package.json` file (e.g. adding another property), the JSON files becomes in a temporary invalid state. This plugin tries to parse the invalid JSON for the `sort-package-json`-rule and throws an exception. ## Expected situation The solution should be to put the [JSON parsing](https://github.com/kellyselden/eslint-plugin-json-files/blob/285e0afea1168aba634de6ece28451418fbd497e/lib/rules/sort-package-json.js#L28) in an `try-catch` and swallow any exceptions until the JSON is valid.
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by jerone and has received 0 comments.