Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tokens): provide autofix for all global tokens #763

Merged
merged 8 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/eslint-plugin-pf-codemods/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './configs';
export * from './ruleCuration';
export * from './ruleCustomization'
export * from "./configs";
export * from "./ruleCuration";
export * from "./ruleCustomization";
export * from "./tokenLists";
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const warningRules = [
"tabs-update-markup",
"tabs-warn-children-type-changed",
"Th-Td-warn-update-markup",
"tokens-warn",
"toolbarLabelGroupContent-updated-markup",
"tooltip-warn-triggerRef-may-be-required",
"treeView-warn-selectable-styling-modifier-removed",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ImportSpecifier } from "estree-jsx";
import { ImportDefaultSpecifierWithParent } from "./interfaces";
import { getDefaultDeclarationString } from "./getDefaultDeclarationString";
import { getImportPath } from "./getImportPath";

/** Gets the name of an import based on the specifier and an array of names that should be looked for in default import paths */
export function getComponentImportName(
Expand All @@ -12,6 +12,6 @@ export function getComponentImportName(
}

return potentialNames.find((name) =>
getDefaultDeclarationString(importSpecifier)?.includes(name)
getImportPath(importSpecifier)?.includes(name)
);
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {
ImportDefaultSpecifierWithParent,
ImportSpecifierWithParent,
} from "./interfaces";

/** Gets the import path string for an import specifier (named or default) */
export function getImportPath(
importSpecifier: ImportDefaultSpecifierWithParent | ImportSpecifierWithParent
) {
return importSpecifier?.parent?.source.value?.toString();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export * from "./getAttributeName";
export * from "./getChildJSXElementByName";
export * from "./getCodeModDataTag";
export * from "./getComponentImportName";
export * from "./getDefaultDeclarationString";
export * from "./getEndRange";
export * from "./getFromPackage";
export * from "./getImportedName";
export * from "./getImportPath";
export * from "./getLocalComponentName";
export * from "./getNodeForAttributeFixer";
export * from "./getNodeName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
JSXOpeningElementWithParent,
} from "./interfaces";
import {
getDefaultDeclarationString,
getImportPath,
getComponentImportName,
getNodeName,
hasCodeModDataTag,
Expand Down Expand Up @@ -90,7 +90,7 @@ export function renameComponent(
}

return oldNames.some((name) =>
getDefaultDeclarationString(imp)?.includes(name)
getImportPath(imp)?.includes(name)
);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -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 (`t_temp_dev_tbd` react token or `--pf-t--temp--dev--tbd` class)
- don't forget to replace these tokens later
adamviktora marked this conversation as resolved.
Show resolved Hide resolved
- 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%
```
Loading
Loading