From 0009cf220690f33f1059b41578b96602c5a2f18a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Wed, 17 Jan 2024 11:52:54 -0500 Subject: [PATCH] feat: add `.node-version` and `.nvmrc` support (#341) Co-authored-by: JounQin --- .changeset/gorgeous-ladybugs-push.md | 5 +++++ packages/sh/test/__snapshots__/fixtures.spec.ts.snap | 10 ++++++++++ packages/sh/test/fixtures/.nvmrc | 1 + scripts/languages.ts | 7 +++++++ 4 files changed, 23 insertions(+) create mode 100644 .changeset/gorgeous-ladybugs-push.md create mode 100644 packages/sh/test/fixtures/.nvmrc diff --git a/.changeset/gorgeous-ladybugs-push.md b/.changeset/gorgeous-ladybugs-push.md new file mode 100644 index 00000000..6d1c3428 --- /dev/null +++ b/.changeset/gorgeous-ladybugs-push.md @@ -0,0 +1,5 @@ +--- +"prettier-plugin-sh": minor +--- + +feat: add `.node-version` and `.nvmrc` support diff --git a/packages/sh/test/__snapshots__/fixtures.spec.ts.snap b/packages/sh/test/__snapshots__/fixtures.spec.ts.snap index 1cebbed5..354ba9eb 100644 --- a/packages/sh/test/__snapshots__/fixtures.spec.ts.snap +++ b/packages/sh/test/__snapshots__/fixtures.spec.ts.snap @@ -22,6 +22,16 @@ node_modules " `; +exports[`parser and printer > should format all fixtures > .nvmrc 1`] = ` +"v1.2.3 +" +`; + +exports[`parser and printer > should format all fixtures > .nvmrc 2`] = ` +"v1.2.3 +" +`; + exports[`parser and printer > should format all fixtures > .properties 1`] = ` "# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. # yarn lockfile v1 diff --git a/packages/sh/test/fixtures/.nvmrc b/packages/sh/test/fixtures/.nvmrc new file mode 100644 index 00000000..a064add5 --- /dev/null +++ b/packages/sh/test/fixtures/.nvmrc @@ -0,0 +1 @@ +v1.2.3 \ No newline at end of file diff --git a/scripts/languages.ts b/scripts/languages.ts index 1911d69d..7155c80e 100644 --- a/scripts/languages.ts +++ b/scripts/languages.ts @@ -27,6 +27,13 @@ const EXTRA_SH_LANGUAGES: SupportLanguage[] = [ filenames: ['.env.*'], vscodeLanguageIds: ['dotenv'], }, + { + name: 'nvmrc', + since: '0.14.0', + parsers: ['sh'], + extensions: ['.node-version', '.nvmrc'], + filenames: ['.node-version', '.nvmrc'], + }, ] const getSupportLanguages = (