@orderly.network/prettier-config
v0.2.6
Published
Shared Prettier configuration used across Orderly projects to enforce a consistent code style and import order.
Keywords
Readme
@orderly.network/prettier-config
Shared Prettier configuration used across Orderly projects to enforce a consistent code style and import order.
This package wraps a Prettier config and the @trivago/prettier-plugin-sort-imports plugin, so you can reuse the same setup in multiple repositories or packages.
Installation
Install Prettier (peer dependency) and this config as dev dependencies:
npm install --save-dev prettier @orderly.network/prettier-config
# or
pnpm add -D prettier @orderly.network/prettier-config
# or
yarn add -D prettier @orderly.network/prettier-configNote
This package requiresprettier >= 3.0.0.
Usage
Basic setup
Create a prettier.config.mjs (or any Prettier-supported config file) in your project root and re-export the shared config:
import config from "@orderly.network/prettier-config";
export default config;After that, you can run Prettier as usual, for example:
npx prettier . --writeMonorepo usage
In a monorepo, you can either:
- Put
prettier.config.mjsat the workspace root so all packages share the same configuration, or - Add a small
prettier.config.mjsin each package that re-exports the shared config:
import config from "@orderly.network/prettier-config";
export default config;Import sorting behavior
This config enables @trivago/prettier-plugin-sort-imports to automatically sort your ES module imports.
The importOrder is configured to group imports in the following order:
reactcore package (^react$)- Other React-related imports (
^react) - Third-party modules (
<THIRD_PARTY_MODULES>) - Internal packages under
@orderly.network/*(excluding.css) - UI library imports from
@orderly.network/ui(excluding.css) - Aliased imports starting with
@/(excluding.css) - Relative imports (
./or../, excluding.css) - CSS imports (any
*.css), always placed last
This helps keep imports organized and predictable across the codebase.
Configuration details
The exported Prettier config currently sets:
semi: true– always add semicolons.tabWidth: 2– use 2 spaces for indentation.singleQuote: false– use double quotes for strings.plugins– includes@trivago/prettier-plugin-sort-importsfor import sorting.importOrder– import grouping as described above.
Requirements
prettier >= 3.0.0
It is recommended to run Prettier (with this shared config) both locally and in CI to ensure a consistent code style across the team and all Orderly projects.
