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

Issue with eslint 9: .eslintrc-json.json?mtime=1712586949000" needs an import attribute of "type: json" #328

Closed nvuillam closed 7 months ago

nvuillam commented 7 months ago

Since eslint v9, we have the following issue in MegaLinter

[eslint-plugin-jsonc] command: ['eslint', '--no-ignore', '--fix', '-c', '/action/lib/.automation/.eslintrc-json.json', '--no-config-lookup', '--format', '@microsoft/eslint-formatter-sarif', '-o', '/tmp/257cdc5b-5fd5-4117-9ea3-9a25b1c03ecb/sarif/JSON_ESLINT_PLUGIN_JSONC.sarif', 'json_fix_1.json']
[eslint-plugin-jsonc] CWD: /tmp/lint/.automation/test/json
[Sarif] ERROR: there is no SARIF output file found, and stdout doesn't contain SARIF
[Sarif] stdout: 
Oops! Something went wrong! :(

ESLint: 9.0.0

TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///action/lib/.automation/.eslintrc-json.json?mtime=1712586949000" needs an import attribute of "type: json"
    at validateAttributes (node:internal/modules/esm/assert:88:15)
    at defaultLoad (node:internal/modules/esm/load:153:3)
    at async ModuleLoader.load (node:internal/modules/esm/loader:403:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:45)
    at async link (node:internal/modules/esm/module_job:78:21)

[eslint-plugin-jsonc] result: 2 
Oops! Something went wrong! :(

ESLint: 9.0.0

.eslintrc-json.json contains the following:

{
    "overrides": [
        {
            "files": ["*.json"],
            "extends": [
                "plugin:jsonc/recommended-with-jsonc"
            ],
            "parser": "jsonc-eslint-parser",
                "parserOptions": {
                    "jsonSyntax": "JSONC"
            }
        },
        {
            "files": ["*.jsonc"],
            "extends": [
                "plugin:jsonc/recommended-with-jsonc"
            ],
            "parser": "jsonc-eslint-parser",
                "parserOptions": {
                    "jsonSyntax": "JSONC"
            }
        },
        {
            "files": ["*.json5"],
            "extends": [
                "plugin:jsonc/recommended-with-json5"
            ],
            "parser": "jsonc-eslint-parser",
                "parserOptions": {
                    "jsonSyntax": "JSON5"
            }
        }
    ]
}

Is there some options /configs to change to make eslint-plugin-json work with eslint v9 ?

Many thanks :)

ota-meshi commented 7 months ago

I can't reproduce your problem. This package is not provided by ESM in the first place, so I suspect it is not a plugin issue.

ota-meshi commented 7 months ago

Oh, you're using a JSON for config. JSON config is no longer supported by default in ESLint 9.0.0. You should refer to the migration guide.

https://eslint.org/docs/latest/use/migrate-to-9.0.0

nvuillam commented 6 months ago

@ota-meshi would you have a ready to use eslint.config.js for eslint-plugin-jsonc ?