Skip to content

Commit c8dbd5c

Browse files
committed
Migrate to Prettier 3 with JavaScript module format
- Replace JSON config with JavaScript module for Prettier 3 compatibility - Update GitHub Actions workflow to latest versions and Node.js LTS - Add comprehensive documentation and usage examples - Include additional package metadata and improve changelog formatting
1 parent c0ee21e commit c8dbd5c

File tree

5 files changed

+85
-17
lines changed

5 files changed

+85
-17
lines changed

.github/workflows/npm-publish.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ jobs:
1212
contents: write
1313
id-token: write
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: Get package version
1717
id: package-version
1818
uses: martinbeentjes/[email protected]
1919
- name: Setup node environment
20-
uses: actions/setup-node@v3
20+
uses: actions/setup-node@v4
2121
with:
22-
node-version: '18.x'
22+
node-version: 'lts/*' # Always use latest LTS version
2323
registry-url: https://registry.npmjs.org
24-
- run: npm ci
24+
cache: 'npm'
25+
- name: Install dependencies
26+
run: npm ci
2527
- name: Publish to NPM
2628
run: npm publish --provenance --access public
2729
env:
@@ -37,7 +39,7 @@ jobs:
3739
echo "::endgroup::"
3840
- name: Create Release Tag
3941
id: create-release
40-
uses: softprops/action-gh-release@v1
42+
uses: softprops/action-gh-release@v2
4143
with:
4244
tag_name: ${{ steps.package-version.outputs.current-version }}
4345
body: ${{ env.RELEASE_NOTES }}

CHANGELOG.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
1-
# Changelog
1+
# 📋 Changelog
22

33
All notable changes to this project will be documented in this file.
44

5+
## [2.0.0] - 2025-01-24
6+
7+
### 💥 Breaking Changes
8+
9+
- 🔄 Migrated from JSON to JavaScript module format for Prettier 3 compatibility
10+
- 📝 Changed main entry point from `main.json` to `index.js`
11+
- ⬆️ Now requires Prettier 3.0.0 or higher
12+
13+
### ✨ Added
14+
15+
- 📦 JavaScript module export for better extensibility
16+
- 📋 Additional package.json metadata (files, engines, keywords)
17+
- 📚 Improved documentation for Prettier 3 usage
18+
- 🔧 Updated GitHub Actions workflow to latest versions with Node.js LTS
19+
20+
### 🔄 Changed
21+
22+
- 🏗️ Configuration now uses CommonJS module.exports instead of JSON format
23+
- 📝 Updated README with Prettier 3 specific instructions
24+
525
## [1.0.1] - 2023-08-16
626

7-
### Added
27+
### Added
828

9-
- Default Prettier configuration
10-
- Actions release workflow
11-
- Install documentation
12-
- Changes changelog
29+
- 🎨 Default Prettier configuration
30+
- 🚀 Actions release workflow
31+
- 📖 Install documentation
32+
- 📋 Changes changelog

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
The official HypeTech prettier configuration, part of Frontend Coding Standards.
44

5+
> **Note**: Version 2.0.0+ requires Prettier 3.0.0 or higher. For Prettier 2.x, use version 1.x of this package.
6+
57
## Installation
68

79
The configuration can be installed via package manager.
@@ -25,6 +27,10 @@ With NPM:
2527
npm install --dev @hypetech/prettier-config
2628
```
2729

30+
## Usage
31+
32+
### Method 1: package.json (Recommended for simple usage)
33+
2834
To inform prettier of this configuration, you have to add the `prettier` property to your `package.json` file:
2935

3036
```json
@@ -37,19 +43,38 @@ Instead of manually editing your `package.json`, you can also utilize the `npm p
3743
npm pkg set prettier=@hypetech/prettier-config
3844
```
3945

40-
## Extending
46+
### Method 2: .prettierrc.js (Required for extending)
47+
48+
For Prettier 3, create a `.prettierrc.js` file:
49+
50+
```js
51+
module.exports = require('@hypetech/prettier-config');
52+
```
4153

42-
[Prettier does not ship with a built-in way of extending configurations](https://prettier.io/docs/en/configuration.html#sharing-configurations).
54+
## Extending
4355

44-
To extend the configuration, you will have to create a `.prettierrc.js` file (or `.prettierrc.cjs` if your package is a `"type": "module"`) and import the HypeTech configuration using `require`:
56+
To extend the configuration, you will have to create a `.prettierrc.js` file (or `.prettierrc.cjs` if your package is a `"type": "module"`) and import the HypeTech configuration:
4557

4658
```js
4759
module.exports = {
4860
...require('@hypetech/prettier-config'),
61+
// Your custom overrides
4962
semi: true,
5063
}
5164
```
5265

66+
## Configuration Details
67+
68+
This configuration includes the following settings:
69+
70+
- **semi**: `false` - No semicolons at the end of statements
71+
- **singleQuote**: `false` - Use double quotes
72+
- **printWidth**: `120` - Line wrap at 120 characters
73+
- **tabWidth**: `4` - Use 4 spaces for indentation
74+
- **quoteProps**: `"preserve"` - Only add quotes around object properties where necessary
75+
- **endOfLine**: `"auto"` - Maintain existing line endings
76+
- **trailingComma**: `"es5"` - Trailing commas where valid in ES5 (objects, arrays, etc.)
77+
5378
If you have previously added the configuration to your `package.json`, via the `prettier` property, you can now remove it.
5479
You can also utilize the `npm pkg`:
5580

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
semi: false,
3+
singleQuote: false,
4+
printWidth: 120,
5+
tabWidth: 4,
6+
quoteProps: "preserve",
7+
endOfLine: "auto",
8+
trailingComma: "es5",
9+
};

package.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
{
22
"name": "@hypetech/prettier-config",
3-
"version": "1.0.1",
3+
"version": "2.0.0",
44
"description": "HypeTech Prettier Configuration",
55
"keywords": [
66
"HypeTech",
7-
"prettier"
7+
"prettier",
8+
"prettier-config",
9+
"code-style",
10+
"formatting"
811
],
12+
"files": [
13+
"index.js",
14+
"README.md",
15+
"CHANGELOG.md",
16+
"LICENSE"
17+
],
18+
"engines": {
19+
"node": ">=14.0.0"
20+
},
921
"homepage": "https://github.com/hypetechdev/prettier-config#readme",
1022
"bugs": {
1123
"url": "https://github.com/hypetechdev/prettier-config/issues"
@@ -16,7 +28,7 @@
1628
},
1729
"license": "MIT",
1830
"author": "HypeTech",
19-
"main": "main.json",
31+
"main": "index.js",
2032
"peerDependencies": {
2133
"prettier": ">=3"
2234
}

0 commit comments

Comments
 (0)