ota-meshi / eslint-plugin-jsonc

ESLint plugin for JSON(C|5)? files
https://ota-meshi.github.io/eslint-plugin-jsonc/
MIT License
199 stars 17 forks source link

[Question] VSCode - can't format User settings.json #359

Closed LatenPath closed 2 months ago

LatenPath commented 3 months ago

I installed this plugin and it works fine with normal json or jsonc files. image image image image image

But, The only file that I can't parse is settings.json in VSCode. image image

No output error from Eslint: image

Version: "eslint-plugin-jsonc": "^2.16.0", "jsonc-eslint-parser": "^2.4.0", VSCode: 1.92.1

eslint.config.mjs:

import eslintTS from "typescript-eslint";
import eslintJsonc from "eslint-plugin-jsonc";
import eslintJsoncParser from "jsonc-eslint-parser";

export default eslintTS.config(
 {
    "files": [ "**/*.json", "**/*.jsonc" ],
    "languageOptions": {
      parser: eslintJsoncParser,
    },
    "plugins": {
      "jsonc": eslintJsonc,
    },
}
);

User settings.json:

{
  //
  "eslint.enable": true,
  "eslint.format.enable": true,
  "eslint.useFlatConfig": true,
  "eslint.validate": ["javascript", "typescript", "json", "jsonc"],
  "[json]": {
    "editor.defaultFormatter": "dbaeumer.vscode-eslint",
    "editor.formatOnSave": false,
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": "explicit"
    }
  },
  "[jsonc]": {
    "editor.defaultFormatter": "dbaeumer.vscode-eslint",
    "editor.formatOnSave": false,
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": "explicit"
    }
  },
 }

I turned off all other settings to try but it still didn't change anything. I don't know where I went wrong, please help. Thank you all very much.

LatenPath commented 2 months ago

Because the file is outside of Eslint dir.