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

There is no formatter for 'json'/'jsonc' files installed. #1967

Open
Joris914 opened this issue Jan 8, 2025 · 2 comments
Open

There is no formatter for 'json'/'jsonc' files installed. #1967

Joris914 opened this issue Jan 8, 2025 · 2 comments
Labels
info-needed Issue requires more information from poster

Comments

@Joris914
Copy link

Joris914 commented Jan 8, 2025

Some relevant settings:

  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "always"
  },
  "eslint.validate": [
    "javascript",
    "typescript",
    "json"
  ],
  "eslint.run": "onType",
  "eslint.format.enable": true,
  "eslint.useFlatConfig": true,
  // just for good measure, I don't think below should do anything
  "[json]": {
    "editor.defaultFormatter": "dbaeumer.vscode-eslint"
  },
  "[jsonc]": {
    "editor.defaultFormatter": "dbaeumer.vscode-eslint"
  },
  "json.format.enable": false, // disable the default vscode json formatter

If I set the last option to true, the error message changes to:
Image

My eslint.config.mjs:

import { FlatCompat } from '@eslint/eslintrc'
import json from '@eslint/json'
import prettier from 'eslint-plugin-prettier'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import { dirname } from 'path'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

const compat = new FlatCompat({
    baseDirectory: __dirname,
})

const eslintConfig = [
    ...compat.extends('next/core-web-vitals', 'next/typescript'),
    {
        languageOptions: {
            ecmaVersion: 'latest',
            sourceType: 'module',
        },
        plugins: {
            simpleImportSort,
            prettier,
            json,
        },
        rules: {
            'comma-dangle': ['error', 'always-multiline'],
            'react/prop-types': 'off',
            'no-unused-vars': 'warn',
            'simpleImportSort/imports': 'error',
            'simpleImportSort/exports': 'error',
            'prettier/prettier': 'warn',
            '@typescript-eslint/no-unused-vars': 'off',
            'json/no-duplicate-keys': 'error',
        },
    },
]

export default eslintConfig

I have tried separating the json-specific rules into its own block with file extension specifications, but that didn't help.
I saw one other issue about this but that was because of "eslint.format.enable": true not being set. I would appreciate some help here :)

@dbaeumer
Copy link
Member

dbaeumer commented Jan 9, 2025

@Joris914 can you format the file in the terminal using --fix. If so, can you please provide me with a GitHub repository with a minimal setup that demos what you are seeing.

@dbaeumer dbaeumer closed this as completed Jan 9, 2025
@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Jan 9, 2025
@dbaeumer dbaeumer reopened this Jan 9, 2025
@Joris914
Copy link
Author

Joris914 commented Jan 10, 2025

Hmm, when I run it on command line I get the message 0:0 warning File ignored because no matching configuration was supplied
I guess that means it's not an extension issue, but an ESLint itself issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants