Giter Site home page Giter Site logo

robinnedergard / prettierx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simonmika/prettierx

0.0 0.0 1.0 53.1 MB

less opinionated code formatter fork of prettier

License: MIT License

JavaScript 84.31% TypeScript 4.49% CSS 6.61% HTML 4.02% Vue 0.54% Shell 0.03%

prettierx's Introduction

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:

  • support option to use Babel parser to parse TypeScript ref: brodybits/prettierx#54
  • support the additional formatting options from the command line, somehow

ref: brodybits/prettierx#8

CLI Usage

Quick CLI usage:

prettierx <options> <file(s)>

Additional prettierx options

Option Default value CLI Override API Override Description
Align object properties false --align-object-properties alignObjectProperties: <bool> Align colons in multiline object literals (not applied with any of the JSON parsers).
Space before function parentheses false --space-before-function-paren spaceBeforeFunctionParen: <bool> Put a space before function parenthesis, in all declarations. (Default is to put a space before function parenthesis for anonymous functions only.)
Space before function parentheses false --space-before-function-paren spaceBeforeFunctionParen: <bool> Put a space before function parenthesis.
Spaces around the star (*) in generator functions false --generator-star-spacing generatorStarSpacing: <bool> Add spaces around the star (*) in generator functions (before and after - from eslint). (Default is after only.)
Spaces around the star (*) in yield* expressions false --yield-star-spacing yieldStarSpacing: <bool> Add spaces around the star (*) in yield* expressions (before and after - from eslint).
Indent chains true --no-indent-chains indentChains: <bool> Print indents at the start of chained calls.
Align ternary lines true --no-align-ternary-lines alignTernaryLines: <bool> Align ternary lines in case of multiline ternery term (default behavior, which is in conflict with ESLint/StandardJS behavior). Should be disabled for consistency with ESLint/StandardJS behavior.
paren spacing false --paren-spacing parenSpacing: <bool> Print spaces between parens, WordPress style.
break before else false --break-before-else breakBeforeElse: <bool> Always add a line break before else.
Formatting of import statements auto see ./docs/options.md see ./docs/options.md Formatting of import statements, may be oneline to avoid conflict with VSCode "Organize Imports" feature.

standard-like formatting

The following options should be used to format the code according to standard js:

  • --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)
  • --no-align-ternary-lines (alignTernaryLines: false)
  • --trailing-comma none (trailingComma: "none")

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 achive correct formatting according to standard js.

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

other recommended settings

  • --arrow-parens avoid (arrowParens: "avoid")

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.