prettier single-line pragma
See original GitHub issueI have a case of code like so:
import * as cp from 'child_process'
import * as fs from 'fs-jetpack'
const json = cp.spawnSync('yarn',['-s','docs','project','index', '--json'], {encoding:'utf8'})
fs.write('api.json', json)
const md = cp.spawnSync('yarn',['-s','docs','project','index'], {encoding:'utf8'})
fs.write('api.md', md)
Prettier wants to turn it into:
import * as cp from 'child_process'
import * as fs from 'fs-jetpack'
const json = cp.spawnSync(
'yarn',
['-s', 'docs', 'project', 'index', '--json'],
{ encoding: 'utf8' }
)
fs.write('api.json', json)
const md = cp.spawnSync('yarn', ['-s', 'docs', 'project', 'index'], {
encoding: 'utf8',
})
fs.write('api.md', md)
This is a small script, case, I really don’t want it how prettier wants it.
So I opt out:
import * as cp from 'child_process'
import * as fs from 'fs-jetpack'
// prettier-ignore
const json = cp.spawnSync('yarn',['-s','docs','project','index', '--json'], {encoding:'utf8'})
fs.write('api.json', json)
// prettier-ignore
const md = cp.spawnSync('yarn',['-s','docs','project','index'], {encoding:'utf8'})
fs.write('api.md', md)
But I wish I could still benefit from prettier formatting within the single line. For example turn ('yarn',[
into ('yarn', [
and {encoding:'utf8'}
into { encoding: 'utf8' }
.
I think such a mode could be made available like so:
import * as cp from 'child_process'
import * as fs from 'fs-jetpack'
// prettier-single-line
const json = cp.spawnSync('yarn',['-s','docs','project','index', '--json'], {encoding:'utf8'})
fs.write('api.json', json)
// prettier-single-line
const md = cp.spawnSync('yarn',['-s','docs','project','index'], {encoding:'utf8'})
fs.write('api.md', md)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Options
(A single-line array, for example, never gets trailing commas.) Valid options: ... This works well when used in tandem with the --require-pragma option....
Read more >How do I turn off this Eslint error "Expected new line break ...
This warning says that you should avoid single line tags. For example, instead of. <nuxt-link to="/test">Another page</nuxt-link>.
Read more >Styling Angular apps using Prettier and TSLint (2020)
Code Style Matters: Styling Angular apps using Prettier and TSLint (2020). Share on facebook. Share on google ... "directive-class-suffix": true,.
Read more >eslint-plugin-react
... default to "createReactClass" "pragma": "React", // Pragma to use, ... jsx-max-props-per-line, Enforce maximum of props on a single line ...
Read more >Prettier 2.1: new --embedded-language-formatting option ...
Support insertPragma and requirePragma in files with shebang (#8376 by ... Omit trailing semicolon on single line style attributes (#8013 by ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@j-f1 If we define “works” as does it support auto-formatting along a single line, then no.
Yes! I don’t know why that came out wrong.