|
| 1 | +# `quilt run` |
| 2 | + |
| 3 | +The `quilt run` command allows you to run some tools that are packaged with [Craft](../craft.md), Quilt’s optional development tool. Using `quilt run` is an alternative to using the `quilt` `test`, `type-check`, and `lint` commands, which automatically run theQuilt’s preferred set of [tools](TODO) that are relevant for a given development task. `quilt run` allows you to use the underlying tools more directly, while still benefitting from Craft’s smart defaults (and its [plugin-based configuration system](../craft.md#configuring-hooks)). |
| 4 | + |
| 5 | +To use `quilt run`, you must provide an additional argument: the name of the tool to run. The following tools can be run directly using `quilt run`: |
| 6 | + |
| 7 | +- [TypeScript](TODO), using [`quilt run typescript` or `quilt run tsc`](#quilt-run-typescript) |
| 8 | +- [Jest](TODO), using [`quilt run jest`](#quilt-run-jest) |
| 9 | +- [ESLint](TODO), using [`quilt run eslint`](#quilt-run-eslint) |
| 10 | +- [Prettier](TODO), using [`quilt run prettier`](#quilt-run-prettier) |
| 11 | + |
| 12 | +## `quilt run typescript` |
| 13 | + |
| 14 | +`quilt run typescript` (aliased as `quilt run tsc`) allows you to run the TypeScript compiler, `tsc`. You can pass this command any of the [flags accepted by the `tsc` executable](https://www.typescriptlang.org/docs/handbook/compiler-options.html): |
| 15 | + |
| 16 | +```sh |
| 17 | +# Run TypeScript in watch mode |
| 18 | +pnpm exec quilt run typescript --watch |
| 19 | +``` |
| 20 | + |
| 21 | +By default, this command will run `tsc` with the [`--build` flag, which enables Project References](https://www.typescriptlang.org/docs/handbook/project-references.html). This matches the default way Quilt runs `tsc` when you use the [`quilt type-check` command](TODO). To disable this behavior, pass a `--no-build` flag to this command: |
| 22 | + |
| 23 | +```sh |
| 24 | +pnpm exec quilt run typescript --no-build |
| 25 | +``` |
| 26 | + |
| 27 | +## `quilt run jest` |
| 28 | + |
| 29 | +`quilt run jest` allows you to run the Jest test runner. You can pass this command any of the [flags accepted by the `jest` executable](https://jestjs.io/docs/cli): |
| 30 | + |
| 31 | +```sh |
| 32 | +# Run Jest on test files matching /app/, with test coverage enabled, |
| 33 | +# and without tests being able to print to the console |
| 34 | +pnpm exec quilt run jest app --silent --coverage |
| 35 | +``` |
| 36 | + |
| 37 | +Unlike when running the [`quilt test` command](TODO), Using `quilt run jest` does not automatically run Jest in watch mode. To enable watch mode, you must run this command with the [`--watch`](https://jestjs.io/docs/cli#--watch) or [`--watchAll`](https://jestjs.io/docs/cli#--watchall) Jest flags: |
| 38 | + |
| 39 | +```sh |
| 40 | +pnpm exec quilt run jest --watch |
| 41 | +``` |
| 42 | + |
| 43 | +## `quilt run eslint` |
| 44 | + |
| 45 | +`quilt run eslint` allows you to run the ESLint linter. You can pass this command any of the [flags accepted by the `eslint` executable](https://eslint.org/docs/latest/user-guide/command-line-interface): |
| 46 | + |
| 47 | +```sh |
| 48 | +# Run `eslint` with a dry run of fixable errors |
| 49 | +pnpm exec quilt run eslint --fix-dry-run |
| 50 | +``` |
| 51 | + |
| 52 | +By default, this command runs on the entire contents of the directory you run this command from, just like when running [`quilt lint`](TODO). You can run ESLint on only a subset of your project by passing additional positional arguments: |
| 53 | + |
| 54 | +```sh |
| 55 | +# Run `eslint` on the ./app directory, relative to where you are running this command |
| 56 | +pnpm exec quilt run eslint ./app |
| 57 | +``` |
| 58 | + |
| 59 | +This command runs on JavaScript and TypeScript files, using the same configurable hooks as `quilt lint`. You can run ESLint on a different set of extensions by explicitly passing the [ESLint `--ext` flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--ext): |
| 60 | + |
| 61 | +```sh |
| 62 | +# Run `eslint` only on JavaScript files |
| 63 | +pnpm exec quilt run eslint --ext .js |
| 64 | +``` |
| 65 | + |
| 66 | +Like `quilt lint`, this command defaults to running with ESLint’s [cache enabled](https://eslint.org/docs/latest/user-guide/command-line-interface#--cache). To disable this behavior, pass a `--no-cache` flag: |
| 67 | + |
| 68 | +```sh |
| 69 | +# Run `eslint` without cache |
| 70 | +pnpm exec quilt run eslint --no-cache |
| 71 | +``` |
| 72 | + |
| 73 | +## `quilt run prettier` |
| 74 | + |
| 75 | +`quilt run prettier` allows you to run the Prettier linter. You can pass this command any of the [flags accepted by the `prettier` executable](https://prettier.io/docs/en/cli.html): |
| 76 | + |
| 77 | +```sh |
| 78 | +# Run `prettier`, preferring single quotes over double quotes |
| 79 | +pnpm exec quilt run prettier --single-quote |
| 80 | +``` |
| 81 | + |
| 82 | +By default, this command runs on a set of extensions that includes all the file types [Prettier is able to format](https://prettier.io/docs/en/index.html), except for JavaScript and TypeScript files, which are assumed to be run Prettier through ESLint. You can customize the files that will be checked with prettier by passing an explicit glob pattern to this command: |
| 83 | + |
| 84 | +```sh |
| 85 | +# Run `prettier` on GraphQL files in the app directory. |
| 86 | +pnpm exec quilt run prettier "./app/**/*.graphql" |
| 87 | +``` |
0 commit comments