New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prettierx

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettierx

prettierx - less opinionated code formatter fork of prettier

  • 0.15.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
decreased by-11.3%
Maintainers
1
Weekly downloads
 
Created
Source

prettierx - less opinionated code formatter fork of prettier

License: MIT npm

Unofficial fork, intended to provide some additional options to help improve consistency with feross/standard and Flet/semistandard. This fork is an attempt to pick up where arijs/prettier-miscellaneous left off.

prettierx as a Prettier plugin

Provides the additional formatting options in a prettier plugin (or two).

Status: experimental

Major TODO items:

  • update to use recent prettierx which uses Babel parser to parse TypeScript by default ref: brodybits/prettierx#54
  • support the additional formatting options from the command line, somehow (additional formatting options will work from the command line if run with the plugin)
  • improve the documentation

ref: brodybits/prettierx#8

CLI Usage

Quick CLI usage:

prettierx <options> <file(s)>

Additional prettierx options

OptionDefault valueCLI OverrideAPI OverrideDescription
Align object propertiesfalse--align-object-propertiesalignObjectProperties: <bool>Align colons in multiline object literals (not applied with any of the JSON parsers).
Space before function parenthesesfalse--space-before-function-parenspaceBeforeFunctionParen: <bool>Put a space before function parenthesis, in all declarations. (Default is to put a space before function parenthesis for anonymous functions only.)
Spaces around the star (*) in generator functionsfalse--generator-star-spacinggeneratorStarSpacing: <bool>Add spaces around the star (*) in generator functions (before and after - from eslint). (Default is after only.)
Spaces around the star (*) in yield* expressionsfalse--yield-star-spacingyieldStarSpacing: <bool>Add spaces around the star (*) in yield* expressions (before and after - from eslint).
Indent chainstrue--no-indent-chainsindentChains: <bool>Print indents at the start of chained calls.
Align ternary linestrue--no-align-ternary-linesalignTernaryLines: <bool>Keep default alignment of ternary expression lines, which is in conflict with "Standard JS" formatting in case of certain nested ternary expressions. See ./docs/options.md ..
paren spacingfalse--paren-spacingparenSpacing: <bool>Print spaces between parens, WordPress style (not recommended with default `arrowParens: "always" setting). Status: experimental, with some known paren spacing formatting issues.
break before elsefalse--break-before-elsebreakBeforeElse: <bool>Always add a line break before else.
Formatting of import statementsautosee ./docs/options.mdsee ./docs/options.mdFormatting of import statements, may be oneline to avoid conflict with VSCode "Organize Imports" feature.
HTML void element tagsfalse--html-void-tagsFormat void HTML elements as void tags.

"Standard JS" formatting options

The following options should be used to format the code as consistently as possible with "Standard JS":

  • --arrow-parens avoid (arrowParens: "avoid")
  • --generator-star-spacing (generatorStarSpacing: true)
  • --space-before-function-paren (spaceBeforeFunctionParen: true)
  • --single-quote (singleQuote: true)
  • --jsx-single-quote (jsxSingleQuote: true)
  • --no-semi (semi: false)
  • --yield-star-spacing (yieldStarSpacing: true)
  • --trailing-comma none (trailingComma: "none")
  • and possibly --no-align-ternary-lines (alignTernaryLines: false) - see ./docs/options.md for some more info

Note that this tool does not follow any of the other "Standard JS" rules. It is recommended to use this tool together with eslint, in some form, to archive correct formatting according to "Standard JS".

Any known conflicts with "Standard JS" will be tracked in open issues with the conflict-with-standard tag.

  • --arrow-parens avoid (arrowParens: "avoid"), especially in combination with --paren-spacing (parenSpacing: true).

Input

foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());

Output

foo(
  reallyLongArg(),
  omgSoManyParameters(),
  IShouldRefactorThis(),
  isThereSeriouslyAnotherOne()
);

Integration with eslint

A couple packages by @aMarCruz (Alberto Martínez):


Contributing

See CONTRIBUTING.md.

FAQs

Package last updated on 14 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc