From 15d9bc7b58bb6bddee2b8be0aee9b4b121c4b564 Mon Sep 17 00:00:00 2001 From: Jordan Shatford Date: Mon, 11 Sep 2023 13:24:45 +1000 Subject: [PATCH] feat(config): shared prettier config to be used in monorepo Signed-off-by: Jordan Shatford --- apps/web/.prettierrc | 9 +------ apps/web/package.json | 3 --- packages/client/.prettierrc | 7 +----- packages/client/package.json | 1 - packages/config/package.json | 6 ++++- packages/config/prettier/index.js | 9 +++++++ packages/ui/.prettierrc | 9 +------ packages/ui/package.json | 3 --- pnpm-lock.yaml | 40 ++++++++++++------------------- 9 files changed, 32 insertions(+), 55 deletions(-) create mode 100644 packages/config/prettier/index.js diff --git a/apps/web/.prettierrc b/apps/web/.prettierrc index 8bc6e864..e7e20303 100644 --- a/apps/web/.prettierrc +++ b/apps/web/.prettierrc @@ -1,8 +1 @@ -{ - "useTabs": true, - "singleQuote": true, - "trailingComma": "none", - "printWidth": 100, - "plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"], - "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] -} +"@yd/config/prettier" diff --git a/apps/web/package.json b/apps/web/package.json index d8921f93..1cadf948 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -25,9 +25,6 @@ "@yd/config": "workspace:*", "autoprefixer": "^10.4.15", "postcss": "^8.4.29", - "prettier": "^3.0.3", - "prettier-plugin-svelte": "^3.0.3", - "prettier-plugin-tailwindcss": "^0.5.4", "svelte": "^4.2.0", "svelte-check": "^3.5.1", "tailwindcss": "^3.3.3", diff --git a/packages/client/.prettierrc b/packages/client/.prettierrc index ff2677ef..e7e20303 100644 --- a/packages/client/.prettierrc +++ b/packages/client/.prettierrc @@ -1,6 +1 @@ -{ - "useTabs": true, - "singleQuote": true, - "trailingComma": "none", - "printWidth": 100 -} +"@yd/config/prettier" diff --git a/packages/client/package.json b/packages/client/package.json index a1369d20..1397b337 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -14,7 +14,6 @@ "devDependencies": { "@yd/config": "workspace:*", "openapi-typescript-codegen": "^0.25.0", - "prettier": "^3.0.3", "typescript": "^5.2.2" } } diff --git a/packages/config/package.json b/packages/config/package.json index eeb41cb3..ac202b36 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -7,7 +7,8 @@ "./tailwind": "./tailwind.config.js", "./eslint/typescript": "./eslint/typescript.js", "./eslint/svelte": "./eslint/svelte.js", - "./typescript": "./typescript.json" + "./prettier": "./prettier/index.js", + "./typescript": "./typescript.json" }, "scripts": {}, "devDependencies": { @@ -16,6 +17,9 @@ "eslint": "^8.48.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-svelte": "^2.33.0", + "prettier": "^3.0.3", + "prettier-plugin-svelte": "^3.0.3", + "prettier-plugin-tailwindcss": "^0.5.4", "tailwindcss": "^3.3.3" } } diff --git a/packages/config/prettier/index.js b/packages/config/prettier/index.js new file mode 100644 index 00000000..748cec76 --- /dev/null +++ b/packages/config/prettier/index.js @@ -0,0 +1,9 @@ +/** @type {import("prettier").Config} */ +module.exports = { + useTabs: true, + singleQuote: true, + trailingComma: "none", + printWidth: 100, + plugins: ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"], + overrides: [{ "files": "*.svelte", "options": { "parser": "svelte" } }] +}; diff --git a/packages/ui/.prettierrc b/packages/ui/.prettierrc index 8bc6e864..e7e20303 100644 --- a/packages/ui/.prettierrc +++ b/packages/ui/.prettierrc @@ -1,8 +1 @@ -{ - "useTabs": true, - "singleQuote": true, - "trailingComma": "none", - "printWidth": 100, - "plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"], - "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] -} +"@yd/config/prettier" diff --git a/packages/ui/package.json b/packages/ui/package.json index a9515a09..5d5c3ccc 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -37,9 +37,6 @@ "@yd/config": "workspace:*", "autoprefixer": "^10.4.15", "postcss": "^8.4.29", - "prettier": "^3.0.3", - "prettier-plugin-svelte": "^3.0.3", - "prettier-plugin-tailwindcss": "^0.5.4", "publint": "^0.2.2", "svelte": "^4.2.0", "svelte-check": "^3.5.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6dd051bd..a8f31d0e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,15 +50,6 @@ importers: postcss: specifier: ^8.4.29 version: 8.4.29 - prettier: - specifier: ^3.0.3 - version: 3.0.3 - prettier-plugin-svelte: - specifier: ^3.0.3 - version: 3.0.3(prettier@3.0.3)(svelte@4.2.0) - prettier-plugin-tailwindcss: - specifier: ^0.5.4 - version: 0.5.4(prettier-plugin-svelte@3.0.3)(prettier@3.0.3) svelte: specifier: ^4.2.0 version: 4.2.0 @@ -86,9 +77,6 @@ importers: openapi-typescript-codegen: specifier: ^0.25.0 version: 0.25.0 - prettier: - specifier: ^3.0.3 - version: 3.0.3 typescript: specifier: ^5.2.2 version: 5.2.2 @@ -109,7 +97,16 @@ importers: version: 9.0.0(eslint@8.48.0) eslint-plugin-svelte: specifier: ^2.33.0 - version: 2.33.0(eslint@8.48.0)(ts-node@10.9.1) + version: 2.33.0(eslint@8.48.0)(svelte@4.2.0)(ts-node@10.9.1) + prettier: + specifier: ^3.0.3 + version: 3.0.3 + prettier-plugin-svelte: + specifier: ^3.0.3 + version: 3.0.3(prettier@3.0.3)(svelte@4.2.0) + prettier-plugin-tailwindcss: + specifier: ^0.5.4 + version: 0.5.4(prettier-plugin-svelte@3.0.3)(prettier@3.0.3) tailwindcss: specifier: ^3.3.3 version: 3.3.3(ts-node@10.9.1) @@ -138,15 +135,6 @@ importers: postcss: specifier: ^8.4.29 version: 8.4.29 - prettier: - specifier: ^3.0.3 - version: 3.0.3 - prettier-plugin-svelte: - specifier: ^3.0.3 - version: 3.0.3(prettier@3.0.3)(svelte@4.2.0) - prettier-plugin-tailwindcss: - specifier: ^0.5.4 - version: 0.5.4(prettier-plugin-svelte@3.0.3)(prettier@3.0.3) publint: specifier: ^0.2.2 version: 0.2.2 @@ -1594,7 +1582,7 @@ packages: eslint: 8.48.0 dev: true - /eslint-plugin-svelte@2.33.0(eslint@8.48.0)(ts-node@10.9.1): + /eslint-plugin-svelte@2.33.0(eslint@8.48.0)(svelte@4.2.0)(ts-node@10.9.1): resolution: {integrity: sha512-kk7Z4BfxVjFYJseFcOpS8kiKNio7KnAnhFagmM89h1wNSKlM7tIn+uguNQppKM9leYW+S+Us0Rjg2Qg3zsEcvg==} engines: {node: ^14.17.0 || >=16.0.0} peerDependencies: @@ -1615,7 +1603,8 @@ packages: postcss-safe-parser: 6.0.0(postcss@8.4.29) postcss-selector-parser: 6.0.13 semver: 7.5.4 - svelte-eslint-parser: 0.33.0 + svelte: 4.2.0 + svelte-eslint-parser: 0.33.0(svelte@4.2.0) transitivePeerDependencies: - supports-color - ts-node @@ -3217,7 +3206,7 @@ packages: - sugarss dev: true - /svelte-eslint-parser@0.33.0: + /svelte-eslint-parser@0.33.0(svelte@4.2.0): resolution: {integrity: sha512-5awZ6Bs+Tb/zQwa41PSdcLynAVQTwW0HGyCBjtbAQ59taLZqDgQSMzRlDmapjZdDtzERm0oXDZNE0E+PKJ6ryg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3231,6 +3220,7 @@ packages: espree: 9.6.1 postcss: 8.4.29 postcss-scss: 4.0.7(postcss@8.4.29) + svelte: 4.2.0 dev: true /svelte-feather-icons@4.0.1: