# @shopify/loom-plugin-prettier

> loom plugin for linting with prettier

Latest version **2.0.1** (published 2022-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @shopify/loom-plugin-prettier
pnpm add @shopify/loom-plugin-prettier
yarn add @shopify/loom-plugin-prettier
bun add @shopify/loom-plugin-prettier
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2022-08-23 |
| First published | 2021-09-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^12.22.0 \|\| ^14.17.0 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Shopify Inc. |
| Maintainers | wcandillon, jplhomer, marytal, themallen, nathanpjf, shopify-dep, goodforonefare, lemonmade, vsumner, wizardlyhel, antoine.grant, tsov, andyw8-shopify, henrytao, hannachen, andrewapperley, iainmcampbell, vividviolet, bpscott |

## Links

- npm: https://www.npmjs.com/package/@shopify/loom-plugin-prettier
- Repository: https://github.com/Shopify/loom
- Homepage: https://github.com/Shopify/loom/blob/main/packages/loom-plugin-prettier/README.md
- Issues: https://github.com/Shopify/loom/issues
- npm.io page: https://npm.io/package/@shopify/loom-plugin-prettier

## Dependencies (1)

- [@shopify/loom](https://npm.io/package/@shopify/loom.md) ^1.0.2

## Recent versions

- 2.0.1 (latest) — 2022-08-23
- 0.3.0-alpha.0 (beta) — 2021-10-12
- 2.0.0 — 2021-12-03
- 1.0.1 — 2021-11-23
- 1.0.0 — 2021-10-22
- 0.3.0-alpha.4 — 2021-10-15
- 0.3.0-alpha.3 — 2021-10-15
- 0.3.0-alpha.2 — 2021-10-15
- 0.3.0-alpha.1 — 2021-10-13
- 0.2.0 — 2021-09-13

## README

# `@shopify/loom-plugin-prettier`

This package provides a `loom` plugin that runs [Prettier](https://prettier.io) as part of the `loom lint` command.

This package does not make any assumptions about what version of Prettier or what ruleset you should use. You will need to install `prettier` as a peerDependency and you will need to [configure Prettier](https://prettier.io/docs/en/configuration.html) yourself. We recommend using the preset provided by [`@shopify/prettier-config`](https://github.com/Shopify/web-configs/tree/main/packages/prettier-config).

## Installation

```sh
yarn add @shopify/loom-plugin-prettier prettier --dev
```

## Usage

Add `prettier` to your loom workspace plugins.

```js
import {createWorkspace} from '@shopify/loom';
import {prettier} from '@shopify/loom-plugin-prettier';

// `createWorkspace` may be `createPackage`, or `createWebApp` if your workspace
// consists of a single project
export default createWorkspace((workspace) => {
  workspace.use(prettier());
});
```

By default prettier runs over everything in the current folder. You can modify the files that are processed by passing in a `files` glob to the plugin's options. This is useful if you use `eslint-plugin-prettier` or `stylelint-prettier` to run prettier as part of `eslint` or `stylelint` as there is no point to running prettier over those files twice.

```js
export default createWorkspace((workspace) => {
  // Run prettier on md, json, yaml and yml files
  workspace.use(prettier({files: '**/*.{md,json,yaml,yml}'}));
});
```

### Running only Prettier when linting

To run only the Prettier linting step, you can use `--isolate-step`:

```sh
loom lint --isolate-step=Prettier
```

### Hooks

This plugin adds the following hooks to `LintWorkspaceConfigurationCustomHooks`:

- `prettierFlags`: an object of options to convert into command line flags for the `prettier` command. These options are camelcase versions of their [CLI counterparts](https://prettier.io/docs/en/cli.html).

  ```js
  import {createWorkspacePlugin} from '@shopify/loom';

  function demoPlugin() {
    return createWorkspacePlugin('Demo', ({tasks: {lint}}) => {
      lint.hook(({hooks}) => {
        hooks.configure.hook((configure) => {
          // Trigger error when encountering unknown files matched by patterns
          configure.prettierFlags?.hook((flags) => ({
            ...flags,
            ignoreUnknown: false,
          }));
        });
      });
    });
  }
  ```

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