idahogurl / vs-code-prettier-eslint

A Visual Studio Code Extension to format JavaScript and TypeScript code using the prettier-eslint package.
MIT License
190 stars 47 forks source link

Extension does not do anything #159

Closed KuznetsovRoman closed 1 year ago

KuznetsovRoman commented 1 year ago

Describe the bug

A clear and concise description of what the bug is.

I installed the extension and copy-pasted .vscode/settings.json from example to my next typescript project, but when i save the file or launch Format Document (With Prettier ESLint is choosed) nothing happens. I added a stroke:

const test = {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl:{qwertyuiopasdfghjkl:{qwertyuiopasdfghjkl:{qwertyuiopasdfghjkl:"qwertyuiopasdfghjkl"}}}}}}}}};

and tried to run the extension on the file, expecting it would unwrap the object, like manual npx prettier --write . does, but nothing changes. Output log only says Incorrect type. Expected "boolean". [Ln 8, Col 45], but using true/false instead of "true"/"false" does not help. Another prettier extension works, but after deleting it, Prettier Eslint doesn't work anyway.

To Reproduce

Steps to reproduce the behavior:

  1. Install eslint, prettier, @typescript-eslint/parser with versions above
  2. Install the extension
  3. Create .vscode/settings.json from the example: https://pastebin.com/2j5AWn3U
  4. Restart Visual Studio
  5. Create a file with content:
const test = {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl: {qwertyuiopasdfghjkl:{qwertyuiopasdfghjkl:{qwertyuiopasdfghjkl:{qwertyuiopasdfghjkl:"qwertyuiopasdfghjkl"}}}}}}}}};
  1. Press "save" or use Format Document command

Expected behavior The statement turns into:

const test = {
    qwertyuiopasdfghjkl: {
        qwertyuiopasdfghjkl: {
            qwertyuiopasdfghjkl: {
                qwertyuiopasdfghjkl: {
                    qwertyuiopasdfghjkl: {
                        qwertyuiopasdfghjkl: {
                            qwertyuiopasdfghjkl: {
                                qwertyuiopasdfghjkl: { qwertyuiopasdfghjkl: "qwertyuiopasdfghjkl" },
                            },
                        },
                    },
                },
            },
        },
    },
};

like after launching npx prettier --write . manually

Example Project

package versions:

"@typescript-eslint/parser": "5.30.5",
"@typescript-eslint/eslint-plugin": "5.30.5",
"eslint": "8.19.0",
"prettier": "2.7.1",
"typescript": "4.7.4",
"eslint-config-next": "^12.2.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.3",
"eslint-plugin-next": "^0.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-only-warn": "^1.0.3",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.30.1",

.vscode/settings.json: https://pastebin.com/CjH8qjFC .eslintrc.json: https://pastebin.com/tgrK3yPp .prettierrc.json: https://pastebin.com/wwdzzc1X tsconfig.json: https://pastebin.com/X64McuVu

Versions:

System Specifications (please complete the following information):

rcoates-isu commented 1 year ago

What output do you see for ESLint-Prettier in the terminal?

KuznetsovRoman commented 1 year ago

What output do you see for ESLint-Prettier in the terminal?

Error: Failed to load plugin 'react-hooks' declared in 'CLIOptions': The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '' 
TypeError: Failed to load plugin 'react-hooks' declared in 'CLIOptions': The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''
    at new NodeError (node:internal/errors:371:5)
    at createRequire (node:internal/modules/cjs/loader:1281:13)
    at Object.resolve (/Users/kroman512/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2325:16)
    at ModuleResolver.resolve (/Users/kroman512/my-project/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:201:44)
    at ConfigArrayFactory._loadPlugin (/Users/kroman512/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3376:33)
    at ConfigArrayFactory._loadPlugin (/Users/kroman512/my-project/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:203:43)
    at /Users/kroman512/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3267:33
    at Array.reduce (<anonymous>)
    at ConfigArrayFactory._loadPlugins (/Users/kroman512/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3263:22)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/kroman512/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3063:44)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/Users/kroman512/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3003:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at ConfigArrayFactory.create (/Users/kroman512/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2798:16)
    at createCLIConfigArray (/Users/kroman512/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3608:47)
    at CascadingConfigArrayFactory.clearCache (/Users/kroman512/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3780:32)
    at new ESLint (/Users/kroman512/my-project/node_modules/eslint/lib/eslint/eslint.js:448:32)
    at $me (/Users/kroman512/.vscode/extensions/rvest.vs-code-prettier-eslint-5.1.0/dist/extension.js:185:69)
    at /Users/kroman512/.vscode/extensions/rvest.vs-code-prettier-eslint-5.1.0/dist/extension.js:193:700
    at zme (/Users/kroman512/.vscode/extensions/rvest.vs-code-prettier-eslint-5.1.0/dist/extension.js:185:1432)
KuznetsovRoman commented 1 year ago

https://github.com/idahogurl/vs-code-prettier-eslint/issues/42 seems related

Looks like the problem is in @rushstack/eslint-patch package

https://github.com/idahogurl/vs-code-prettier-eslint/issues/72#issuecomment-1247516987 solved the problem