Skip to content

Commit fb797dc

Browse files
chore: Update prettier configs README
1 parent 8bb895d commit fb797dc

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

.changeset/eighty-jeans-train.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@tcd-devkit/prettier-config-react': minor
3+
'@tcd-devkit/prettier-config': minor
4+
---
5+
6+
Update README with better info

packages/prettier/prettier-config-react/README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,30 @@ Alternatively, you can create a Prettier configuration file (e.g., `.prettierrc.
4343

4444
**`.prettierrc.js` (or `prettier.config.js`)**
4545

46-
This package exports both CommonJS (CJS) and ES Module (ESM) formats. You can import it accordingly:
46+
This package exports both CommonJS (CJS) and ES Module (ESM) formats. Choose the appropriate example based on your project's module system:
47+
48+
> **Note**: You can also use `prettier.config.cjs` to force CommonJS format even in projects with `"type": "module"` in package.json.
49+
50+
For CommonJS (`.js` files without `"type": "module"` in package.json):
4751

4852
```javascript
49-
// For CommonJS (e.g., if your prettier.config.js is a .js file treated as CJS)
50-
// const prettierConfigReact = require('@tcd-devkit/prettier-config-react');
53+
const prettierConfigReact = require('@tcd-devkit/prettier-config-react');
54+
55+
module.exports = {
56+
...prettierConfigReact,
57+
// Your custom overrides can be added here
58+
// For example, if you have custom Tailwind settings:
59+
// tailwindConfig: './tailwind.config.js',
60+
};
61+
```
5162

52-
// For ES Modules (e.g., if your prettier.config.js is a .mjs file or package.json has "type": "module")
53-
// import prettierConfigReact from '@tcd-devkit/prettier-config-react';
63+
For ES Modules (`.mjs` files or `.js` files with `"type": "module"` in package.json):
64+
65+
```javascript
66+
import prettierConfigReact from '@tcd-devkit/prettier-config-react';
5467

55-
// Then spread the imported config:
5668
export default {
57-
// ...prettierConfigReact, // Choose one of the import methods above
58-
...require('@tcd-devkit/prettier-config-react'), // Defaulting to require for wider compatibility in basic .js files
69+
...prettierConfigReact,
5970
// Your custom overrides can be added here
6071
// For example, if you have custom Tailwind settings:
6172
// tailwindConfig: './tailwind.config.js',

packages/prettier/prettier-config/README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,32 @@ Alternatively, you can create a Prettier configuration file (e.g., `.prettierrc.
4747

4848
**`.prettierrc.js` (or `prettier.config.js`)**
4949

50-
This package exports both CommonJS (CJS) and ES Module (ESM) formats. You can import it accordingly:
50+
This package exports both CommonJS (CJS) and ES Module (ESM) formats. Choose the appropriate example based on your project's module system:
51+
52+
> **Note**: You can also use `prettier.config.cjs` to force CommonJS format even in projects with `"type": "module"` in package.json.
53+
54+
For CommonJS (`.js` files without `"type": "module"` in package.json):
5155

5256
```javascript
53-
// For CommonJS (e.g., if your prettier.config.js is a .js file treated as CJS)
54-
// const prettierConfig = require('@tcd-devkit/prettier-config');
57+
const prettierConfig = require('@tcd-devkit/prettier-config');
5558

56-
// For ES Modules (e.g., if your prettier.config.js is a .mjs file or package.json has "type": "module")
57-
// import prettierConfig from '@tcd-devkit/prettier-config';
59+
module.exports = {
60+
...prettierConfig,
61+
// Your custom overrides can be added here
62+
// For example:
63+
// printWidth: 100,
64+
};
65+
```
66+
67+
For ES Modules (`.mjs` files or `.js` files with `"type": "module"` in package.json):
68+
69+
```javascript
70+
import prettierConfig from '@tcd-devkit/prettier-config';
5871

59-
// Then spread the imported config:
6072
export default {
61-
// ...prettierConfig, // Choose one of the import methods above
62-
...require('@tcd-devkit/prettier-config'), // Defaulting to require for wider compatibility in basic .js files
73+
...prettierConfig,
6374
// Your custom overrides can be added here
64-
// مثلا:
75+
// For example:
6576
// printWidth: 100,
6677
};
6778
```

0 commit comments

Comments
 (0)