# @marketgridsys/prettier

> Prettier is an opinionated code formatter

Latest version **3.5.3-mgs.2** (published 2025-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @marketgridsys/prettier
pnpm add @marketgridsys/prettier
yarn add @marketgridsys/prettier
bun add @marketgridsys/prettier
```

Provides the command `prettier`.

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.5.3-mgs.2 |
| Published | 2025-03-04 |
| First published | 2021-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14 |
| Dependencies | 0 |
| Unpacked size | 7.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | James Long |
| Maintainers | marketgridsys |

## Links

- npm: https://www.npmjs.com/package/@marketgridsys/prettier
- Repository: https://gitlab.com/marketgrid/prettier
- Homepage: https://xpansiv.gitlab.io/XMarkets/mg-import/prettier/
- Issues: https://gitlab.com/marketgrid/prettier/issues
- Funding: https://github.com/prettier/prettier?sponsor=1
- npm.io page: https://npm.io/package/@marketgridsys/prettier

## Recent versions

- 3.5.3-mgs.2 (latest) — 2025-03-04
- 3.5.2-mgs.1 — 2025-02-28
- 3.5.1-mgs.1 — 2025-02-17
- 3.4.0-mgs.2 — 2024-06-13
- 3.4.0-mgs.1 — 2024-06-13
- 2.9.0-mgs.5 — 2023-05-18
- 2.9.0-mgs.4 — 2023-01-09
- 2.9.0-mgs.3 — 2022-12-16
- 2.9.0-mgs.2 — 2022-12-15
- 2.9.0-mgs.1 — 2022-11-25
- 2.7.0-mgs.3 — 2022-06-03
- 2.7.0-mgs.2 — 2022-04-15
- 2.7.0-mgs.1 — 2022-04-14
- 2.6.0-mgs.8 — 2022-03-22
- 2.6.0-mgs.7 — 2022-03-11
- … 19 more at https://npm.io/package/@marketgridsys/prettier/versions

## README

# @marketgridsys/prettier

`@marketgridsys/prettier` is a fork of the popular code formatting tool [Prettier](https://github.com/prettier) that offers improved formatting.

It is fully compatible with all Prettier plugins and integrations, provided they support package aliasing (see usage section below). Try it out today and improve the readability and consistency of your codebase.

This fork:

- Moves binary and modified assignment operators to the beginning of the line.
- Places else, catch and finally statements on new lines.
- Adds braces around multiline if, else, for, while and do statements.
- Adds `--switch-indent` option to control switch case indentation.
- Breaks multiline parenthesized logical expressions.
- Removes extra spaces from for loops.
- Improves wrapping for member chains.
- Breaks multiline function arguments.
- Extends jest.each template string table formatting

## Binary operators and modified assignment operators

Binary operators and modified assignment operators (e.g. `+=`, `-=`, `*=`, `/=`) are placed at the beginning of the line rather than the end of the line. This improves readability as the operators are aligned.

<!-- prettier-ignore -->
```js
// Before: using prettier
someVeryLongStringA &&
  someVeryVeryLongStringB &&
  someVeryVeryVeryLongStringC &&
  someVeryVeryVeryVeryLongStringD

let first_var =
  10000000000000000000000000000000000 + 10000000000000000000000000000000000;
first_var +=
  10000000000000000000000000000000000 + 10000000000000000000000000000000000;
first_var -=
  10000000000000000000000000000000000 + 10000000000000000000000000000000000;
```

<!-- prettier-ignore -->
```js
// After: using @marketgridsys/prettier
someVeryLongStringA
  && someVeryVeryLongStringB
  && someVeryVeryVeryLongStringC
  && someVeryVeryVeryVeryLongStringD;

let first_var =
  10000000000000000000000000000000000 + 10000000000000000000000000000000000;
first_var
  += 10000000000000000000000000000000000 + 10000000000000000000000000000000000;
first_var
  -= 10000000000000000000000000000000000 + 10000000000000000000000000000000000;
```

## Else, catch and finally statements

`else`, `catch` and `finally` statements are placed on new lines rather than inline.

<!-- prettier-ignore -->
```js
// Before: using prettier
function foo(x: string | Array<string>): string {
  if (typeof x === "string") {
    return x;
  } else {
    return x.join();
  }
}

try {
  doSomething()
} catch (e) {
  onError(e)
} finally {
  doSomethingElse()
}
```

<!-- prettier-ignore -->
```js
// After: using @marketgridsys/prettier
function foo(x: string | Array<string>): string {
  if (typeof x === "string") {
    return x;
  }
  else {
    return x.join();
  }
}

try {
  doSomething()
}
catch (e) {
  onError(e)
}
finally {
  doSomethingElse()
}
```

## Braces for multiline statements

Braces are automatically added to multiline `if`, `else`, `for`, `while` and `do` statements. This improve the readability and structure of your code.

<!-- prettier-ignore -->
```js
// Before: using prettier
if (somethingTrue())
  makeACallToAVeryLongFunctionThatPreventsThisFromBeingAOneLineStatement();

if (foo)
  // A comment that makes this a multiline statement
  bar();

while (foo)
  // A comment that makes this a multiline statement
  bar();
```

<!-- prettier-ignore -->
```js
// After: using @marketgridsys/prettier
if (somethingTrue()) {
  makeACallToAVeryLongFunctionThatPreventsThisFromBeingAOneLineStatement();
}

if (foo) {
  // A comment that makes this a multiline statement
  bar();
}

while (foo) {
  // A comment that makes this a multiline statement
  bar();
}
```

## Adds `--switch-indent` option to control switch case indentation

Switch case indentation can be controlled using the `--switch-indent` boolean option.

- `true`: Indent switch statements
- `false` (default): Do not indent switch statements

<!-- prettier-ignore -->
```js
// Using @marketgridsys/prettier with --switch-indent=true
switch (op) {
  case "plus":
    return "+";
  case "minus":
    return "-";
  case "divide":
    return "/";
  case "multiply":
    return "*";
  default:
    throw new Error("Invalid binary operator: " + op);
}

// Using @marketgridsys/prettier with --switch-indent=false (default)
switch (op) {
case "plus":
  return "+";
case "minus":
  return "-";
case "divide":
  return "/";
case "multiply":
  return "*";
default:
  throw new Error("Invalid binary operator: " + op);
}
```

## Break multiline parenthesized logical expressions

Line breaks are automatically added to multiline parenthesized logical expressions. This makes it easier to read complex logic.

<!-- prettier-ignore -->
```jsx
// Before: using prettier
const funnelSnapshotCard =
  (report === MY_OVERVIEW && !ReportGK.xar_metrics_active_capitol_v2) ||
  (report === COMPANY_OVERVIEW &&
    !ReportGK.xar_metrics_active_capitol_v2_company_metrics) ? (
    <ReportMetricsFunnelSnapshotCard metrics={metrics} />
  ) : null;
```

<!-- prettier-ignore -->
```jsx
// After: using @marketgridsys/prettier
const funnelSnapshotCard =
  (report === MY_OVERVIEW && !ReportGK.xar_metrics_active_capitol_v2)
  || (
    report === COMPANY_OVERVIEW
    && !ReportGK.xar_metrics_active_capitol_v2_company_metrics
  ) ? (
    <ReportMetricsFunnelSnapshotCard metrics={metrics} />
  ) : null;
```

## Remove extra spaces from for loops

Empty expressions in `for` statements are collapsed together.

<!-- prettier-ignore -->
```jsx
// Before: using prettier
for ((x in a); ; ) {}
for (a = (a in b); ; ) {}
for (let a = (b in c); ; );
for (a && (b in c); ; );
for ((a) => (b in c); ; );
```

<!-- prettier-ignore -->
```jsx
// After: using @marketgridsys/prettier
for ((x in a);;) {}
for (a = (a in b);;) {}
for (let a = (b in c);;);
for (a && (b in c);;);
for ((a) => (b in c);;);
```

## Improves wrapping for member chains

Member chains automatically wrap to limit the number of function calls per line to enforce a vertical style that is more readable.

<!-- prettier-ignore -->
```jsx
// Before: using prettier
expect(pet).to.have.property("OwnerAddress").that.deep.equals({
  AddressLine1: "Alexanderstrasse",
  AddressLine2: "",
  PostalCode: "10999",
  Region: "Berlin",
  City: "Berlin",
  Country: "DE",
});
```

<!-- prettier-ignore -->
```jsx
// After: using @marketgridsys/prettier
expect(pet)
  .to.have.property("OwnerAddress")
  .that.deep.equals({
    AddressLine1: "Alexanderstrasse",
    AddressLine2: "",
    PostalCode: "10999",
    Region: "Berlin",
    City: "Berlin",
    Country: "DE",
  });
```

## Break multiline function arguments

Line breaks are automatically added to multiline function arguments to enforce a vertical style that is more readable.

<!-- prettier-ignore -->
```jsx
// Before: using prettier
instantiate(game, [
  transform([-0.7, 0.5, 0]),
  render_colored_diffuse(
    game.MaterialDiffuse,
    game.Meshes["monkey_flat"],
    [1, 1, 0.3, 1]
  ),
]);
```

<!-- prettier-ignore -->
```jsx
// After: using @marketgridsys/prettier
instantiate(
  game,
  [
    transform([-0.7, 0.5, 0]),
    render_colored_diffuse(
      game.MaterialDiffuse,
      game.Meshes["monkey_flat"],
      [1, 1, 0.3, 1]
    ),
  ]
);
```

# Extend jest.each template string table formatting

Prettier formats template strings like `jest.each` tables if the preceding chained expression matches `describe.each`, `it.each` or `test.each`. This fork extends this to include functions or chained expressions which include the word "table" (case-insensitive).

<!-- prettier-ignore -->
```jsx
// Before: using prettier
table`
a|b|expected
${1}|${1}|${2}
${1}|${2}|${3}
${2}|${1}|${3}
`
```

<!-- prettier-ignore -->
```jsx
// After: using @marketgridsys/prettier
table`
  a    | b    | expected
  ${1} | ${1} | ${2}
  ${1} | ${2} | ${3}
  ${2} | ${1} | ${3}
`
```

## Usage

If you use Yarn, you can [install using an alias](https://yarnpkg.com/lang/en/docs/cli/add/#toc-yarn-add-alias) so that `require('prettier')` transparently resolves to this fork:

```sh
$ yarn add -D prettier@npm:@marketgridsys/prettier
```

[![Prettier Banner](https://unpkg.com/prettier-logo@1.0.3/images/prettier-banner-light.svg)](https://prettier.io)

<h2 align="center">Opinionated Code Formatter</h2>

<p align="center">
  <em>
    JavaScript
    · TypeScript
    · Flow
    · JSX
    · JSON
  </em>
  <br />
  <em>
    CSS
    · SCSS
    · Less
  </em>
  <br />
  <em>
    HTML
    · Vue
    · Angular
  </em>
  <br />
  <em>
    GraphQL
    · Markdown
    · YAML
  </em>
  <br />
  <em>
    <a href="https://prettier.io/docs/plugins">
      Your favorite language?
    </a>
  </em>
</p>

<p align="center">
  <a href="https://github.com/prettier/prettier/actions?query=workflow%3AProd+branch%3Amain">
    <img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/prettier/prettier/prod-test.yml?label=Prod&style=flat-square"></a>
  <a href="https://github.com/prettier/prettier/actions?query=workflow%3ADev+branch%3Amain">
    <img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/prettier/prettier/dev-test.yml?label=Dev&style=flat-square"></a>
  <a href="https://github.com/prettier/prettier/actions?query=workflow%3ALint+branch%3Amain">
    <img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/prettier/prettier/lint.yml?label=Lint&style=flat-square"></a>
  <a href="https://codecov.io/gh/prettier/prettier">
    <img alt="Codecov Coverage Status" src="https://img.shields.io/codecov/c/github/prettier/prettier.svg?style=flat-square"></a>
  <a href="https://twitter.com/acdlite/status/974390255393505280">
    <img alt="Blazing Fast" src="https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg?style=flat-square"></a>
  <br/>
  <a href="https://www.npmjs.com/package/prettier">
    <img alt="npm version" src="https://img.shields.io/npm/v/prettier.svg?style=flat-square"></a>
  <a href="https://www.npmjs.com/package/prettier">
    <img alt="weekly downloads from npm" src="https://img.shields.io/npm/dw/prettier.svg?style=flat-square"></a>
  <a href="#badge">
    <img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"></a>
  <a href="https://twitter.com/PrettierCode">
    <img alt="Follow Prettier on Twitter" src="https://img.shields.io/badge/%40PrettierCode-9f9f9f?style=flat-square&logo=x&labelColor=555"></a>
</p>

## Intro

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

### Input

<!-- prettier-ignore -->
```js
foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());
```

### Output

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

Prettier can be run [in your editor](https://prettier.io/docs/editors) on-save, in a [pre-commit hook](https://prettier.io/docs/precommit), or in [CI environments](https://prettier.io/docs/cli#list-different) to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!

---

**[Documentation](https://prettier.io/docs/)**

[Install](https://prettier.io/docs/install) ·
[Options](https://prettier.io/docs/options) ·
[CLI](https://prettier.io/docs/cli) ·
[API](https://prettier.io/docs/api)

**[Playground](https://prettier.io/playground/)**

---

## Badge

Show the world you're using _Prettier_ → [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

```md
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
```

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).

---
_Source: https://npm.io/package/@marketgridsys/prettier · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
