From a2ec8573187b7d9d2377cae80833eb91170e9de8 Mon Sep 17 00:00:00 2001 From: adamviktora Date: Mon, 16 Sep 2024 16:04:14 +0200 Subject: [PATCH] refactor(tokens): rename rule --- .../rules/v6/tokensUpdate/tokens-update.md | 24 +++++++++++++++++++ .../tokens-update.test.ts} | 2 +- .../tokens-update.ts} | 0 .../tokensUpdateInput.tsx} | 6 ++--- .../tokensUpdateOutput.tsx} | 6 ++--- .../src/rules/v6/tokensWarn/tokens-warn.md | 17 ------------- 6 files changed, 31 insertions(+), 24 deletions(-) create mode 100644 packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokens-update.md rename packages/eslint-plugin-pf-codemods/src/rules/v6/{tokensWarn/tokens-warn.test.ts => tokensUpdate/tokens-update.test.ts} (99%) rename packages/eslint-plugin-pf-codemods/src/rules/v6/{tokensWarn/tokens-warn.ts => tokensUpdate/tokens-update.ts} (100%) rename packages/eslint-plugin-pf-codemods/src/rules/v6/{tokensWarn/tokensWarnInput.tsx => tokensUpdate/tokensUpdateInput.tsx} (87%) rename packages/eslint-plugin-pf-codemods/src/rules/v6/{tokensWarn/tokensWarnOutput.tsx => tokensUpdate/tokensUpdateOutput.tsx} (90%) delete mode 100644 packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokens-warn.md diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokens-update.md b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokens-update.md new file mode 100644 index 00000000..42a0b4f8 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokens-update.md @@ -0,0 +1,24 @@ +### tokens-update + +We have updated our CSS tokens. About half of our tokens have been replaced with newer ones. + +- this rule provides an autofix for global non color tokens +- global color tokens will be replaced with a temporary hot pink color token (`temp_dev_tbd` react token or `--pf-t--temp--dev--tbd` class) + - don't forget to replace these tokens later +- other non-global (component or chart) tokens need to be replaced manually + +To find a suitable replacement token, check our [v6 token documentation](https://staging-v6.patternfly.org/tokens/all-patternfly-tokens). + +#### Examples + +In: + +```jsx +%inputExample% +``` + +Out: + +```jsx +%outputExample% +``` diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokens-warn.test.ts b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokens-update.test.ts similarity index 99% rename from packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokens-warn.test.ts rename to packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokens-update.test.ts index 111bc7b0..4f169a93 100644 --- a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokens-warn.test.ts +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokens-update.test.ts @@ -1,5 +1,5 @@ const ruleTester = require("../../ruletester"); -import * as rule from "./tokens-warn"; +import * as rule from "./tokens-update"; const getWarnMessage = (tokenName: string) => `${tokenName} is an old CSS token. About half of our tokens have been replaced with newer ones. To find a suitable replacement token, check our new documentation https://staging-v6.patternfly.org/tokens/all-patternfly-tokens.`; diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokens-warn.ts b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokens-update.ts similarity index 100% rename from packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokens-warn.ts rename to packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokens-update.ts diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokensWarnInput.tsx b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokensUpdateInput.tsx similarity index 87% rename from packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokensWarnInput.tsx rename to packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokensUpdateInput.tsx index 03b2a7b9..48c20abb 100644 --- a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokensWarnInput.tsx +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokensUpdateInput.tsx @@ -15,15 +15,15 @@ document.documentElement.style.setProperty("--pf-v5-global--ZIndex--lg", "3"); >; // warnings (not fixable) -import global_warning_color_100 from "@patternfly/react-tokens/dist/esm/global_warning_color_100"; +import c_badge_PaddingLeft from "@patternfly/react-tokens/dist/esm/c_badge_PaddingLeft"; import { c_alert__FontSize } from "@patternfly/react-tokens"; -global_warning_color_100; +c_badge_PaddingLeft; c_alert__FontSize;
; diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokensWarnOutput.tsx b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokensUpdateOutput.tsx similarity index 90% rename from packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokensWarnOutput.tsx rename to packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokensUpdateOutput.tsx index 92da6db8..a1c42a91 100644 --- a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokensWarnOutput.tsx +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensUpdate/tokensUpdateOutput.tsx @@ -15,15 +15,15 @@ document.documentElement.style.setProperty("--pf-t--global--z-index--lg", "3"); >; // warnings (not fixable) -import global_warning_color_100 from "@patternfly/react-tokens/dist/esm/global_warning_color_100"; +import c_badge_PaddingLeft from "@patternfly/react-tokens/dist/esm/c_badge_PaddingLeft"; import { c_alert__FontSize } from "@patternfly/react-tokens"; -global_warning_color_100; +c_badge_PaddingLeft; c_alert__FontSize;
; diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokens-warn.md b/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokens-warn.md deleted file mode 100644 index 43f4b5e3..00000000 --- a/packages/eslint-plugin-pf-codemods/src/rules/v6/tokensWarn/tokens-warn.md +++ /dev/null @@ -1,17 +0,0 @@ -### tokens-warn - -We have updated our CSS tokens. About half of our tokens have been replaced with newer ones. To find a suitable replacement token, check our [v6 token documentation](https://staging-v6.patternfly.org/tokens/all-patternfly-tokens). - -#### Examples - -In: - -```jsx -%inputExample% -``` - -Out: - -```jsx -%outputExample% -```