Skip to content

Commit a607eef

Browse files
authored
feat(prettier-plugin-sh): better support for dotenv and husky files out of box (#479)
1 parent b32eea4 commit a607eef

File tree

13 files changed

+1283
-894
lines changed

13 files changed

+1283
-894
lines changed

.changeset/large-bananas-tease.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"prettier-plugin-sh": minor
3+
---
4+
5+
feat: better support for `dotenv` and `husky` files out of box

.github/workflows/autofix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ jobs:
3131
run: yarn run-s build format
3232

3333
- name: Apply autofix.ci
34-
uses: autofix-ci/action@2891949f3779a1cafafae1523058501de3d4e944 # v1
34+
uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # v1.3.2
3535
with:
3636
fail-fast: false

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
strategy:
1515
matrix:
1616
node:
17-
- 18
1817
- 20
1918
- 22
2019
- 24

package.json

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,31 @@
3333
},
3434
"devDependencies": {
3535
"@1stg/browserslist-config": "^2.1.4",
36-
"@1stg/common-config": "^14.0.0",
36+
"@1stg/common-config": "^14.2.0",
3737
"@1stg/postcss-config": "^6.1.0",
3838
"@changesets/changelog-github": "^0.5.1",
39-
"@changesets/cli": "^2.29.4",
39+
"@changesets/cli": "^2.29.5",
4040
"@commitlint/cli": "^19.8.1",
4141
"@mdx-js/rollup": "^3.1.0",
4242
"@pkgr/rollup": "^7.0.0",
43-
"@shikijs/rehype": "^3.5.0",
44-
"@stylistic/eslint-plugin": "^4.4.1",
45-
"@types/node": "^22.15.29",
46-
"@types/react": "^19.1.6",
43+
"@shikijs/rehype": "^3.7.0",
44+
"@stylistic/eslint-plugin": "^5.0.0",
45+
"@types/node": "^22.15.33",
46+
"@types/react": "^19.1.8",
4747
"@types/react-dom": "^19.1.6",
48-
"@types/web": "^0.0.239",
49-
"@vitejs/plugin-react-swc": "^3.10.1",
50-
"@vitest/coverage-istanbul": "^3.2.1",
51-
"@vitest/eslint-plugin": "^1.2.1",
48+
"@types/serialize-javascript": "^5.0.4",
49+
"@types/web": "^0.0.243",
50+
"@vitejs/plugin-react-swc": "^3.10.2",
51+
"@vitest/coverage-istanbul": "^3.2.4",
52+
"@vitest/eslint-plugin": "^1.2.7",
5253
"clean-pkg-json": "^1.3.0",
53-
"eslint": "^9.28.0",
54+
"eslint": "^9.29.0",
5455
"eslint-plugin-tsdoc": "^0.4.0",
5556
"github-markdown-css": "^5.8.1",
5657
"linguist-languages": "^8.0.0",
5758
"nano-staged": "^0.8.0",
5859
"npm-run-all2": "^8.0.4",
59-
"prettier": "^3.5.3",
60+
"prettier": "^3.6.1",
6061
"prettier-plugin-autocorrect": "workspace:*",
6162
"prettier-plugin-pkg": "workspace:*",
6263
"prettier-plugin-sh": "workspace:*",
@@ -68,24 +69,26 @@
6869
"rehype-slug": "^6.0.0",
6970
"remark-gfm": "^4.0.1",
7071
"rimraf": "^6.0.1",
72+
"serialize-javascript": "^6.0.2",
7173
"simple-git-hooks": "^2.13.0",
7274
"sirv-cli": "^3.0.1",
7375
"size-limit": "^11.2.0",
7476
"size-limit-preset-node-lib": "^0.4.0",
75-
"tsx": "^4.19.4",
77+
"tsx": "^4.20.3",
7678
"type-coverage": "^2.29.7",
7779
"typescript": "^5.8.3",
78-
"vite": "^6.3.5",
79-
"vitest": "^3.2.1",
80+
"vite": "^7.0.0",
81+
"vitest": "^3.2.4",
8082
"yarn-berry-deduplicate": "^6.1.3"
8183
},
8284
"resolutions": {
83-
"prettier": "^3.5.3",
85+
"prettier": "^3.6.1",
8486
"prettier-plugin-autocorrect": "workspace:*",
8587
"prettier-plugin-pkg": "workspace:*",
8688
"prettier-plugin-sh": "workspace:*",
8789
"prettier-plugin-sql": "workspace:*",
88-
"prettier-plugin-toml": "workspace:*"
90+
"prettier-plugin-toml": "workspace:*",
91+
"vite": "npm:rolldown-vite@^7.0.1"
8992
},
9093
"browserslist": [
9194
"extends @1stg/browserslist-config/modern"

packages/sh/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"prepack": "clean-pkg-json"
4444
},
4545
"peerDependencies": {
46-
"prettier": "^3.0.3"
46+
"prettier": "^3.6.0"
4747
},
4848
"dependencies": {
4949
"@reteps/dockerfmt": "^0.3.6",

packages/sh/test/__snapshots__/fixtures.spec.ts.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ node_modules
1111
"
1212
`;
1313

14+
exports[`parser and printer > should format .env.development fixture correctly 1`] = `
15+
"VITE_API_BASE_URL= /api
16+
"
17+
`;
18+
19+
exports[`parser and printer > should format .husky/precommit fixture correctly 1`] = `
20+
"yarn \\
21+
lint
22+
"
23+
`;
24+
1425
exports[`parser and printer > should format .nvmrc fixture correctly 1`] = `
1526
"v1.2.3
1627
"

packages/sh/test/fixtures.spec.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,25 @@ const PARSER_OPTIONS: Partial<
1616
describe('parser and printer', () => {
1717
const fixtures = path.resolve(import.meta.dirname, 'fixtures')
1818

19-
for (const relativeFilepath of fs.readdirSync(fixtures)) {
20-
const filepath = path.resolve(fixtures, relativeFilepath)
19+
for (const dirent of fs.readdirSync(fixtures, {
20+
recursive: true,
21+
withFileTypes: true,
22+
})) {
23+
if (dirent.isDirectory()) {
24+
continue
25+
}
26+
27+
const filepath = path.resolve(dirent.parentPath, dirent.name)
28+
29+
const relativeFilepath = path
30+
.relative(fixtures, filepath)
31+
.replaceAll(path.win32.sep, path.posix.sep)
32+
2133
const input = fs.readFileSync(filepath, 'utf8')
2234

23-
const caseName = relativeFilepath.slice(
24-
0,
25-
relativeFilepath.lastIndexOf('.'),
26-
)
35+
const caseName = dirent.name.includes('.')
36+
? relativeFilepath.slice(0, relativeFilepath.lastIndexOf('.'))
37+
: relativeFilepath
2738

2839
const overrideOptions = PARSER_OPTIONS[caseName]
2940

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_BASE_URL= /api
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
yarn \
2+
lint

packages/sql/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
},
5252
"dependencies": {
5353
"jsox": "^1.2.123",
54-
"node-sql-parser": "^5.3.9",
55-
"sql-formatter": "^15.6.2",
54+
"node-sql-parser": "^5.3.10",
55+
"sql-formatter": "^15.6.5",
5656
"tslib": "^2.8.1"
5757
},
5858
"publishConfig": {

0 commit comments

Comments
 (0)