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] TypeError: input.replace is not a function #74

Closed
1 task done
arthur-vanpassel opened this issue Apr 11, 2024 · 2 comments
Closed
1 task done

[error] TypeError: input.replace is not a function #74

arthur-vanpassel opened this issue Apr 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@arthur-vanpassel
Copy link

arthur-vanpassel commented Apr 11, 2024

Description

I've installed the prettier-plugin-hubl as described in the readme, but when I try to run prettier, I get the following error:

["ERROR" - 11:30:33 AM] Error formatting document.
["ERROR" - 11:30:33 AM] input.replace is not a function
TypeError: input.replace is not a function
    at preserveFormatting ([path_to_my_folder]\node_modules\@hubspot\prettier-plugin-hubl\prettier\dist\index.js:135:19)
    at Object.preprocess ([path_to_my_folder]\node_modules\@hubspot\prettier-plugin-hubl\prettier\dist\index.js:153:27)
    at parse4 (file:///[path_to_my_folder]/node_modules/prettier/index.mjs:22113:43)
    at async coreFormat (file:///[path_to_my_folder]/node_modules/prettier/index.mjs:22607:7)
    at async formatWithCursor (file:///[path_to_my_folder]/node_modules/prettier/index.mjs:22809:14)
    at async Module.format2 (file:///[path_to_my_folder]/node_modules/prettier/index.mjs:24194:25)

Expected behavior

I want my html-hubl files to format

To Reproduce

package.json:

{
  "scripts": {
    "hs-fetch": "hs fetch . my-project --overwrite",
    "hs-watch": "hs watch my-project/ ."
  },
  "dependencies": {
    "@hubspot/cli": "^5.1.1",
    "@hubspot/prettier-plugin-hubl": "^0.2.5",
    "prettier": "^3.2.5"
  }
}

.prettierrc.json:

{
  "plugins": [
    "prettier",
    "@hubspot/prettier-plugin-hubl"
  ],
  "overrides": [
    {
      "files": "*.html",
      "options": {
        "parser": "hubl"
      }
    }
  ]
}

I also have a .vscode/settings.json set up:

{
  "files.associations": {
    "*.html": "html-hubl",
    "*.css": "css-hubl",
  },
  "[html-hubl]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
  },
}

When I try to run yarn prettier --write my-project/**/*.html or npx prettier --write my-project/**/*.html,
or when I execute the automatic format in vscode, I get the error.

Additional context

Full error log:

npx prettier --write **/*.html
my-project/2 videos.module/module.html
[error] my-project/2 videos.module/module.html: TypeError: input.replace is not a function
[error]     at preserveFormatting ([path_to_my_folder]\node_modules\@hubspot\prettier-plugin-hubl\prettier\dist\index.js:135:20)
[error]     at Object.preprocess ([path_to_my_folder]\node_modules\@hubspot\prettier-plugin-hubl\prettier\dist\index.js:153:27)
[error]     at parse4 (file:///[path_to_my_folder]/node_modules/prettier/index.mjs:22113:43)
[error]     at async coreFormat (file:///[path_to_my_folder]/node_modules/prettier/index.mjs:22607:7)
[error]     at async formatWithCursor (file:///[path_to_my_folder]/node_modules/prettier/index.mjs:22809:14)
[error]     at async formatFiles (file:///[path_to_my_folder]/node_modules/prettier/internal/cli.mjs:6673:18)
[error]     at async main (file:///[path_to_my_folder]/node_modules/prettier/internal/cli.mjs:7081:5)
[error]     at async Module.run (file:///[path_to_my_folder]/node_modules/prettier/internal/cli.mjs:7027:5)

Checklist

  • I have checked the known issues to make sure this isn’t already a known issue.
@arthur-vanpassel arthur-vanpassel added the bug Something isn't working label Apr 11, 2024
@j-malt
Copy link
Contributor

j-malt commented May 7, 2024

👋 Hi! I am not able to reproduce this issue. Your configuration looks all correct. Were you able to resolve this? If not, could you provide a snippet of the file that was causing this issue?

@arthur-vanpassel
Copy link
Author

Yes! the prettier package was not the right version. I replaced "prettier": "^3.2.5" with "prettier": "2.x" and now it's working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants