Tabs vs spaces and single vs double quotes in existing files
#118Closes #44 Closes #118 Relates #100
This basically duplicates #100 at this point. See #100 for up and downsides of this approach.
I was initially intending to get rid of a lot more dependencies (like the dependencies for handling html) and use svelte-ast-print
instead, but this was opening too many issues at the same time. That's why I opted to "only" switch to acorn
and esrap
here, the rest can be done later.
Relevant PR's / issues
Benefits
svelte
ecosystemrecast
esrap
Downsides
TSEstree
as no good public alternative exists, that matches acorn
s output. We do have @typescript-eslint/types
but that was just the one with the smallest pain points. Still exploring other options.We now default to tabs and single quotes in new files
We have guessIndentString
, but it's only used for JSON. Can we use guessIndentString
for JS/TS as well? Barring that, can we set the formatting for existing files to match the default for new files?
I don't think this is possible in a reasonable manner. If this would work then as post-processing step after serializing the ast. In that case i think we should rather spend effort in solving the problem once and for all via #100
Wouldn't we need to do roughly the same thing in either case? Whether we're using recast or esrap to print the file, I'd expect we would need to tell it whether to use tabs/spaces and single/double quotes. Or does esrap have built-in detection for that already?
Fair point, looks like you are right. esrap
seems to always use tabs and single quotes. Does not look like it has any detection for it, or any options regarding this...
Interesting. Maybe we can do the same and see if people complain. If so, then we'll know we need to add an option to esrap