From a0a7457eea3cdcce29d04e9917e89997cad4b385 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 21 Feb 2023 19:24:47 +0800 Subject: [PATCH] refactor: put the default prettierrc into a separate file --- index.js | 8 +------- templates/prettierrc-default.json | 8 ++++++++ templates/prettierrcs.cjs | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 templates/prettierrc-default.json diff --git a/index.js b/index.js index 83a50a1..4180e7b 100644 --- a/index.js +++ b/index.js @@ -143,13 +143,7 @@ export default function createConfig ({ } if (needsPrettier) { // Prettier recommends an explicit configuration file to let the editor know that it's used. - files['.prettierrc.json'] = prettierrcs[styleGuide] || `{ - "semi": false, - "tabWidth": 2, - "singleQuote": true, - "printWidth": 100, - "trailingComma": "none" -}` + files['.prettierrc.json'] = prettierrcs[styleGuide] } return { diff --git a/templates/prettierrc-default.json b/templates/prettierrc-default.json new file mode 100644 index 0000000..ecdf3e0 --- /dev/null +++ b/templates/prettierrc-default.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://json.schemastore.org/prettierrc", + "semi": false, + "tabWidth": 2, + "singleQuote": true, + "printWidth": 100, + "trailingComma": "none" +} diff --git a/templates/prettierrcs.cjs b/templates/prettierrcs.cjs index 607fdab..3d6f476 100644 --- a/templates/prettierrcs.cjs +++ b/templates/prettierrcs.cjs @@ -1,2 +1,3 @@ exports.airbnb = require('./prettierrc-airbnb.json') +exports.default = require('./prettierrc-default.json') exports.standard = require('./prettierrc-standard.json')