Skip to content

INSTUI-5173: Document the new codemods in the upgrade guide; allow both Prettier 2 and 3 to run in the codemods - #2705

Open
matyasf wants to merge 2 commits into
masterfrom
codemod_fixes
Open

INSTUI-5173: Document the new codemods in the upgrade guide; allow both Prettier 2 and 3 to run in the codemods#2705
matyasf wants to merge 2 commits into
masterfrom
codemod_fixes

Conversation

@matyasf

@matyasf matyasf commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Make Prettier a peer dependency; allow users to use both v2 and v3
  • Move the codemod section to the top of the v11.7 upgrade guide and add migrateToNewIcons and multiVersionThemeVariablesCodemod docs
  • Add the missing Billboard iconHoverColorInverse / messageColorInverse removals and a DataPermissionLevels entry to the theme variable mappings

Test Plan

  • Check the v11.7 upgrade guide in the docs app
  • Run multiVersionThemeVariablesCodemod against a file using Billboard iconHoverColorInverse / messageColorInverse and DataPermissionLevels overrides to confirm they're removed.

Fixes INSTUI-5173

🤖 Generated with Claude Code

@matyasf matyasf self-assigned this Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://instructure.design/pr-preview/pr-2705/

Built to branch gh-pages at 2026-09-03 13:01 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Visual regression report

Cypress suite: ✅ Passing

Visual diff: ⚠️ Changes detected.

Status Count
Unchanged 95
Changed 1
New 0
Removed 0

Accessibility (axe): ✅ No violations.

📊 View full report — click a screenshot's ⚠ badge to see each violation boxed on the image, with the offending element named and contrast failures shown as color swatches.

Diff images (1)

badge-canvas.png — 1573 pixels differ

Baselines come from the visual-baselines branch. They refresh on every merge to master. The Cypress suite line covers the a11y and console-error assertions — a ❌ there means the suite found real issues even if the visual diff is clean.

github-actions Bot pushed a commit that referenced this pull request Sep 2, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 2, 2026
@matyasf matyasf changed the title docs(ui-codemods): document the new codemods in the upgrade guide INSTUI-5173: Document the new codemods in the upgrade guide; allow both Prettier 2 and 3 to run in the codemods Sep 2, 2026

## Codemods

### updateInstUIImportVersions

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this section was just moved up

* @returns a promise resolving to the modified file as `string` or to `null`
*/
const myCodemod: Transform = (file, api,
const myCodemod: Transform = async (file, api,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async is needed because Prettier 3 as async, thus everything needs to be async

- `fileName`: write parse errors and transform failures to this file.
- `usePrettier`: run output through Prettier (default `true`).

### migrateToNewIcons

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new part from here

removed: {
iconColor: {},
iconHoverColor: {}
iconHoverColor: {},

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes in this file are because these were late additiong and were missing from the codemod

Comment on lines +54 to +84
const importModule = new Function('specifier', 'return import(specifier)') as (
specifier: string
) => Promise<Record<string, unknown>>

async function importPrettier(): Promise<Record<string, unknown>> {
try {
return await importModule(PRETTIER)
} catch {
// Test runners that evaluate modules in their own context (Vitest) give
// `new Function` no dynamic import callback, but do handle a plain import.
return await import(PRETTIER)
}
}

/**
* Prettier is an optional peer dependency, so it is resolved from the
* consumer's `node_modules` and its version is whatever they installed.
*/
function loadPrettier() {
if (!prettierPromise) {
prettierPromise = importPrettier()
.then((namespace) => {
const asDefault = namespace.default as PrettierModule | undefined
return typeof asDefault?.format === 'function'
? asDefault
: (namespace as unknown as PrettierModule)
})
.catch(() => undefined)
}
return prettierPromise
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole thing is super ugly, but needed while ppl are using Prettier v2..

@matyasf
matyasf requested a review from joyenjoyer September 2, 2026 15:14
github-actions Bot pushed a commit that referenced this pull request Sep 3, 2026
@@ -1,10 +1,10 @@
---
title: Upgrade guide for v11.7
title: Upgrade guide for new theming

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was really debating the best title for this (cannot be much longer than now), still not 100% sure that this is the best

---

# Upgrade guide for v10 -> v11
# Upgrade guide for v10 -> 11

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove v from v11 here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to keep the title as short at possible

Comment thread docs/upgrading/upgrade-guide.md Outdated
npx jscodeshift@latest -t node_modules/@instructure/ui-codemods/lib/[codemod name].ts <path> \
--extensions=ts,tsx \
--ignore-pattern="**/node_modules/**" \
--ignore-pattern="**/*.d.ts" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the trailing slash after the last line

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@joyenjoyer joyenjoyer Sep 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried loading the upgrade-guide in a local environment and it loads extremely slowly for me. Please check it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats because this page is huge and because you are using a debug build. Even in the prod build its 2 secs on my M3 Max. I guess if we'd optimize V12ChangelogTable to e.g. use native HTML instead of InstUI it would be much faster. maybe worth a shot in a different PR.

Is it a bad UX in your machine here too? https://instructure.design/pr-preview/pr-2705/upgrade-guide

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this upon opening the link:
image

matyasf and others added 2 commits September 3, 2026 14:54
Move the codemod docs to the top of the v11.7 upgrade guide and add
migrateToNewIcons and multiVersionThemeVariablesCodemod sections. Note which
InstUI version introduced each change in the codemod JSDoc, and group the
exports by target version.

Also add the missing Billboard iconHoverColorInverse and messageColorInverse
removals and a DataPermissionLevels entry to the theme variable mappings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ettier 3

Prettier is now an optional peer dependency instead of a bundled Prettier 2. The codemods import it
lazily from the consumer's node_modules, accept both the v2 sync and v3 async API, and fall back to
unformatted output with a warning when it is not installed. This makes instUICodemodExecutor and
every transform async, so the tests await them and the codemod fixtures are excluded from the repo's
own Prettier run.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Sep 3, 2026
let warnedAboutMissingPrettier = false

/**
* jscodeshift registers `@babel/register` for `.mjs` and `.cjs` files too and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit too verbose comment here

@matyasf
matyasf requested a review from git-nandor September 3, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants