Skip to content

Instantly share code, notes, and snippets.

@aqzhyi
Last active September 13, 2025 05:12
Show Gist options
  • Save aqzhyi/47e08ce5631e24f03a6e8018934f6af2 to your computer and use it in GitHub Desktop.
Save aqzhyi/47e08ce5631e24f03a6e8018934f6af2 to your computer and use it in GitHub Desktop.
prettier v3 with ESM setup
// @ts-check
/** @type {import('prettier').Config} */
const overrides = {
overrides: [
{ files: ['*.astro'], options: { parser: 'astro' } },
{ files: '*.vue', options: { parser: 'vue' } },
{ files: ['*.htm', '*.html', '*.htmlx'], options: { parser: 'html' } },
{ files: '*.scss', options: { parser: 'scss' } },
{ files: '*.css', options: { parser: 'css' } },
{ files: '*.md', options: { parser: 'markdown' } },
{ files: '*.mdx', options: { parser: 'mdx' } },
{ files: '*.yaml', options: { parser: 'yaml' } },
{
// some files like package.json do not allow comments because they are json
// `'json-stringify'` can make, for example, `['foo', 'bar']` into multiple lines,
// which makes it easier to add or delete elements
files: ['**/package.json'],
options: { parser: 'json-stringify' },
},
{
files: [
'i18n/**/*.json',
'i18n/*.json',
'locales/**/*.json',
'locales/*.json',
],
options: { parser: 'json' },
},
{
// some files like tsconfig.json are written in jsonc so comments are allowed
files: ['.oxlintrc.json', 'tsconfig.json', 'tsconfig.*.json'],
options: { parser: 'json' },
},
{ files: ['**/*.{js,mjs,cjs,jsx}'], options: { parser: 'babel' } },
{ files: ['**/*.{ts,mts,cts,tsx}'], options: { parser: 'typescript' } },
],
}
/** @type {Partial<import('prettier-plugin-jsdoc').Options>} */
const prettierPluginJsdocOptions = {
jsdocCommentLineStrategy: 'keep',
jsdocCapitalizeDescription: false,
}
/** @type {import('prettier').Options} */
const config = {
plugins: ['prettier-plugin-jsdoc', 'prettier-plugin-tailwindcss'],
...prettierPluginJsdocOptions,
arrowParens: 'always',
bracketSameLine: false,
bracketSpacing: true,
insertPragma: false,
jsxSingleQuote: true,
printWidth: 80,
proseWrap: 'preserve',
quoteProps: 'consistent',
requirePragma: false,
semi: false,
singleAttributePerLine: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
}
// eslint-disable-next-line import/no-anonymous-default-export
export default {
...config,
...overrides,
}
{
"private": true,
"type": "module",
"devDependencies": {
"prettier": "3.6.2",
"prettier-plugin-jsdoc": "1.3.3",
"prettier-plugin-tailwindcss": "0.6.14"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment