From 78bc3d6a9d3b8121ff86041a30c5aa5202c9286f Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 23 Jul 2023 17:29:33 +0800 Subject: [PATCH] refactor: drop import assertions and inline prettierrcs The Import Assertions proposal is superceded by the Import Attributes proposal. So Node.js support for this syntax might be deprecated or even dropped in the future. Inlining these JSON objects is safer, though a bit less maintainable. But I think it's acceptable for those rarely touched configs. --- templates/prettierrc-airbnb.json | 16 ----------- templates/prettierrc-default.json | 8 ------ templates/prettierrc-standard.json | 14 ---------- templates/prettierrcs.js | 44 +++++++++++++++++++++++++++--- 4 files changed, 40 insertions(+), 42 deletions(-) delete mode 100644 templates/prettierrc-airbnb.json delete mode 100644 templates/prettierrc-default.json delete mode 100644 templates/prettierrc-standard.json diff --git a/templates/prettierrc-airbnb.json b/templates/prettierrc-airbnb.json deleted file mode 100644 index 86b6b36..0000000 --- a/templates/prettierrc-airbnb.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/prettierrc", - "arrowParens": "always", - "bracketSameLine": false, - "bracketSpacing": true, - "endOfLine": "lf", - "jsxSingleQuote": false, - "printWidth": 100, - "proseWrap": "preserve", - "quoteProps": "as-needed", - "semi": true, - "singleQuote": true, - "tabWidth": 2, - "trailingComma": "all", - "useTabs": false -} diff --git a/templates/prettierrc-default.json b/templates/prettierrc-default.json deleted file mode 100644 index ecdf3e0..0000000 --- a/templates/prettierrc-default.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/prettierrc", - "semi": false, - "tabWidth": 2, - "singleQuote": true, - "printWidth": 100, - "trailingComma": "none" -} diff --git a/templates/prettierrc-standard.json b/templates/prettierrc-standard.json deleted file mode 100644 index a6a1d54..0000000 --- a/templates/prettierrc-standard.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/prettierrc", - "arrowParens": "always", - "bracketSameLine": false, - "bracketSpacing": true, - "jsxSingleQuote": true, - "proseWrap": "preserve", - "quoteProps": "as-needed", - "semi": false, - "singleQuote": true, - "tabWidth": 2, - "trailingComma": "none", - "useTabs": false -} diff --git a/templates/prettierrcs.js b/templates/prettierrcs.js index e0f825d..e565cb4 100644 --- a/templates/prettierrcs.js +++ b/templates/prettierrcs.js @@ -1,11 +1,47 @@ -import defaultConfig from './prettierrc-default.json' assert { type: 'json' } +const defaultConfig = { + $schema: 'https://json.schemastore.org/prettierrc', + semi: false, + tabWidth: 2, + singleQuote: true, + printWidth: 100, + trailingComma: 'none' +} + +const airbnb = { + $schema: 'https://json.schemastore.org/prettierrc', + arrowParens: 'always', + bracketSameLine: false, + bracketSpacing: true, + endOfLine: 'lf', + jsxSingleQuote: false, + printWidth: 100, + proseWrap: 'preserve', + quoteProps: 'as-needed', + semi: true, + singleQuote: true, + tabWidth: 2, + trailingComma: 'all', + useTabs: false +} -import airbnb from './prettierrc-airbnb.json' assert { type: 'json' } -import standard from './prettierrc-standard.json' assert { type: 'json' } +const standard = { + $schema: 'https://json.schemastore.org/prettierrc', + arrowParens: 'always', + bracketSameLine: false, + bracketSpacing: true, + jsxSingleQuote: true, + proseWrap: 'preserve', + quoteProps: 'as-needed', + semi: false, + singleQuote: true, + tabWidth: 2, + trailingComma: 'none', + useTabs: false +} export { defaultConfig as default, airbnb, - standard, + standard }