Skip to content

Commit 94a5fe3

Browse files
iOvergaardclaude
andcommitted
chore: fix pre-existing formatting issues
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent de3f244 commit 94a5fe3

7 files changed

Lines changed: 74 additions & 36 deletions

File tree

scripts/codemods/test.mjs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,21 @@ describe('v2.0.0/update-imports', async () => {
2828

2929
it('transforms fixture correctly', () => {
3030
const input = readFileSync(
31-
resolve(__dirname, 'v2.0.0', '__testfixtures__', 'update-imports.input.ts'),
31+
resolve(
32+
__dirname,
33+
'v2.0.0',
34+
'__testfixtures__',
35+
'update-imports.input.ts',
36+
),
3237
'utf-8',
3338
);
3439
const expected = readFileSync(
35-
resolve(__dirname, 'v2.0.0', '__testfixtures__', 'update-imports.output.ts'),
40+
resolve(
41+
__dirname,
42+
'v2.0.0',
43+
'__testfixtures__',
44+
'update-imports.output.ts',
45+
),
3646
'utf-8',
3747
);
3848
assert.equal(applyTransform(transform, input).trim(), expected.trim());
@@ -48,7 +58,9 @@ describe('v2.0.0/update-imports', async () => {
4858
transform,
4959
`import { UUIButtonElement } from '@umbraco-ui/uui-button/lib/uui-button.element';`,
5060
);
51-
assert.ok(out.includes(`'@umbraco-ui/uui/components/button/button.element.js'`));
61+
assert.ok(
62+
out.includes(`'@umbraco-ui/uui/components/button/button.element.js'`),
63+
);
5264
});
5365

5466
it('maps uui-base to barrel', () => {
@@ -112,7 +124,8 @@ describe('v2.0.0/update-imports', async () => {
112124
});
113125

114126
it('rewrites paths inside template literals', () => {
115-
const input = 'const t = html`<link href="node_modules/@umbraco-ui/uui-css/dist/uui-css.css">`;';
127+
const input =
128+
'const t = html`<link href="node_modules/@umbraco-ui/uui-css/dist/uui-css.css">`;';
116129
const out = applyTransform(transform, input);
117130
assert.ok(out.includes('@umbraco-ui/uui/dist/themes/light.css'));
118131
});

scripts/codemods/v2.0.0/__testfixtures__/update-imports.input.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ const fontDir = 'node_modules/@umbraco-ui/uui-css/assets/fonts';
4747
const fontGlob = 'node_modules/@umbraco-ui/uui-css/assets/fonts/*';
4848

4949
// Template literal with <link> tag
50-
const tpl = html`<link rel="stylesheet" href="node_modules/@umbraco-ui/uui-css/dist/uui-css.css" />`;
50+
const tpl = html`<link
51+
rel="stylesheet"
52+
href="node_modules/@umbraco-ui/uui-css/dist/uui-css.css" />`;

scripts/codemods/v2.0.0/__testfixtures__/update-imports.output.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ const fontDir = 'node_modules/@umbraco-ui/uui/dist/assets/fonts';
4040
const fontGlob = 'node_modules/@umbraco-ui/uui/dist/assets/fonts/*';
4141

4242
// Template literal with <link> tag
43-
const tpl = html`<link rel="stylesheet" href="node_modules/@umbraco-ui/uui/dist/themes/light.css" />`;
43+
const tpl = html`<link
44+
rel="stylesheet"
45+
href="node_modules/@umbraco-ui/uui/dist/themes/light.css" />`;

scripts/codemods/v2.0.0/update-imports.ts

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import type { API, FileInfo, Options, ASTPath, ImportDeclaration } from 'jscodeshift';
1+
import type {
2+
API,
3+
FileInfo,
4+
Options,
5+
ASTPath,
6+
ImportDeclaration,
7+
} from 'jscodeshift';
28

39
const REMOVED_COMPONENTS: Record<string, string> = {
410
'uui-caret': 'uui-symbol-expand',
@@ -17,8 +23,9 @@ function mapSource(source: string): MapResult {
1723
}
1824

1925
// Match @umbraco-ui/uui-{name} with optional /lib/{file} (strip trailing .js)
20-
const match =
21-
/^@umbraco-ui\/uui-([^/]+?)(?:\/lib\/(.+?)(?:\.js)?)?$/.exec(source);
26+
const match = /^@umbraco-ui\/uui-([^/]+?)(?:\/lib\/(.+?)(?:\.js)?)?$/.exec(
27+
source,
28+
);
2229
if (!match) return { target: null };
2330

2431
const [, name, libFile] = match;
@@ -172,35 +179,39 @@ export default function transform(
172179
// --- Dynamic imports: import('...') ---
173180
// tsx parser: CallExpression with callee.type === 'Import'
174181

175-
root
176-
.find(j.CallExpression, { callee: { type: 'Import' } })
177-
.forEach(path => {
178-
const arg = path.node.arguments[0];
179-
if (!arg) return;
180-
181-
let source: string | null = null;
182-
if (arg.type === 'StringLiteral') {
183-
source = arg.value;
184-
} else if (arg.type === 'Literal' && typeof arg.value === 'string') {
185-
source = arg.value;
186-
}
182+
root.find(j.CallExpression, { callee: { type: 'Import' } }).forEach(path => {
183+
const arg = path.node.arguments[0];
184+
if (!arg) return;
187185

188-
if (!source) return;
186+
let source: string | null = null;
187+
if (arg.type === 'StringLiteral') {
188+
source = arg.value;
189+
} else if (arg.type === 'Literal' && typeof arg.value === 'string') {
190+
source = arg.value;
191+
}
189192

190-
const result = mapSource(source);
191-
if (result.warning) warnings.push(result.warning);
192-
if (result.target) {
193-
arg.value = result.target;
194-
hasChanges = true;
195-
}
196-
});
193+
if (!source) return;
194+
195+
const result = mapSource(source);
196+
if (result.warning) warnings.push(result.warning);
197+
if (result.target) {
198+
arg.value = result.target;
199+
hasChanges = true;
200+
}
201+
});
197202

198203
// --- Path-based references (string literals in configs, template literals in HTML) ---
199204
// Handles e.g. vite-plugin-static-copy targets and <link> tags in Lit templates.
200205

201206
const PATH_REPLACEMENTS: [RegExp, string][] = [
202-
[/@umbraco-ui\/uui-css\/dist\/uui-css\.css/g, '@umbraco-ui/uui/dist/themes/light.css'],
203-
[/@umbraco-ui\/uui-css\/assets\/fonts/g, '@umbraco-ui/uui/dist/assets/fonts'],
207+
[
208+
/@umbraco-ui\/uui-css\/dist\/uui-css\.css/g,
209+
'@umbraco-ui/uui/dist/themes/light.css',
210+
],
211+
[
212+
/@umbraco-ui\/uui-css\/assets\/fonts/g,
213+
'@umbraco-ui/uui/dist/assets/fonts',
214+
],
204215
];
205216

206217
function rewritePaths(value: string): string | null {

src/components/form/form.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ describe('UUIFormElement', () => {
7474

7575
await listener;
7676
await expect(formElement.hasAttribute('submit-invalid')).to.equal(true);
77-
await expect(formElement.getAttribute('submit-invalid')).to.not.equal(null);
77+
await expect(formElement.getAttribute('submit-invalid')).to.not.equal(
78+
null,
79+
);
7880
await expect(formElement.getAttribute('submit-invalid')).to.equal('');
7981
});
8082

src/components/icon-registry/icon-registry.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ describe('UUIIconRegistryElement', () => {
5454
});
5555

5656
it('Child uui-icon retrieves the right SVG data through shadow-dom', () => {
57-
expect(iconElement.shadowRoot!.querySelector('#MyCustomIcon')).to.not.equal(null);
57+
expect(
58+
iconElement.shadowRoot!.querySelector('#MyCustomIcon'),
59+
).to.not.equal(null);
5860
});
5961
});
6062

@@ -91,7 +93,9 @@ describe('UUIIconRegistryElement', () => {
9193

9294
it('Child uui-icon retrieves the custom SVG data', async () => {
9395
await elementUpdated(iconElement);
94-
expect(iconElement.shadowRoot!.querySelector('#MyCustomIcon')).to.not.equal(null);
96+
expect(
97+
iconElement.shadowRoot!.querySelector('#MyCustomIcon'),
98+
).to.not.equal(null);
9599
});
96100
});
97101
});

src/components/icon/icon.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ describe('UUIIconElement', () => {
9898
});
9999

100100
it('contains svg of icon', () => {
101-
expect(element.shadowRoot!.querySelector('#TestFallbackIcon')).to.not.equal(null);
101+
expect(
102+
element.shadowRoot!.querySelector('#TestFallbackIcon'),
103+
).to.not.equal(null);
102104
});
103105

104106
it('passes the a11y audit', async () => {
@@ -176,7 +178,9 @@ describe('UUIIconElement', () => {
176178
});
177179

178180
it('Child uui-icon retrieves icon of registry', () => {
179-
expect(iconElement.shadowRoot!.querySelector('#TestIcon')).to.not.equal(null);
181+
expect(iconElement.shadowRoot!.querySelector('#TestIcon')).to.not.equal(
182+
null,
183+
);
180184
});
181185
});
182186

0 commit comments

Comments
 (0)