facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.41k stars 596 forks source link

prettier plugin: Infinite loop for malformed graphql relay query #1359

Open ayroblu opened 1 month ago

ayroblu commented 1 month ago

Bug Description

The following code hangs forever:

const prettier = require('@prettier/sync');
const prettierOptions = {
  plugins: ['prettier-plugin-hermes-parser'],
};
const code = `// @flow strict
            function App() {
            const data = useLazyLoadQuery(graphql\`query AppQuery {} \`, {})
          }
          `;

for (let i = 0; i < 4; ++i) {
  console.log(
    prettier.format(code, { ...prettierOptions, parser: 'hermes' }).trim()
  );
}

Hermes git revision (if applicable): "prettier-plugin-hermes-parser": "0.19.2",

The Expected Behavior

Don't have infinite loops