Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/eighty-jeans-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@tcd-devkit/prettier-config-react': minor
'@tcd-devkit/prettier-config': minor
---

Update README with better info
5 changes: 5 additions & 0 deletions .changeset/polite-teeth-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tcd-devkit/prettier-config': patch
---

Add more alternative for import order path aliases and add styles aliases
27 changes: 19 additions & 8 deletions packages/prettier/prettier-config-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,30 @@ Alternatively, you can create a Prettier configuration file (e.g., `.prettierrc.

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

This package exports both CommonJS (CJS) and ES Module (ESM) formats. You can import it accordingly:
This package exports both CommonJS (CJS) and ES Module (ESM) formats. Choose the appropriate example based on your project's module system:

> **Note**: You can also use `prettier.config.cjs` to force CommonJS format even in projects with `"type": "module"` in package.json.

For CommonJS (`.js` files without `"type": "module"` in package.json):

```javascript
// For CommonJS (e.g., if your prettier.config.js is a .js file treated as CJS)
// const prettierConfigReact = require('@tcd-devkit/prettier-config-react');
const prettierConfigReact = require('@tcd-devkit/prettier-config-react');

module.exports = {
...prettierConfigReact,
// Your custom overrides can be added here
// For example, if you have custom Tailwind settings:
// tailwindConfig: './tailwind.config.js',
};
```

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

```javascript
import prettierConfigReact from '@tcd-devkit/prettier-config-react';

// Then spread the imported config:
export default {
// ...prettierConfigReact, // Choose one of the import methods above
...require('@tcd-devkit/prettier-config-react'), // Defaulting to require for wider compatibility in basic .js files
...prettierConfigReact,
// Your custom overrides can be added here
// For example, if you have custom Tailwind settings:
// tailwindConfig: './tailwind.config.js',
Expand Down
29 changes: 20 additions & 9 deletions packages/prettier/prettier-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,32 @@ Alternatively, you can create a Prettier configuration file (e.g., `.prettierrc.

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

This package exports both CommonJS (CJS) and ES Module (ESM) formats. You can import it accordingly:
This package exports both CommonJS (CJS) and ES Module (ESM) formats. Choose the appropriate example based on your project's module system:

> **Note**: You can also use `prettier.config.cjs` to force CommonJS format even in projects with `"type": "module"` in package.json.

For CommonJS (`.js` files without `"type": "module"` in package.json):

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

// For ES Modules (e.g., if your prettier.config.js is a .mjs file or package.json has "type": "module")
// import prettierConfig from '@tcd-devkit/prettier-config';
module.exports = {
...prettierConfig,
// Your custom overrides can be added here
// For example:
// printWidth: 100,
};
```

For ES Modules (`.mjs` files or `.js` files with `"type": "module"` in package.json):

```javascript
import prettierConfig from '@tcd-devkit/prettier-config';

// Then spread the imported config:
export default {
// ...prettierConfig, // Choose one of the import methods above
...require('@tcd-devkit/prettier-config'), // Defaulting to require for wider compatibility in basic .js files
...prettierConfig,
// Your custom overrides can be added here
// مثلا:
// For example:
// printWidth: 100,
};
```
Expand Down
14 changes: 8 additions & 6 deletions packages/prettier/prettier-config/src/base.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,21 @@ const baseFormatter = {
'',
'^(@tcd-devkit)(/.*)$',
'',
'^(@/shared|#shared)(/.*)$',
'^(@shared|@/shared|#shared)(/.*)$',
'',
'^(@/server|#server)(/.*)$',
'^(@/actions|#actions)(/.*)$',
'^(@server|@/server|#server)(/.*)$',
'^(@actions|@/actions|#actions)(/.*)$',
'',
'^(@/client|#client)(/.*)$',
'^(@client|@/client|#client)(/.*)$',
'',
'^(@/components|#components)(/.*)$',
'^(@components|@/components|#components)(/.*)$',
'',
'^(@/public|#public)(/.*)$',
'^(@public|@/public|#public)(/.*)$',
'',
'^#([^/].*)$',
'',
'^(@global-styles?|@/global-styles?|#global-styles?)(/.*)$',
'^(@styles?|@/styles?|#styles?)(/.*)$',
'(?:\\.s?css)',
'',
'^[./]',
Expand Down