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

Just removes values before dot #184

Open
wclr opened this issue Nov 25, 2021 · 5 comments
Open

Just removes values before dot #184

wclr opened this issue Nov 25, 2021 · 5 comments

Comments

@wclr
Copy link

wclr commented Nov 25, 2021

Why this:

concat = (list...) ->
  r=''.concat (list.map (i) -> "(?:#{toString i})")...
  "(?:#{r})"

formatted to this:

concat = (list...) ->
  parts = .map (i) -> "(?:#{toString i})"
  r = .concat parts...
  "(?:#{r})"

??

@helixbass
Copy link
Owner

Hi, Prettier shouldn't "refactor" the code (ie change the AST) like in your example where parts doesn't exist in the original code. And when I try running the original code through this plugin I get expected results. So I'd guess you have something else in your toolchain that is causing this?

Feel free to post an example repo where you can reproduce this behavior if you're having trouble tracking it down

@wclr
Copy link
Author

wclr commented Nov 26, 2021

Thanks for the reply!

You can take a whole file here: https://github.com/purescript-contrib/atom-language-purescript/blob/ccaef631dd37ae65da24caa2aed22f69455458ad/src/purescript.coffee

Wanted to make it formated, but failed.

@helixbass
Copy link
Owner

Ok I tried running this plugin against that whole file and am seeing expected formatting, what commands did you run to format it?

@wclr
Copy link
Author

wclr commented Nov 26, 2021

I'm using prettier plugin for vscode:

["INFO" - 1:13:57 AM] Formatting file:///d%3A/Code/atom-language-purescript/src/purescript.coffee
["INFO" - 1:13:57 AM] Using ignore file (if present) at d:\Code\atom-language-purescript\.prettierignore
["INFO" - 1:13:57 AM] File Info:
{
  "ignored": false,
  "inferredParser": "coffeescript"
}
["INFO" - 1:13:57 AM] No local configuration (i.e. .prettierrc or .editorconfig) detected, falling back to VS Code configuration
["INFO" - 1:13:57 AM] Prettier Options:
{
  "arrowParens": "always",
  "bracketSpacing": true,
  "endOfLine": "lf",
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxBracketSameLine": false,
  "jsxSingleQuote": false,
  "printWidth": 80,
  "proseWrap": "preserve",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": true,
  "singleQuote": false,
  "tabWidth": 2,
  "trailingComma": "es5",
  "useTabs": false,
  "vueIndentScriptAndStyle": false,
  "filepath": "d:\\Code\\atom-language-purescript\\src\\purescript.coffee",
  "parser": "coffeescript"
}
["INFO" - 1:13:57 AM] Formatting completed in 0.212ms.

and get such result:
image

@alxarch
Copy link

alxarch commented May 9, 2022

I am also observing this problem.
The README.md explains that in order to use this plugin you need to use a prettier fork from github:helixbass/prettier instead of the NPM published version of prettier.
After I switched to the fork, it works fine.
Apparently the fork adds some functinality required to properly handle coffeescript AST and AFAICT upstream prettier has not accepted the PR yet because it is too specific to coffeescript.

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

3 participants