From 885acd9a66639a550cb76863f43eceb77fb6e368 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 6 Jun 2024 07:21:19 -0400 Subject: [PATCH 1/4] feat: add prettier-plugin-sh --- .nvmrc | 2 ++ .prettierrc.json | 6 +++++- docs/Tooling.md | 2 +- package.json | 1 + pnpm-lock.yaml | 28 +++++++++++++++++++++++++ src/steps/finalizeDependencies.test.ts | 6 +++--- src/steps/finalizeDependencies.ts | 1 + src/steps/writing/creation/rootFiles.ts | 6 +++++- 8 files changed, 46 insertions(+), 6 deletions(-) diff --git a/.nvmrc b/.nvmrc index 87834047a..b0a2608c8 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1,3 @@ 20.12.2 + +gotcha. diff --git a/.prettierrc.json b/.prettierrc.json index e3efe60fd..5b0fab8c5 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,6 +1,10 @@ { "$schema": "http://json.schemastore.org/prettierrc", "overrides": [{ "files": ".nvmrc", "options": { "parser": "yaml" } }], - "plugins": ["prettier-plugin-curly", "prettier-plugin-packagejson"], + "plugins": [ + "prettier-plugin-curly", + "prettier-plugin-sh", + "prettier-plugin-packagejson" + ], "useTabs": true } diff --git a/docs/Tooling.md b/docs/Tooling.md index 3b8ddc2d8..bb8cb7fd2 100644 --- a/docs/Tooling.md +++ b/docs/Tooling.md @@ -83,7 +83,7 @@ pnpm run build --watch [**Prettier**](https://prettier.io): Formats code for developers and enforces a consistent formatting style. It's run on file save per [VS Code](https://code.visualstudio.com/docs/getstarted/settings) settings and as a Git commit hook via [husky](https://typicode.github.io/husky) and [lint-staged](https://github.com/okonet/lint-staged). -[prettier-plugin-curly](https://github.com/JoshuaKGoldberg/prettier-plugin-curly) and [prettier-plugin-packagejson](https://github.com/matzkoh/prettier-plugin-packagejson) add in more formatting as well. +[prettier-plugin-curly](https://github.com/JoshuaKGoldberg/prettier-plugin-curly), [prettier-plugin-sh](https://github.com/un-ts/prettier/tree/master/packages/sh), and [prettier-plugin-packagejson](https://github.com/matzkoh/prettier-plugin-packagejson) add in more formatting as well. Auto-formatting all files: diff --git a/package.json b/package.json index 390628b6f..00ff57497 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,7 @@ "markdownlint-cli": "^0.41.0", "prettier-plugin-curly": "^0.2.0", "prettier-plugin-packagejson": "^2.5.0", + "prettier-plugin-sh": "^0.14.0", "release-it": "^17.3.0", "sentences-per-line": "^0.2.1", "tsup": "^8.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index daa6f4cb2..1de755ac0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -159,6 +159,9 @@ importers: prettier-plugin-packagejson: specifier: ^2.5.0 version: 2.5.0(prettier@3.1.0) + prettier-plugin-sh: + specifier: ^0.14.0 + version: 0.14.0(prettier@3.1.0) release-it: specifier: ^17.3.0 version: 17.3.0(typescript@5.4.3) @@ -3418,6 +3421,9 @@ packages: resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + mvdan-sh@0.10.1: + resolution: {integrity: sha512-kMbrH0EObaKmK3nVRKUIIya1dpASHIEusM13S4V1ViHFuxuNxCo+arxoa6j/dbV22YBGjl7UKJm9QQKJ2Crzhg==} + mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} @@ -3735,6 +3741,12 @@ packages: prettier: optional: true + prettier-plugin-sh@0.14.0: + resolution: {integrity: sha512-hfXulj5+zEl/ulrO5kMuuTPKmXvOg0bnLHY1hKFNN/N+/903iZbNp8NyZBTsgI8dtkSgFfAEIQq0IQTyP1ZVFQ==} + engines: {node: '>=16.0.0'} + peerDependencies: + prettier: ^3.0.3 + prettier@3.1.0: resolution: {integrity: sha512-TQLvXjq5IAibjh8EpBIkNKxO749UEWABoiIZehEPiY4GNpVdhaFKqSTu+QrlU6D2dPAfubRmtJTi4K4YkQ5eXw==} engines: {node: '>=14'} @@ -3964,6 +3976,10 @@ packages: resolution: {integrity: sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==} engines: {node: '>= 0.4'} + sh-syntax@0.4.2: + resolution: {integrity: sha512-/l2UZ5fhGZLVZa16XQM9/Vq/hezGGbdHeVEA01uWjOL1+7Ek/gt6FquW0iKKws4a9AYPYvlz6RyVvjh3JxOteg==} + engines: {node: '>=16.0.0'} + shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -8077,6 +8093,8 @@ snapshots: mute-stream@1.0.0: {} + mvdan-sh@0.10.1: {} + mz@2.7.0: dependencies: any-promise: 1.3.0 @@ -8429,6 +8447,12 @@ snapshots: optionalDependencies: prettier: 3.1.0 + prettier-plugin-sh@0.14.0(prettier@3.1.0): + dependencies: + mvdan-sh: 0.10.1 + prettier: 3.1.0 + sh-syntax: 0.4.2 + prettier@3.1.0: {} pretty-format@29.7.0: @@ -8715,6 +8739,10 @@ snapshots: functions-have-names: 1.2.3 has-property-descriptors: 1.0.2 + sh-syntax@0.4.2: + dependencies: + tslib: 2.6.2 + shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 diff --git a/src/steps/finalizeDependencies.test.ts b/src/steps/finalizeDependencies.test.ts index 95e48791c..05d2ed597 100644 --- a/src/steps/finalizeDependencies.test.ts +++ b/src/steps/finalizeDependencies.test.ts @@ -38,7 +38,7 @@ describe("finalize", () => { expect(mockExecaCommand.mock.calls).toMatchInlineSnapshot(` [ [ - "pnpm add @eslint-community/eslint-plugin-eslint-comments@latest @eslint/js@latest @release-it/conventional-changelog@latest @types/eslint-plugin-markdown@latest @vitest/coverage-v8@latest all-contributors-cli@latest console-fail-test@latest cspell@latest eslint@latest eslint-plugin-jsdoc@latest eslint-plugin-jsonc@latest eslint-plugin-markdown@latest eslint-plugin-n@latest eslint-plugin-package-json@latest eslint-plugin-perfectionist@latest eslint-plugin-regexp@latest eslint-plugin-vitest@latest eslint-plugin-yml@latest husky@latest jsonc-eslint-parser@latest knip@latest lint-staged@latest markdownlint@latest markdownlint-cli@latest prettier@latest prettier-plugin-curly@latest prettier-plugin-packagejson@latest release-it@latest sentences-per-line@latest tsup@latest typescript@latest typescript-eslint@latest vitest@latest -D", + "pnpm add @eslint-community/eslint-plugin-eslint-comments@latest @eslint/js@latest @release-it/conventional-changelog@latest @types/eslint-plugin-markdown@latest @vitest/coverage-v8@latest all-contributors-cli@latest console-fail-test@latest cspell@latest eslint@latest eslint-plugin-jsdoc@latest eslint-plugin-jsonc@latest eslint-plugin-markdown@latest eslint-plugin-n@latest eslint-plugin-package-json@latest eslint-plugin-perfectionist@latest eslint-plugin-regexp@latest eslint-plugin-vitest@latest eslint-plugin-yml@latest husky@latest jsonc-eslint-parser@latest knip@latest lint-staged@latest markdownlint@latest markdownlint-cli@latest prettier@latest prettier-plugin-curly@latest prettier-plugin-packagejson@latest prettier-plugin-sh@latest release-it@latest sentences-per-line@latest tsup@latest typescript@latest typescript-eslint@latest vitest@latest -D", ], [ "npx all-contributors-cli generate", @@ -59,7 +59,7 @@ describe("finalize", () => { expect(mockExecaCommand.mock.calls).toMatchInlineSnapshot(` [ [ - "pnpm add @eslint-community/eslint-plugin-eslint-comments@latest @eslint/js@latest @release-it/conventional-changelog@latest @types/eslint-plugin-markdown@latest @vitest/coverage-v8@latest all-contributors-cli@latest console-fail-test@latest cspell@latest eslint@latest eslint-plugin-jsdoc@latest eslint-plugin-jsonc@latest eslint-plugin-markdown@latest eslint-plugin-n@latest eslint-plugin-package-json@latest eslint-plugin-perfectionist@latest eslint-plugin-regexp@latest eslint-plugin-vitest@latest eslint-plugin-yml@latest husky@latest jsonc-eslint-parser@latest knip@latest lint-staged@latest markdownlint@latest markdownlint-cli@latest prettier@latest prettier-plugin-curly@latest prettier-plugin-packagejson@latest release-it@latest sentences-per-line@latest tsup@latest typescript@latest typescript-eslint@latest vitest@latest -D --offline", + "pnpm add @eslint-community/eslint-plugin-eslint-comments@latest @eslint/js@latest @release-it/conventional-changelog@latest @types/eslint-plugin-markdown@latest @vitest/coverage-v8@latest all-contributors-cli@latest console-fail-test@latest cspell@latest eslint@latest eslint-plugin-jsdoc@latest eslint-plugin-jsonc@latest eslint-plugin-markdown@latest eslint-plugin-n@latest eslint-plugin-package-json@latest eslint-plugin-perfectionist@latest eslint-plugin-regexp@latest eslint-plugin-vitest@latest eslint-plugin-yml@latest husky@latest jsonc-eslint-parser@latest knip@latest lint-staged@latest markdownlint@latest markdownlint-cli@latest prettier@latest prettier-plugin-curly@latest prettier-plugin-packagejson@latest prettier-plugin-sh@latest release-it@latest sentences-per-line@latest tsup@latest typescript@latest typescript-eslint@latest vitest@latest -D --offline", ], [ "npx all-contributors-cli generate", @@ -92,7 +92,7 @@ describe("finalize", () => { expect(mockExecaCommand.mock.calls).toMatchInlineSnapshot(` [ [ - "pnpm add @eslint-community/eslint-plugin-eslint-comments@latest @eslint/js@latest @types/eslint-plugin-markdown@latest eslint@latest eslint-plugin-jsdoc@latest eslint-plugin-n@latest eslint-plugin-regexp@latest husky@latest lint-staged@latest prettier@latest prettier-plugin-curly@latest prettier-plugin-packagejson@latest tsup@latest typescript@latest typescript-eslint@latest -D", + "pnpm add @eslint-community/eslint-plugin-eslint-comments@latest @eslint/js@latest @types/eslint-plugin-markdown@latest eslint@latest eslint-plugin-jsdoc@latest eslint-plugin-n@latest eslint-plugin-regexp@latest husky@latest lint-staged@latest prettier@latest prettier-plugin-curly@latest prettier-plugin-packagejson@latest prettier-plugin-sh@latest tsup@latest typescript@latest typescript-eslint@latest -D", ], [ "pnpm dedupe", diff --git a/src/steps/finalizeDependencies.ts b/src/steps/finalizeDependencies.ts index 3dbd69693..42b4f0c0d 100644 --- a/src/steps/finalizeDependencies.ts +++ b/src/steps/finalizeDependencies.ts @@ -16,6 +16,7 @@ export async function finalizeDependencies(options: Options) { "lint-staged", "prettier", "prettier-plugin-curly", + "prettier-plugin-sh", "prettier-plugin-packagejson", "tsup", "typescript", diff --git a/src/steps/writing/creation/rootFiles.ts b/src/steps/writing/creation/rootFiles.ts index a34186199..ec13a60c7 100644 --- a/src/steps/writing/creation/rootFiles.ts +++ b/src/steps/writing/creation/rootFiles.ts @@ -40,7 +40,11 @@ export async function createRootFiles(options: Options) { options: { parser: "yaml" }, }, ], - plugins: ["prettier-plugin-curly", "prettier-plugin-packagejson"], + plugins: [ + "prettier-plugin-curly", + "prettier-plugin-sh", + "prettier-plugin-packagejson", + ], useTabs: true, }), ...(!options.excludeReleases && { From aa9aa93a0f775889d4b4f3ffa4a9bd301295fedb Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 6 Jun 2024 07:27:01 -0400 Subject: [PATCH 2/4] Also .prettierignore --- .github/DEVELOPMENT.md | 2 +- .prettierignore | 1 + src/steps/writing/creation/rootFiles.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/DEVELOPMENT.md b/.github/DEVELOPMENT.md index 3fa32a0ce..30091f435 100644 --- a/.github/DEVELOPMENT.md +++ b/.github/DEVELOPMENT.md @@ -6,7 +6,7 @@ After [forking the repo from GitHub](https://help.github.com/articles/fork-a-repo) and [installing pnpm](https://pnpm.io/installation): ```shell -git clone https://github.com//create-typescript-app +git clone https://github.com/ < your-name-here > /create-typescript-app cd create-typescript-app pnpm install ``` diff --git a/.prettierignore b/.prettierignore index 613eedd4d..608dd8d91 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,5 @@ .all-contributorsrc +.husky/ coverage*/ lib/ pnpm-lock.yaml diff --git a/src/steps/writing/creation/rootFiles.ts b/src/steps/writing/creation/rootFiles.ts index ec13a60c7..36ab96972 100644 --- a/src/steps/writing/creation/rootFiles.ts +++ b/src/steps/writing/creation/rootFiles.ts @@ -28,6 +28,7 @@ export async function createRootFiles(options: Options) { ".nvmrc": `20.12.2\n`, ".prettierignore": formatIgnoreFile([ ...(options.excludeAllContributors ? [] : [".all-contributorsrc"]), + ".husky/", ...(options.excludeTests ? [] : ["coverage/"]), "lib/", "pnpm-lock.yaml", From 74ff790b6579c10de033a50792fe8c90fb9d3d4e Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 6 Jun 2024 07:27:22 -0400 Subject: [PATCH 3/4] Remove gotcha --- .nvmrc | 2 -- 1 file changed, 2 deletions(-) diff --git a/.nvmrc b/.nvmrc index b0a2608c8..87834047a 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1,3 +1 @@ 20.12.2 - -gotcha. From 4ae56937c43e20e64bc001b2969e1f29e7870111 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 6 Jun 2024 07:31:23 -0400 Subject: [PATCH 4/4] Update migration snapshot --- script/__snapshots__/migrate-test-e2e.ts.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/script/__snapshots__/migrate-test-e2e.ts.snap b/script/__snapshots__/migrate-test-e2e.ts.snap index cef671e3a..37f5a1c4d 100644 --- a/script/__snapshots__/migrate-test-e2e.ts.snap +++ b/script/__snapshots__/migrate-test-e2e.ts.snap @@ -29,6 +29,7 @@ exports[`expected file changes > .prettierignore 1`] = ` +++ b/.prettierignore @@ ... @@ .all-contributorsrc + .husky/ -coverage*/ +coverage/ lib/