benjamn / recast

JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator
MIT License
4.95k stars 346 forks source link

Allow pretty-printer configuration via .eslintrc files #226

Open benjamn opened 8 years ago

benjamn commented 8 years ago

This came up in the discussion over at https://gitter.im/benjamn/recast, thanks to @hzoo.

Though I've known for a long time that the printer isn't very configurable, it seemed like a bad idea to invent a Recast-specific set of configuration options, so I really like the idea of just borrowing the one that .eslintrc files already use.

This is potentially a lot of work (adding multiple new cases to each printer rule), but it can be done incrementally, I think.

jamestalmage commented 8 years ago

This is potentially a lot of work, (adding multiple new cases to each printer rule)

Just to pile on :stuck_out_tongue: , what about .editorconfig, and configs to match zero-config linters like standard, and xo?

I am pretty sure it is possible to coerce all those to .eslintrc format (standard and xo are just eslint wrappers, so almost definitely in that case).

benjamn commented 8 years ago

I'm happy to pick whichever format can most easily accommodate coerced versions of other formats!

juliankrispel commented 8 years ago

Ooooh this would be so neat

skovhus commented 8 years ago

What about detecting it based on the existing code? Instead of configuration we can try to detect it by looking at strings in the code (i.e rawValue of string literals).

hzoo commented 8 years ago

Yeah that should definetely work for that particular case but it would cover spacing, newlines, etc.