Skip to content

Commit

Permalink
feat(prettier): add back packagejson plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Apr 7, 2024
1 parent fd05195 commit ce2c198
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
5 changes: 5 additions & 0 deletions packages/prettier-config-ali/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# 更新日志

## 1.2.0 - 2024-04-07

- 重新添加 `prettier-plugin-packagejson`
- 补全 Prettier 选项

## 1.1.0 - 2024-01-23

- 移除 `prettier-plugin-packagejson` (在 `type: module` 项目中报错)
Expand Down
3 changes: 3 additions & 0 deletions packages/prettier-config-ali/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Options } from 'prettier';

declare const config: Options;
22 changes: 14 additions & 8 deletions packages/prettier-config-ali/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
module.exports = {
// Prettier 兼容 EditorConfig,凡是能够在 EditorConfig 中配置的,这里就不再定义,避免冲突
// 详见 https://prettier.io/docs/en/options
printWidth: 100,
tabWidth: 2,
tabs: false,
semi: true,
singleQuote: true,
quoteProps: 'as-needed',
jsxSingleQuote: false,
trailingComma: 'all',
bracketSpacing: true,
bracketSameLine: false,
arrowParens: 'always',
bracketSpacing: true, // https://prettier.io/docs/en/options#bracket-spacing
semi: true, // https://prettier.io/docs/en/options#semicolons
trailingComma: 'all', // https://prettier.io/docs/en/options#trailing-commas

// Prettier 2.x 可以自动加载 prettier-plugin- 开头的插件
// 但是从 Prettier 3.x 开始,插件必须配置才能生效
endOfLine: 'lf',
// 从 Prettier 3.x 开始,插件必须配置才能生效
plugins: [
// 'prettier-plugin-packagejson', // 排序 package.json 中的属性,ESM 项目报错,暂时禁用
// 排序 package.json 中的属性,ESM 项目报错,暂时禁用
'prettier-plugin-packagejson',
],
};
7 changes: 6 additions & 1 deletion packages/prettier-config-ali/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"f2elint",
"Alibaba F2E Guidelines"
],
"scripts": {
"build": "tsc"
},
"repository": {
"type": "git",
"url": "https://github.com/alibaba/f2e-spec"
Expand All @@ -26,5 +29,7 @@
"devDependencies": {
"prettier": "^2.2.1"
},
"dependencies": {}
"dependencies": {
"prettier-plugin-packagejson": "^2.4.14"
}
}

0 comments on commit ce2c198

Please sign in to comment.