From 62775f5076d90e5fa84ea107f2ecaf285860ae2c Mon Sep 17 00:00:00 2001 From: freshavocado7 Date: Wed, 18 Sep 2024 14:27:21 +0200 Subject: [PATCH] refactor: Make tailwind classes prettier --- .pre-commit-config.yaml | 5 ++ frontend/.eslintrc.cjs | 3 +- frontend/.prettierrc.js | 9 ++- frontend/package-lock.json | 48 ++++++++++++ frontend/package.json | 2 + frontend/src/components/Badge.jsx | 28 ++++--- frontend/src/components/Breadcrumbs.jsx | 17 ++--- frontend/src/components/Button.jsx | 11 +-- frontend/src/components/Card.jsx | 8 +- frontend/src/components/DiffExplorer.jsx | 8 +- frontend/src/components/DiffView.jsx | 16 ++-- frontend/src/components/Header.jsx | 8 +- frontend/src/components/HomeIcon.jsx | 4 +- frontend/src/components/InstanceView.jsx | 28 +++---- frontend/src/components/Lightbox.jsx | 12 +-- frontend/src/components/LightboxButton.jsx | 6 +- frontend/src/components/ModelDiff.jsx | 30 ++++---- frontend/src/components/SVGDisplay.jsx | 13 ++-- frontend/src/components/SettingsMenu.jsx | 13 +--- frontend/src/components/SoftwareVersion.jsx | 4 +- frontend/src/components/Spinner.jsx | 6 +- frontend/src/components/TemplateCard.jsx | 19 ++--- frontend/src/components/TemplateDetails.jsx | 73 ++++++++----------- frontend/src/components/ThemeSwitcher.jsx | 12 +-- frontend/src/components/ViewsList.jsx | 21 ++---- .../src/components/WiredTemplatesList.jsx | 15 ++-- frontend/src/views/HomeView.jsx | 14 +++- frontend/src/views/ModelComparisonView.jsx | 55 ++++++-------- frontend/src/views/TemplateView.jsx | 68 ++++++++--------- 29 files changed, 279 insertions(+), 277 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5030375..cee44e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -131,6 +131,8 @@ repos: additional_dependencies: - 'prettier@^3.3.3' - 'prettier-plugin-tailwindcss@^0.6.6' + - 'prettier-plugin-classnames@^0.7.2' + - 'prettier-plugin-merge@^0.7.1' - 'tailwind-scrollbar@^3.1.0' - repo: https://github.com/pre-commit/mirrors-eslint rev: v9.10.0 @@ -147,3 +149,6 @@ repos: - 'eslint-plugin-react@^7.34.1' - 'eslint-plugin-react-hooks@^4.6.2' - 'eslint-plugin-react-refresh@^0.4.5' + args: ['--fix'] + types: [] + files: '^frontend/.*\.(js|jsx)$' diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs index 71ff1a6..b7db9aa 100644 --- a/frontend/.eslintrc.cjs +++ b/frontend/.eslintrc.cjs @@ -22,6 +22,7 @@ module.exports = { 'warn', { allowConstantExport: true } ], - 'max-len': ['error', { code: 79 }] + 'max-len': ['error', { code: 100 }], + 'react/no-unescaped-entities': 'off' } }; diff --git a/frontend/.prettierrc.js b/frontend/.prettierrc.js index d17e3d4..9585637 100644 --- a/frontend/.prettierrc.js +++ b/frontend/.prettierrc.js @@ -4,11 +4,16 @@ */ module.exports = { - plugins: [require.resolve('prettier-plugin-tailwindcss')], + plugins: [ + require.resolve('prettier-plugin-tailwindcss'), + require.resolve('prettier-plugin-classnames'), + require.resolve('prettier-plugin-merge') + ], semi: true, tabWidth: 2, printWidth: 79, singleQuote: true, trailingComma: 'none', - bracketSameLine: true + bracketSameLine: true, + endingPosition: 'absolute-with-indent' }; diff --git a/frontend/package-lock.json b/frontend/package-lock.json index f3f0d70..10c3bdb 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -42,6 +42,8 @@ "globals": "^15.9.0", "postcss": "^8.4.45", "prettier": "^3.3.3", + "prettier-plugin-classnames": "^0.7.2", + "prettier-plugin-merge": "^0.7.1", "prettier-plugin-tailwindcss": "^0.6.6", "prop-types": "^15.8.1", "react-router-dom": "^6.26.2", @@ -6039,6 +6041,15 @@ "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==" }, + "node_modules/diff": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", + "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -10299,6 +10310,43 @@ "node": ">=6.0.0" } }, + "node_modules/prettier-plugin-classnames": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/prettier-plugin-classnames/-/prettier-plugin-classnames-0.7.2.tgz", + "integrity": "sha512-rocYqVSWV/YSJE+TA7b1IgYY9/I4bx0lxJjE5Iwv/kavNNEYhKh7Gl1+MQARQYgPisGMd5DU8Uj6ZEVX0KmTTA==", + "dev": true, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "prettier": "^2 || ^3", + "prettier-plugin-astro": "*", + "prettier-plugin-svelte": "*" + }, + "peerDependenciesMeta": { + "prettier-plugin-astro": { + "optional": true + }, + "prettier-plugin-svelte": { + "optional": true + } + } + }, + "node_modules/prettier-plugin-merge": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-merge/-/prettier-plugin-merge-0.7.1.tgz", + "integrity": "sha512-R3dSlv3kAlScjd/liWjTkGHcUrE4MBhPKKBxVOvHK7+FY2P5SEmLarZiD11VUEuaMRK0L7zqIurX6JcRYS9Y5Q==", + "dev": true, + "dependencies": { + "diff": "5.1.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "prettier": "^2 || ^3" + } + }, "node_modules/prettier-plugin-tailwindcss": { "version": "0.6.6", "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.6.tgz", diff --git a/frontend/package.json b/frontend/package.json index 1609fed..091dd43 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -47,6 +47,8 @@ "globals": "^15.9.0", "postcss": "^8.4.45", "prettier": "^3.3.3", + "prettier-plugin-classnames": "^0.7.2", + "prettier-plugin-merge": "^0.7.1", "prettier-plugin-tailwindcss": "^0.6.6", "prop-types": "^15.8.1", "react-router-dom": "^6.26.2", diff --git a/frontend/src/components/Badge.jsx b/frontend/src/components/Badge.jsx index a24b443..dd6b12c 100644 --- a/frontend/src/components/Badge.jsx +++ b/frontend/src/components/Badge.jsx @@ -1,18 +1,22 @@ - // Copyright DB InfraGO AG and contributors // SPDX-License-Identifier: Apache-2.0 const color_classes = { - "default": "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300", - "danger": "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300", - "success": "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300", - "warning": "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300" -} + default: 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300', + danger: 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300', + success: 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300', + warning: + 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300' +}; /* -* provides a badge that may have different colors -*/ -export const Badge = ({ children, color="default" }) => ( -
- {children} -
+ * provides a badge that may have different colors + */ +export const Badge = ({ children, color = 'default' }) => ( +
+ {children} +
); diff --git a/frontend/src/components/Breadcrumbs.jsx b/frontend/src/components/Breadcrumbs.jsx index 414d63e..6efec40 100644 --- a/frontend/src/components/Breadcrumbs.jsx +++ b/frontend/src/components/Breadcrumbs.jsx @@ -65,9 +65,7 @@ export const Breadcrumbs = () => { return (