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

refactor: add codemod for Table & Spinner #1976

Merged
merged 6 commits into from
Jan 18, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
chore: udpate tabel codemod
  • Loading branch information
snitin315 committed Jan 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d1873f50137ad24fd3d3f6c11caa1fbb20acc852
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ it('should migrate the ActionList component', async () => {
expect(result).toMatchInlineSnapshot(`
"const App = () => (
<>
<Table {...args} data={data} backgroundColor="surface.background.gray.intense">
<Table {...args} data={data}>
{(tableData) => (
<>
<TableHeader>
@@ -123,7 +123,7 @@ it('should migrate the ActionList component', async () => {
)}
</Table>

<Table {...args} data={data} backgroundColor="surface.background.gray.moderate">
<Table {...args} data={data}>
{(tableData) => (
<>
<TableHeader>
@@ -150,7 +150,7 @@ it('should migrate the ActionList component', async () => {
)}
</Table>

<Table {...args} data={data} backgroundColor="surface.background.subtle">
<Table {...args} data={data}>
{(tableData) => (
<>
<TableHeader>
8 changes: 4 additions & 4 deletions packages/blade/codemods/brand-refresh/transformers/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Transform } from 'jscodeshift';
import migrateAmountComponent from './migrate-amount';
import migrateDividerComponent from './migrate-divider';
import migrateCardAndTableComponent from './migrate-card-and-table';
import migrateCardComponent from './migrate-card';
import migrateBadgeComponent from './migrate-badge';
import migrateContrastIntentAndColorProps from './migrate-contrast-intent-color-props';
import migrateTypographyComponents from './migrate-typography';
import migrateActionListComponent from './migrate-actionlist';
import migrateActionListAndTable from './migrate-actionlist-and-table';
import { red, isExpression } from './utils';
// eslint-disable-next-line import/extensions
import colorTokensMapping from './colorTokensMapping.json';
@@ -109,7 +109,7 @@

return node;
});
} catch (error) {

Check warning on line 112 in packages/blade/codemods/brand-refresh/transformers/index.ts

GitHub Actions / Validate Source Code

Implicit any in catch clause
console.error(
red(
`⛔️ ${file.path}: Oops! Ran into an issue while updating the themeTokens prop in BladeProvider.`,
@@ -173,7 +173,7 @@

return node;
});
} catch (error) {

Check warning on line 176 in packages/blade/codemods/brand-refresh/transformers/index.ts

GitHub Actions / Validate Source Code

Implicit any in catch clause
console.error(
red(
`⛔️ ${file.path}: Oops! Ran into an issue while updating the color token value based on the context.`,
@@ -185,10 +185,10 @@
migrateTypographyComponents({ root, j, file });
migrateContrastIntentAndColorProps({ root, j, file });
migrateBadgeComponent({ root, j, file });
migrateCardAndTableComponent({ root, j, file });
migrateCardComponent({ root, j, file });
migrateAmountComponent({ root, j, file });
migrateDividerComponent({ root, j, file });
migrateActionListComponent({ root, j, file });
migrateActionListAndTable({ root, j, file });
migrateDropdownComponent({ root, j, file });

// Update ImportSpecifier from "paymentTheme"/"bankingTheme" to "bladeTheme"
@@ -209,7 +209,7 @@

return path.node;
});
} catch (error) {

Check warning on line 212 in packages/blade/codemods/brand-refresh/transformers/index.ts

GitHub Actions / Validate Source Code

Implicit any in catch clause
console.error(
red(
`⛔️ ${file.path}: Oops! Ran into an issue while updating the ImportSpecifier from "paymentTheme"/"bankingTheme" to "bladeTheme".`,
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { red } from './utils';

function migrateActionListComponent({ root, j, file }): void {
function migrateActionListAndTable({ root, j, file }): void {
// ActionList & Table components: Remove the `surfaceLevel` prop
// <ActionList surfaceLevel={2}> -> <ActionList >
// <Table surfaceLevel={2}> -> <Table >
@@ -9,7 +9,7 @@
.find(j.JSXElement, {
openingElement: {
name: {
name: 'ActionList',
name: (name) => ['ActionList', 'Table'].includes(name),
},
},
})
@@ -19,7 +19,7 @@
},
})
.remove();
} catch (error) {

Check warning on line 22 in packages/blade/codemods/brand-refresh/transformers/migrate-actionlist-and-table.ts

GitHub Actions / Validate Source Code

Implicit any in catch clause
console.error(
red(
`⛔️ ${file.path}: Oops! Ran into an issue while removing the "surfaceLevel" prop from "ActionList"/"Table".`,
@@ -29,4 +29,4 @@
}
}

export default migrateActionListComponent;
export default migrateActionListAndTable;
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { red } from './utils';

// Card & Table components Migration
// Card components Migration
// <Card surfaceLevel={2|3} > -> <Card backgroundColor=”surface.background.gray.moderate”|surface.background.gray.intense>
// <Table surfaceLevel={2|3} > -> <Table backgroundColor=”surface.background.gray.subtle|surface.background.gray.moderate|surface.background.gray.intense”>
function migrateCardAndTable({ root, j, file }): void {
try {
root
.find(j.JSXElement, {
openingElement: {
name: {
name: (name) => ['Card', 'Table'].includes(name),
name: 'Card',
},
},
})
@@ -33,7 +32,7 @@

return node;
});
} catch (error) {

Check warning on line 35 in packages/blade/codemods/brand-refresh/transformers/migrate-card.ts

GitHub Actions / Validate Source Code

Implicit any in catch clause
console.error(
red(`⛔️ ${file.path}: Oops! Ran into an issue while updating the Card component.`),
`\n${red(error.stack)}\n`,
12 changes: 3 additions & 9 deletions packages/blade/upgrade-v11.md
Original file line number Diff line number Diff line change
@@ -460,15 +460,9 @@ Only use this if you're unable to run the codemod described above.

### Table

- **The `surfaceLevel` prop has been removed in favor of the `backgroundColor` prop.**
- **The `surfaceLevel` prop has been removed without replacement.**

```diff
- <Table data={tableData} surfaceLevel={1}>
+ <Table backgroundColor="surface.background.gray.subtle">

- <Table data={tableData} surfaceLevel={2}>
+ <Table backgroundColor="surface.background.gray.moderate">

- <Table data={tableData} surfaceLevel={3}>
+ <Table backgroundColor="surface.background.gray.intense">
- <Table data={tableData} surfaceLevel={1/2/3} >
+ <Table data={tableData} >
```
Loading