Detailed guide for configuring Prettier with JS Style Kit
.prettierrc.js
file in your project root:
.prettierrc.mjs
file instead:
package.json
:
prettierConfig()
function accepts a configuration object with the following options:
prettier-plugin-css-order
) sorts CSS properties in a consistent order. It’s enabled by default.
To disable it:
prettier-plugin-sort-json
) sorts JSON properties alphabetically. It’s enabled by default.
Basic configuration:
prettier-plugin-packagejson
) sorts package.json fields according to a standard convention. It’s enabled by default.
To disable it:
prettier-plugin-tailwindcss
) sorts Tailwind CSS classes according to Tailwind’s recommended order. It’s disabled by default.
Enable with default settings:
clsx
, cva
, cn
).
Add custom tailwind functions:
prettier-plugin-tailwindcss
to remove an unsafe declare module
statement that can cause conflicts with other Prettier plugins. This happens automatically when the Tailwind plugin is enabled, so you don’t need to worry about manual fixes or compatibility issues.
The patch addresses a known issue where the Tailwind plugin’s TypeScript declarations include a global module declaration that can conflict with other Prettier plugins, leading to type errors or plugin compatibility problems.
experimentalTernaries
is enabled by default in JS Style Kit’s Prettier configuration.
.vscode/settings.json
file: