
Security News
PolinRider: North Korea-Linked Supply Chain Campaign Expands Across Open Source Ecosystems
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.
@huaiyou/config-prettier
Advanced tools
共享的 Prettier 配置,确保代码格式的一致性。
pnpm add -D @huaiyou/config-prettier prettier
{
"prettier": "@huaiyou/config-prettier"
}
module.exports = require('@huaiyou/config-prettier');
import config from '@huaiyou/config-prettier';
export default config;
| 选项 | 值 | 说明 |
|---|---|---|
semi | true | 语句末尾添加分号 |
trailingComma | 'es5' | 尾随逗号(ES5 兼容) |
singleQuote | true | 使用单引号 |
printWidth | 100 | 每行最大字符数 |
tabWidth | 2 | 缩进空格数 |
useTabs | false | 使用空格缩进 |
endOfLine | 'lf' | 行尾符(LF) |
arrowParens | 'always' | 箭头函数参数始终加括号 |
bracketSpacing | true | 对象字面量括号内加空格 |
jsxSingleQuote | false | JSX 使用双引号 |
在 package.json 中添加格式化脚本:
{
"scripts": {
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md,yml,yaml}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md,yml,yaml}\""
}
}
import baseConfig from '@huaiyou/config-prettier';
export default {
...baseConfig,
printWidth: 120, // 覆盖特定选项
};
创建 .prettierignore 文件:
# Dependencies
node_modules
pnpm-lock.yaml
# Build output
dist
build
.next
out
# Environment
.env
.env.local
安装 Prettier 扩展并在 .vscode/settings.json 中配置:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
node_modules/prettier本配置已经与 @huaiyou/config-eslint 完全兼容,不会产生规则冲突。
ESLint 负责代码质量检查,Prettier 负责代码格式化。
MIT
FAQs
Shared Prettier configuration
We found that @huaiyou/config-prettier demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.

Security News
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.