prettier-plugin-coffeescript
prettier-plugin-coffeescript copied to clipboard
Just removes values before dot
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})"
??
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
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.
Ok I tried running this plugin against that whole file and am seeing expected formatting, what commands did you run to format it?
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:

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.