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

Bug in src/embed.js @getParser(node, opts) #810

Open
shane-au-wade opened this issue Aug 12, 2024 · 1 comment
Open

Bug in src/embed.js @getParser(node, opts) #810

shane-au-wade opened this issue Aug 12, 2024 · 1 comment

Comments

@shane-au-wade
Copy link

shane-au-wade commented Aug 12, 2024

Stack trace

TypeError: Cannot read properties of undefined (reading 'toLowerCase')
    at getParser (file:///Users/shane/repos/brm/node_modules/@prettier/plugin-xml/src/embed.js:56:21)
    at embed (file:///Users/shane/repos/brm/node_modules/@prettier/plugin-xml/src/embed.js:121:18)
    at recurse (file:///Users/shane/repos/brm/node_modules/prettier/index.mjs:22194:20)
    at AstPath.each (file:///Users/shane/repos/brm/node_modules/prettier/index.mjs:20791:9)
    at recurse (file:///Users/shane/repos/brm/node_modules/prettier/index.mjs:22189:16)
    at AstPath.call (file:///Users/shane/repos/brm/node_modules/prettier/index.mjs:20753:14)
    at recurse (file:///Users/shane/repos/brm/node_modules/prettier/index.mjs:22191:16)
    at AstPath.each (file:///Users/shane/repos/brm/node_modules/prettier/index.mjs:20791:9)
    at recurse (file:///Users/shane/repos/brm/node_modules/prettier/index.mjs:22189:16)
    at AstPath.call (file:///Users/shane/repos/brm/node_modules/prettier/index.mjs:20753:14)

console.log(node)

Screenshot 2024-08-12 at 11 23 49 AM

and the function is attempting to destructured some properties that don't exist

const { Name, attribute } = node; let parser = Name.toLowerCase();

thus we get the undefined TypeError

details of my machine

Screenshot 2024-08-12 at 11 27 04 AM

prettier config

{
  "trailingComma": "es5",
  "tabWidth": 2,
  "printWidth": 120,
  "semi": false,
  "singleQuote": false,

  "language": "postgresql",
  "keywordCase": "upper",

  "embeddedSqlTags": ["db.sql", "sql"],
  "embeddedSqlComments": ["db.sql", "sql"],

  "overrides": [
    {
      "files": ["*.md", "*.y?(a)ml"],
      "options": {
        "tabWidth": 2
      }
    }
  ],

  "plugins": ["prettier-plugin-embed", "prettier-plugin-sql", "@prettier/plugin-xml"]
}

command to reproduce

npx prettier --check . --log-level warn
@shane-au-wade
Copy link
Author

I tried to fix this up, but I don't have much context of the upstream/downstream code.

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

1 participant