简体   繁体   中英

Prettier shell script format

Can I format template literal embedded shell script with Prettier?

Example:

Before formating:

import {bash} from 'random-bash-runner'

await bash`
a_bash_command argument1 \
     main-dev \
argument4 --database=name --quiet`

After formatting:

import {bash} from 'random-bash-runner'

await bash`
  a_bash_command argument1 \
    main-dev \
    argument4 l \
    --database=name --quiet
`

Thanks

Prettier can, with the setting --embedded-language-formatting=auto (see here ), format templates.

However, the languages it can format (from it's extension page on VSCode) are:

JavaScript · TypeScript · Flow · JSX · JSON
CSS · SCSS · Less
HTML · Vue · Angular
GraphQL · Markdown · YAML

So I'm afraid no, this cannot be accomplished by Prettier as bash or shell are not on this list.

Prettier cannot format bash files. Instead you can try either shell-format or Bash Beautify extensions for VSCode to format your bash scripts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM