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

SyntaxError: "foo(" must be followed by ) #278

Closed
maxpatiiuk opened this issue Aug 13, 2023 · 2 comments
Closed

SyntaxError: "foo(" must be followed by ) #278

maxpatiiuk opened this issue Aug 13, 2023 · 2 comments
Labels

Comments

@maxpatiiuk
Copy link

When formatting the following Dockerfile:

FROM ubuntu

RUN (cd out && ls)

The extension fails with the SyntaxError: "foo(" must be followed by ) error. Full error message:

Error in CLI:

npx prettier --write ../../../Test.dockerfile
../../../Test.dockerfile
[error] ../../../Test.dockerfile: Error: runtime error: cannot internalize syntax.File
[error]     at $callDeferred (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/mvdan-sh/index.js:5:23866)
[error]     at $panic (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/mvdan-sh/index.js:5:24449)
[error]     at AT (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/mvdan-sh/index.js:9:7075)
[error]     at $internalize (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/mvdan-sh/index.js:5:34691)
[error]     at $internalize (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/mvdan-sh/index.js:5:33981)
[error]     at e.$externalizeWrapper.e.$externalizeWrapper (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/mvdan-sh/index.js:5:30547)
[error]     at /Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/mvdan-sh/index.js:7:6619
[error]     at e.$externalizeWrapper.e.$externalizeWrapper (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/mvdan-sh/index.js:5:30597)
[error]     at Object.print (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier-plugin-sh/lib/index.cjs:548:11)
[error]     at callPluginPrintFunction (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8420:26)
[error]     at mainPrintInternal (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8369:22)
[error]     at mainPrint (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8356:18)
[error]     at printAstToDoc (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8348:18)
[error]     at coreFormat (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8653:20)
[error]     at formatWithCursor2 (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8837:18)
[error]     at Object.formatWithCursor (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:37229:12)
[error]     at format (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/cli.js:14748:24)
[error]     at formatFiles2 (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/cli.js:14860:22)
[error]     at async main (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/cli.js:15077:5)
[error]     at async Object.run (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/cli.js:15024:5)
/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier-plugin-sh/lib/index.cjs:499
            throw new ShParseError(err);
                  ^

ShParseError [SyntaxError]: "foo(" must be followed by )
    at Object.<anonymous> (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier-plugin-sh/lib/index.cjs:499:19)
    at Generator.next (<anonymous>)
    at /Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier-plugin-sh/lib/index.cjs:438:61
    at new Promise (<anonymous>)
    at __async (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier-plugin-sh/lib/index.cjs:422:10)
    at Object.parse (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier-plugin-sh/lib/index.cjs:470:16)
    at Object.parse (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:7334:23)
    at coreFormat (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8645:18)
    at formatWithCursor2 (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8837:18)
    at Object.formatWithCursor (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:37229:12)
    at format (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/cli.js:14748:24)
    at formatFiles2 (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/cli.js:14860:22)
    at async main (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/cli.js:15077:5)
    at async Object.run (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/cli.js:15024:5) {
  cause: {},
  loc: { start: { column: 1, line: 3 } }
}

Node.js v20.2.0

Errror in VS Code:

["INFO" - 10:52:47 AM] Prettier Options:
{
  "arrowParens": "always",
  "bracketSpacing": true,
  "endOfLine": "lf",
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "singleAttributePerLine": false,
  "bracketSameLine": false,
  "jsxBracketSameLine": false,
  "jsxSingleQuote": false,
  "printWidth": 80,
  "proseWrap": "always",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": true,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "es5",
  "useTabs": false,
  "embeddedLanguageFormatting": "auto",
  "vueIndentScriptAndStyle": true,
  "filepath": "/Users/maxpatiiuk/site/python/specify7/Test.dockerfile",
  "parser": "sh"
}
["ERROR" - 10:52:47 AM] Error formatting document.
["ERROR" - 10:52:47 AM] "foo(" must be followed by )
  1 | FROM ubuntu
  2 |
> 3 | RUN (cd out && ls)
    | ^
SyntaxError: "foo(" must be followed by )
  1 | FROM ubuntu
  2 |
> 3 | RUN (cd out && ls)
    | ^
    at Object.parse (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier-plugin-sh/lib/index.cjs:443:17)
    at Object.parse (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:7334:23)
    at coreFormat (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8645:18)
    at formatWithCursor2 (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:8837:18)
    at /Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:37229:12
    at Object.format (/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/node_modules/prettier/index.js:37243:12)
    at MessagePort.<anonymous> (/Users/maxpatiiuk/.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/worker/prettier-instance-worker.js:1:717)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:694:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
["INFO" - 10:52:47 AM] Formatting completed in 7ms.

System

Replicated with:

"prettier": "3.0.1",
"prettier-plugin-sh": "0.13.1",

and with

"prettier": "2.7.1",
"prettier-plugin-sh": "0.12.6",
@JounQin JounQin closed this as completed Nov 9, 2023
@JounQin JounQin reopened this Nov 9, 2023
@JounQin
Copy link
Member

JounQin commented Nov 9, 2023

Accidentally closed. I'll take a look when I'm free.

@JounQin
Copy link
Member

JounQin commented Nov 10, 2023

I'm sorry, but actually Dockerfile is not officially supported by https://github.com/mvdan/sh what means only basic and simple Dockerfile usage cases can be handled correctly. We can not do much inside.

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

No branches or pull requests

2 participants