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

Error: r is not a constructor #26

Closed
gzhqiang opened this issue Dec 26, 2021 · 32 comments
Closed

Error: r is not a constructor #26

gzhqiang opened this issue Dec 26, 2021 · 32 comments

Comments

@gzhqiang
Copy link

I use the vue3-recommended, then throw Error: r is not a constructor

@bithavoc
Copy link

Same with React, my package json:

 "dependencies": {
    "@headlessui/react": "^1.4.2",
    "@heroicons/react": "^1.0.5",
    "@reduxjs/toolkit": "^1.7.1",
    "@tailwindcss/forms": "^0.4.0",
    "@types/redux-persist": "^4.3.1",
    "classnames": "^2.3.1",
    "next": "12.0.7",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-redux": "^7.2.6",
    "redux-persist": "^6.0.0"
  },
  "devDependencies": {
    "@types/node": "17.0.4",
    "@types/react": "17.0.38",
    "@typescript-eslint/eslint-plugin": "^5.8.0",
    "@typescript-eslint/parser": "^5.8.0",
    "autoprefixer": "^10.4.0",
    "eslint": "^8.5.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-next": "12.0.7",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-react": "^7.28.0",
    "eslint-plugin-react-hooks": "^4.3.0",
    "postcss": "^8.4.5",
    "prettier": "2.5.1",
    "prettier-eslint": "^13.0.0",
    "tailwindcss": "^3.0.7",
    "typescript": "4.5.4"
  }

@idahogurl
Copy link
Owner

@bithavoc @gzhqiang Could I get your ESLint config file?

@dangjoeltang
Copy link

I am having this same issue. These are my package versions and eslintrc.js
Screen Shot 2021-12-27 at 3 28 03 PM
Screen Shot 2021-12-27 at 3 28 21 PM

@dangjoeltang
Copy link

These are the default configurations for a fresh project using NestJS CLI command: nest new <app-name>

@idahogurl
Copy link
Owner

idahogurl commented Dec 28, 2021

@dangjoeltang @bithavoc This extension does not support ESLint 8. There is a breaking change where they removed functionality from their API. Please downgrade and try again 🙂

@badalya1
Copy link

badalya1 commented Jan 22, 2022

I am having this same issue. These are my package versions and eslintrc.js

and please please please, when posting code don't use screenshots, don't be an end user :)

@el-ethan
Copy link

@idahogurl thank you for writing and maintaining this extension!

This extension does not support ESLint 8.

Do you have plans to add support for newer versions of eslint, or are there reasons why this is unlikely/impossible?

@idahogurl
Copy link
Owner

idahogurl commented Jan 24, 2022

@el-ethan I'd love to support newer versions of ESLint. My pain point right now is the prettier-eslint package. (see prettier/prettier-eslint#656)

I am working on this PR but I noticed how they have approved PRs that are nearly a year old and not merged. The last time the package was updated was 6 months ago. I'm hesitant to diverge and create my own version of their package. That is the reason behind the extension not supporting ESLint 8+

@dangjoeltang
Copy link

I am having this same issue. These are my package versions and eslintrc.js

and please please please, when posting code don't use screenshots, don't be an end user :)

Sorry this is my first ever comment on a github issue, so I don't know proper etiquette :(

@wclr
Copy link

wclr commented Jan 26, 2022

@idahogurl

  • I use "array-bracket-spacing": ["warn", "always"] it shows warning in file (when there is not spacing) and calling "ESlint: fix autofixible problems" adds needed spaces, so I wanted to get this when formatting with prettier using this extension.

  • I tried and had the same error in the "Prettier Eslint" output (when trying to "Format document with Prettier ESlint")

  • I've downgraded to eslint 7,

  • Tried to format, and there was not error in the output (it is empty)

  • But the source is not changed (no eslint formatting fixed applied).

So should my case work? How to debug, and why there is nothing in "Prettier Eslient" output?

@el-ethan
Copy link

That is the reason behind the extension not supporting ESLint 8+

@idahogurl that is totally understandable. Thanks for the information!

@idahogurl
Copy link
Owner

@wclr
The reason nothing is showing up in the output is that there was no error. I think you are right in thinking it should at least have a success message.

  1. Are you using the Beta version of my extension? Only the Beta version supports ESLint 7.
  2. Try to test against the Prettier ESLint CLI (https://github.com/prettier/prettier-eslint-cli). If it adds the space as expected then I'll need an example project to debug. I used to ask for the ESLint config file & package.json but it makes the process faster if you could provide a repository or even a zip file (minus node_modules) of the project.

@wclr
Copy link

wclr commented Jan 26, 2022

@idahogurl I installed 4.0.0-beta and checked, the result is the same, prettier-eslint CLI works ok (adds needed spaces). eslint version 7.32.0.

@idahogurl
Copy link
Owner

@wclr Alright could I get an example project?

@wclr
Copy link

wclr commented Jan 27, 2022

@idahogurl https://github.com/wclr/vscode-prettier-eslint-issue.git

@idahogurl
Copy link
Owner

@wclr I found a fix for your issue. It could not find the your tsconfig.json Replace your package.json with this

package.json

{
  "name": "vscode-prettier-eslint-issue",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@typescript-eslint/eslint-plugin": "^5.10.1",
    "@typescript-eslint/parser": "^5.10.0",
    "eslint": "^7.32.0",
    "prettier": "^2.5.1",
    "prettier-eslint": "^13.0.0",
    "prettier-eslint-cli": "^5.0.1",
    "typescript": "^4.5.5"
  }
}

Rename .eslintrc to .eslintrc.js

.eslintrc.js

module.exports = {
  root: true,
  parser: "@typescript-eslint/parser",
  parserOptions: {
    project: "./tsconfig.json",
    tsconfigRootDir: __dirname, // instead of '.'
  },
  rules: {
    eqeqeq: ["warn", "always"],
    "array-bracket-spacing": ["warn", "always"],
  },
  plugins: ["@typescript-eslint"],
  extends: [
    "eslint:recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended",
  ],
};

@wclr
Copy link

wclr commented Feb 1, 2022

@idahogurl worked, thanks.

@SushyDev
Copy link

SushyDev commented Feb 1, 2022

same issue here with nuxt/ts/eslint/prettier

@idahogurl
Copy link
Owner

@SushyDev Sample repo?

@gdibble
Copy link

gdibble commented Mar 2, 2022

@el-ethan I'd love to support newer versions of ESLint. My pain point right now is the prettier-eslint package. (see prettier/prettier-eslint#656)

I am working on this PR but I noticed how they have approved PRs that are nearly a year old and not merged. The last time the package was updated was 6 months ago. I'm hesitant to diverge and create my own version of their package. That is the reason behind the extension not supporting ESLint 8+

Good news is: "DanielKlys7 approved these changes 13 days ago"

@github-actions
Copy link

github-actions bot commented Apr 1, 2022

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Apr 1, 2022
@bernardocs
Copy link

Bump
Waiting for this merge :))

@github-actions github-actions bot removed the stale label Apr 13, 2022
@gdibble
Copy link

gdibble commented Apr 18, 2022

@idahogurl did you see?! 👀 🎉 Congrats on your code merge. We all appreciate your hard work!

@idahogurl
Copy link
Owner

@gdibble Close but no cigar. Release is broken https://github.com/prettier/prettier-eslint/runs/6070047136?check_suite_focus=true
Also it looks like they didn't include the BREAKING CHANGE message in the squash and merge so the semver will be wrong.

@gdibble
Copy link

gdibble commented Apr 19, 2022

"Close but no cigar" just means more "fun" 😉 😉
🙏 Thanks in advance

@mannie-exe
Copy link

mannie-exe commented Apr 21, 2022

Hey!

Thanks for the update to prettier-eslint! I'm currently installing it from Git in order to get ESLint 8 support, in conjunction with the pre-release version of vs-code-prettier-eslint extension.

This is the error I receive when I try to format now:
Error: n is not a constructor 
TypeError: n is not a constructor
    at p (c:\Users\mannie.exe\.vscode\extensions\rvest.vs-code-prettier-eslint-4.1.0\dist\extension.js:22:71)
    at c:\Users\mannie.exe\.vscode\extensions\rvest.vs-code-prettier-eslint-4.1.0\dist\extension.js:34:41
    at e.exports (c:\Users\mannie.exe\.vscode\extensions\rvest.vs-code-prettier-eslint-4.1.0\dist\extension.js:34:275)
    at c:\Users\mannie.exe\.vscode\extensions\rvest.vs-code-prettier-eslint-4.1.0\dist\extension.js:46:7244
    at Rt (c:\Users\mannie.exe\.vscode\extensions\rvest.vs-code-prettier-eslint-4.1.0\dist\extension.js:46:7268)
    at Object.provideDocumentRangeFormattingEdits (c:\Users\mannie.exe\.vscode\extensions\rvest.vs-code-prettier-eslint-4.1.0\dist\extension.js:46:7565)
    at H.provideDocumentRangeFormattingEdits (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:103221)
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:129986
    at Q._withAdapter (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:123100)
    at Q.$provideDocumentRangeFormattingEdits (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:129962)
    at i._doInvokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:13826)
    at i._invokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:13510)
    at i._receiveRequest (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:12119)
    at i._receiveOneMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:10841)
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:8947
    at u.invoke (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145)
    at v.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1856)
    at d.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:19034)
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:34275
    at u.invoke (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145)
    at v.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1856)
    at d.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:19034)
    at o._receiveMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:23615)
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:21149
    at u.invoke (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145)
    at v.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1856)
    at v.acceptChunk (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:15865)
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:14995
    at Socket.P (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:13797)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)
Here are the relevant package versions as set in the NPM project
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"prettier": "^2.6.2",
"prettier-eslint": "github:prettier/prettier-eslint#master",
And my ESLint config (YAML in this case)
root: true
env:
  es2022: true
  node: true
extends:
  - eslint:recommended
  - plugin:import/recommended
  - prettier

At first I though this was related to my project being a Node.js ESM module, but I reverted back to CJS to test and received the same results. I am not using TypeScript. Am I missing something else compatibility-wise?


EDIT: Let me know if this error is ultimately unrelated to the original issue, and I'll open another one.

@k-utsumi
Copy link

@schmannie Maybe see Prerequisites.

@mannie-exe
Copy link

@k-utsumi yep.

I'm running a version of prettier-eslint that should be able to run with ESLint 8 (prettier/prettier-eslint#696). I am asking if vs-code-prettier-eslint itself needs to be updated as well — and I guess it does.

@idahogurl
Copy link
Owner

@schmannie Yes vs-code-prettier-eslint itself does need to be updated. However, there was an issue with the publish process and prettier/prettier-eslint#696 did not go out. If you look at NPM it's still 13.0.

@mannie-exe
Copy link

@schmannie Yes vs-code-prettier-eslint itself does need to be updated. However, there was an issue with the publish process and prettier/prettier-eslint#696 did not go out. If you look at NPM it's still 13.0.

Hey! I hope I'm not derailing this issue, but I was trying to update this extension myself — just to see what that might be like — have you managed to bundle the new ESLint with Rollup? No matter what methods I use, Rollup has refused to cooperate. My changes are at schmannie/vs-code-prettier-eslint:4.0.0-beta.

P.S. there are definitely a few, unnecessary changes I've made in an effort to get this to work. 😬
P.P.S. lmk if there's anything I can do, you know, in case you haven't already released a fix in the next couple hours. 😂

@idahogurl
Copy link
Owner

@schmannie Interesting... 🤔 I will take a look on my side and see if I have the same behavior with Rollbar.

@idahogurl
Copy link
Owner

idahogurl commented Apr 26, 2022

@schmannie I was able to get Rollbar to run but its output was causing an error when I tried running the extension tests. I used your branch and switched to esbuild and the problems went away.

I just released v5.0.0 as a pre-release.

P.S. I was was blown away by how fast esbuild runs. Thank you for your branch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests