@plumeria/codemod 18.2.17 → 18.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -0
- package/dist/cli.js +76 -4
- package/dist/release.d.ts +23 -0
- package/dist/release.js +293 -0
- package/dist/resolve.d.ts +2 -0
- package/dist/resolve.js +104 -0
- package/dist/transforms/from-plumeria.d.ts +45 -0
- package/dist/transforms/from-plumeria.js +555 -0
- package/dist/transforms/release-styles.d.ts +26 -0
- package/dist/transforms/release-styles.js +430 -0
- package/package.json +4 -2
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.releaseStyles = exports.__private = void 0;
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
|
+
const resolve_1 = require("../resolve");
|
|
39
|
+
const memberPath = (node) => {
|
|
40
|
+
if (node?.type === 'Identifier')
|
|
41
|
+
return [node.name];
|
|
42
|
+
if (node?.type !== 'MemberExpression')
|
|
43
|
+
return undefined;
|
|
44
|
+
const parent = memberPath(node.object);
|
|
45
|
+
const key = node.computed
|
|
46
|
+
? node.property.type === 'Literal'
|
|
47
|
+
? String(node.property.value)
|
|
48
|
+
: undefined
|
|
49
|
+
: node.property.name;
|
|
50
|
+
return parent && key !== undefined ? [...parent, key] : undefined;
|
|
51
|
+
};
|
|
52
|
+
const isCreate = (node) => {
|
|
53
|
+
if (node?.type !== 'CallExpression')
|
|
54
|
+
return false;
|
|
55
|
+
const path = memberPath(node.callee);
|
|
56
|
+
return path?.length === 2 && path[1] === 'create';
|
|
57
|
+
};
|
|
58
|
+
const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
59
|
+
const needsFilter = (node) => node.type === 'LogicalExpression' ||
|
|
60
|
+
node.type === 'ConditionalExpression' ||
|
|
61
|
+
node.type === 'SpreadElement';
|
|
62
|
+
exports.__private = { memberPath, isCreate, needsFilter };
|
|
63
|
+
exports.releaseStyles = {
|
|
64
|
+
meta: {
|
|
65
|
+
type: 'suggestion',
|
|
66
|
+
docs: {
|
|
67
|
+
description: 'Replace Plumeria style definitions and usages with a generated CSS Module',
|
|
68
|
+
},
|
|
69
|
+
fixable: 'code',
|
|
70
|
+
messages: {
|
|
71
|
+
definition: 'Import the generated CSS Module.',
|
|
72
|
+
static: '`createStatic` values were inlined into the generated CSS.',
|
|
73
|
+
theme: '`createTheme` was written to the global stylesheet.',
|
|
74
|
+
themeImport: 'Remove the createTheme import after inlining its CSS variables.',
|
|
75
|
+
animation: '`keyframes` or `viewTransition` was written globally.',
|
|
76
|
+
animationImport: 'Remove the animation import after replacing it with its generated name.',
|
|
77
|
+
staticImport: 'Remove the createStatic import after inlining its values into the CSS.',
|
|
78
|
+
alias: 'Read this style from the CSS Module the whole file was exported to.',
|
|
79
|
+
core: 'Remove the Plumeria import after exporting the styles.',
|
|
80
|
+
prop: 'Use className after exporting this style to CSS Modules.',
|
|
81
|
+
composition: 'Join the composed CSS Module class names.',
|
|
82
|
+
functionStyle: 'Use the CSS Module class and pass function arguments as custom properties.',
|
|
83
|
+
unsupportedFunctionStyle: 'This function style call cannot be converted without changing its behavior.',
|
|
84
|
+
},
|
|
85
|
+
schema: [
|
|
86
|
+
{
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
modules: { type: 'object' },
|
|
90
|
+
themes: { type: 'object' },
|
|
91
|
+
animations: { type: 'object' },
|
|
92
|
+
statics: { type: 'object' },
|
|
93
|
+
styleProp: { type: 'string' },
|
|
94
|
+
active: { type: 'boolean' },
|
|
95
|
+
},
|
|
96
|
+
additionalProperties: false,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
create(context) {
|
|
101
|
+
const raw = (context.options[0] ?? {});
|
|
102
|
+
const declared = raw.modules?.[context.filename];
|
|
103
|
+
const entry = declared?.definitionOnly ? undefined : declared;
|
|
104
|
+
const themeBindings = raw.themes?.[context.filename] ?? [];
|
|
105
|
+
const animationBindings = raw.animations?.[context.filename] ?? [];
|
|
106
|
+
const styleProp = raw.styleProp ?? 'classStyle';
|
|
107
|
+
const sourceCode = context.sourceCode;
|
|
108
|
+
let active = Boolean(entry || raw.active);
|
|
109
|
+
let activeModule = entry;
|
|
110
|
+
const specifierFor = (module) => {
|
|
111
|
+
if (!module.target)
|
|
112
|
+
return module.source;
|
|
113
|
+
const relative = path
|
|
114
|
+
.relative(path.dirname(context.filename), module.target)
|
|
115
|
+
.split(path.sep)
|
|
116
|
+
.join('/');
|
|
117
|
+
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
118
|
+
};
|
|
119
|
+
const importOf = (specifiers, source) => {
|
|
120
|
+
const defaultImport = specifiers.find((specifier) => specifier.type === 'ImportDefaultSpecifier');
|
|
121
|
+
const namedImports = specifiers.filter((specifier) => specifier.type === 'ImportSpecifier');
|
|
122
|
+
const clauses = [];
|
|
123
|
+
if (defaultImport)
|
|
124
|
+
clauses.push(sourceCode.getText(defaultImport));
|
|
125
|
+
if (namedImports.length > 0) {
|
|
126
|
+
clauses.push(`{ ${namedImports
|
|
127
|
+
.map((specifier) => sourceCode.getText(specifier))
|
|
128
|
+
.join(', ')} }`);
|
|
129
|
+
}
|
|
130
|
+
return `import ${clauses.join(', ')} from ${sourceCode.getText(source)};`;
|
|
131
|
+
};
|
|
132
|
+
const importedFrom = (specifier, table) => {
|
|
133
|
+
const resolved = (0, resolve_1.resolveSourcePath)(specifier, context.filename);
|
|
134
|
+
return resolved ? table?.[resolved] : undefined;
|
|
135
|
+
};
|
|
136
|
+
const importedReleasedModule = (specifier) => importedFrom(specifier, raw.modules);
|
|
137
|
+
const importedThemeBindings = (specifier) => importedFrom(specifier, raw.themes);
|
|
138
|
+
const importedAnimationBindings = (specifier) => importedFrom(specifier, raw.animations);
|
|
139
|
+
const importedStaticBindings = (specifier) => importedFrom(specifier, raw.statics);
|
|
140
|
+
const releasedRange = () => {
|
|
141
|
+
if (!entry)
|
|
142
|
+
return undefined;
|
|
143
|
+
for (const statement of sourceCode.ast.body) {
|
|
144
|
+
const declaration = statement.type === 'ExportNamedDeclaration'
|
|
145
|
+
? statement.declaration
|
|
146
|
+
: statement;
|
|
147
|
+
if (declaration?.type !== 'VariableDeclaration')
|
|
148
|
+
continue;
|
|
149
|
+
for (const candidate of declaration.declarations) {
|
|
150
|
+
if (candidate.id.type === 'Identifier' &&
|
|
151
|
+
candidate.id.name === entry.binding &&
|
|
152
|
+
isCreate(candidate.init))
|
|
153
|
+
return statement.range;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
};
|
|
158
|
+
const onlyUsedByReleasedStyles = (local) => {
|
|
159
|
+
const range = releasedRange();
|
|
160
|
+
if (!range)
|
|
161
|
+
return false;
|
|
162
|
+
const scope = sourceCode.getScope(sourceCode.ast);
|
|
163
|
+
const moduleScope = scope.type === 'global' ? (scope.childScopes[0] ?? scope) : scope;
|
|
164
|
+
const variable = moduleScope.variables.find((candidate) => candidate.name === local);
|
|
165
|
+
if (!variable || variable.references.length === 0)
|
|
166
|
+
return false;
|
|
167
|
+
return variable.references.every((reference) => reference.identifier.range[0] >= range[0] &&
|
|
168
|
+
reference.identifier.range[1] <= range[1]);
|
|
169
|
+
};
|
|
170
|
+
const removeImportedBindings = (node, bindings, messageId, dead) => {
|
|
171
|
+
const removed = node.specifiers.filter((specifier) => {
|
|
172
|
+
if (specifier.type !== 'ImportSpecifier')
|
|
173
|
+
return false;
|
|
174
|
+
const name = specifier.imported.name ?? specifier.imported.value;
|
|
175
|
+
return bindings.includes(name) && (!dead || dead(specifier));
|
|
176
|
+
});
|
|
177
|
+
if (removed.length === 0)
|
|
178
|
+
return false;
|
|
179
|
+
const retained = node.specifiers.filter((specifier) => !removed.includes(specifier));
|
|
180
|
+
context.report({
|
|
181
|
+
node,
|
|
182
|
+
messageId,
|
|
183
|
+
fix: (fixer) => retained.length === 0
|
|
184
|
+
? fixer.remove(node)
|
|
185
|
+
: fixer.replaceText(node, importOf(retained, node.source)),
|
|
186
|
+
});
|
|
187
|
+
return true;
|
|
188
|
+
};
|
|
189
|
+
return {
|
|
190
|
+
ImportDeclaration(node) {
|
|
191
|
+
if ((entry || themeBindings.length > 0 || animationBindings.length > 0) &&
|
|
192
|
+
node.source.value === '@plumeria/core') {
|
|
193
|
+
context.report({
|
|
194
|
+
node,
|
|
195
|
+
messageId: 'core',
|
|
196
|
+
fix: (fixer) => fixer.remove(node),
|
|
197
|
+
});
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const importedAnimations = importedAnimationBindings(String(node.source.value));
|
|
201
|
+
if (importedAnimations) {
|
|
202
|
+
if (removeImportedBindings(node, importedAnimations, 'animationImport'))
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const importedThemes = importedThemeBindings(String(node.source.value));
|
|
206
|
+
if (importedThemes) {
|
|
207
|
+
if (removeImportedBindings(node, importedThemes, 'themeImport'))
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const importedStatics = importedStaticBindings(String(node.source.value));
|
|
211
|
+
if (importedStatics) {
|
|
212
|
+
if (removeImportedBindings(node, importedStatics, 'staticImport', (specifier) => onlyUsedByReleasedStyles(specifier.local.name)))
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const importedModule = importedReleasedModule(String(node.source.value));
|
|
216
|
+
if (importedModule) {
|
|
217
|
+
active = true;
|
|
218
|
+
const importedBinding = node.specifiers.find((specifier) => specifier.type === 'ImportSpecifier' &&
|
|
219
|
+
(specifier.imported.name ?? specifier.imported.value) ===
|
|
220
|
+
importedModule.binding);
|
|
221
|
+
const local = importedBinding?.local.name ?? importedModule.binding;
|
|
222
|
+
activeModule = { ...importedModule, binding: local };
|
|
223
|
+
if (importedModule.definitionOnly && importedBinding) {
|
|
224
|
+
const retained = node.specifiers.filter((specifier) => specifier !== importedBinding);
|
|
225
|
+
const released = `import ${local} from '${specifierFor(importedModule)}';`;
|
|
226
|
+
context.report({
|
|
227
|
+
node,
|
|
228
|
+
messageId: 'definition',
|
|
229
|
+
fix: (fixer) => fixer.replaceText(node, retained.length === 0
|
|
230
|
+
? released
|
|
231
|
+
: `${released}\n${importOf(retained, node.source)}`),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
VariableDeclaration(node) {
|
|
237
|
+
if (node.declarations.length !== 1)
|
|
238
|
+
return;
|
|
239
|
+
const declaration = node.declarations[0];
|
|
240
|
+
if (declaration.id.type !== 'Identifier')
|
|
241
|
+
return;
|
|
242
|
+
const path = declaration.init?.type === 'CallExpression'
|
|
243
|
+
? memberPath(declaration.init.callee)
|
|
244
|
+
: undefined;
|
|
245
|
+
if (path?.length === 2 &&
|
|
246
|
+
((entry && path[1] === 'createStatic') ||
|
|
247
|
+
(path[1] === 'createTheme' &&
|
|
248
|
+
themeBindings.includes(declaration.id.name)) ||
|
|
249
|
+
((path[1] === 'keyframes' || path[1] === 'viewTransition') &&
|
|
250
|
+
animationBindings.includes(declaration.id.name)))) {
|
|
251
|
+
const target = node.parent?.type === 'ExportNamedDeclaration' ? node.parent : node;
|
|
252
|
+
context.report({
|
|
253
|
+
node: target,
|
|
254
|
+
messageId: path[1] === 'createTheme'
|
|
255
|
+
? 'theme'
|
|
256
|
+
: path[1] === 'keyframes' || path[1] === 'viewTransition'
|
|
257
|
+
? 'animation'
|
|
258
|
+
: 'static',
|
|
259
|
+
fix: (fixer) => fixer.remove(target),
|
|
260
|
+
});
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (!entry)
|
|
264
|
+
return;
|
|
265
|
+
if (!isCreate(declaration.init))
|
|
266
|
+
return;
|
|
267
|
+
if (entry.aliases?.[declaration.id.name]) {
|
|
268
|
+
const aliased = node.parent?.type === 'ExportNamedDeclaration' ? node.parent : node;
|
|
269
|
+
context.report({
|
|
270
|
+
node: aliased,
|
|
271
|
+
messageId: 'definition',
|
|
272
|
+
fix: (fixer) => fixer.remove(aliased),
|
|
273
|
+
});
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (declaration.id.name !== entry.binding)
|
|
277
|
+
return;
|
|
278
|
+
const exported = node.parent?.type === 'ExportNamedDeclaration';
|
|
279
|
+
const target = exported ? node.parent : node;
|
|
280
|
+
const imported = `import ${entry.binding} from '${entry.source}';`;
|
|
281
|
+
const replacement = exported
|
|
282
|
+
? `${imported}\nexport { ${entry.binding} };`
|
|
283
|
+
: imported;
|
|
284
|
+
context.report({
|
|
285
|
+
node: target,
|
|
286
|
+
messageId: 'definition',
|
|
287
|
+
fix: (fixer) => fixer.replaceText(target, replacement),
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
MemberExpression(node) {
|
|
291
|
+
if (!entry?.aliases || node.object.type !== 'Identifier')
|
|
292
|
+
return;
|
|
293
|
+
const alias = entry.aliases[node.object.name];
|
|
294
|
+
if (!alias)
|
|
295
|
+
return;
|
|
296
|
+
const key = node.computed
|
|
297
|
+
? node.property.type === 'Literal'
|
|
298
|
+
? String(node.property.value)
|
|
299
|
+
: undefined
|
|
300
|
+
: node.property.name;
|
|
301
|
+
const className = key ? alias[key] : undefined;
|
|
302
|
+
if (!className)
|
|
303
|
+
return;
|
|
304
|
+
const access = IDENTIFIER.test(className)
|
|
305
|
+
? `.${className}`
|
|
306
|
+
: `['${className}']`;
|
|
307
|
+
context.report({
|
|
308
|
+
node,
|
|
309
|
+
messageId: 'alias',
|
|
310
|
+
fix: (fixer) => fixer.replaceText(node, `${entry.binding}${access}`),
|
|
311
|
+
});
|
|
312
|
+
},
|
|
313
|
+
JSXAttribute(node) {
|
|
314
|
+
if (!active)
|
|
315
|
+
return;
|
|
316
|
+
if (node.name.type !== 'JSXIdentifier' || node.name.name !== styleProp)
|
|
317
|
+
return;
|
|
318
|
+
const expression = node.value?.type === 'JSXExpressionContainer'
|
|
319
|
+
? node.value.expression
|
|
320
|
+
: undefined;
|
|
321
|
+
const moduleInfo = activeModule;
|
|
322
|
+
const readsModule = (callee) => Boolean(moduleInfo &&
|
|
323
|
+
callee?.type === 'MemberExpression' &&
|
|
324
|
+
callee.object.type === 'Identifier' &&
|
|
325
|
+
(callee.object.name === moduleInfo.binding ||
|
|
326
|
+
moduleInfo.aliases?.[callee.object.name]));
|
|
327
|
+
const styleKey = (callee) => {
|
|
328
|
+
if (!readsModule(callee))
|
|
329
|
+
return undefined;
|
|
330
|
+
const raw = callee.computed
|
|
331
|
+
? callee.property.type === 'Literal'
|
|
332
|
+
? String(callee.property.value)
|
|
333
|
+
: undefined
|
|
334
|
+
: callee.property.name;
|
|
335
|
+
if (raw === undefined)
|
|
336
|
+
return undefined;
|
|
337
|
+
const alias = moduleInfo.aliases?.[callee.object.name];
|
|
338
|
+
return alias ? alias[raw] : raw;
|
|
339
|
+
};
|
|
340
|
+
const functionStyle = (value) => {
|
|
341
|
+
if (!moduleInfo || value?.type !== 'CallExpression')
|
|
342
|
+
return undefined;
|
|
343
|
+
const key = styleKey(value.callee);
|
|
344
|
+
const func = key ? moduleInfo.functions?.[key] : undefined;
|
|
345
|
+
if (!key || !func || func.variables.length !== value.arguments.length)
|
|
346
|
+
return undefined;
|
|
347
|
+
const access = IDENTIFIER.test(key) ? `.${key}` : `['${key}']`;
|
|
348
|
+
return {
|
|
349
|
+
className: `${moduleInfo.binding}${access}`,
|
|
350
|
+
declarations: func.variables.map((variable, index) => {
|
|
351
|
+
const argument = sourceCode.getText(value.arguments[index]);
|
|
352
|
+
return `'${variable}': ${argument}`;
|
|
353
|
+
}),
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
const replaceWithFunctionStyle = (className, declarations) => {
|
|
357
|
+
const styleAttribute = node.parent.attributes.find((attribute) => attribute.type === 'JSXAttribute' &&
|
|
358
|
+
attribute.name.type === 'JSXIdentifier' &&
|
|
359
|
+
attribute.name.name === 'style');
|
|
360
|
+
const classReplacement = `className={${className}}`;
|
|
361
|
+
if (styleAttribute?.value?.type === 'JSXExpressionContainer' &&
|
|
362
|
+
styleAttribute.value.expression.type !== 'JSXEmptyExpression') {
|
|
363
|
+
const existing = sourceCode.getText(styleAttribute.value.expression);
|
|
364
|
+
const merged = styleAttribute.value.expression.type === 'ObjectExpression'
|
|
365
|
+
? `{ ...${existing}, ${declarations.join(', ')} }`
|
|
366
|
+
: `{ ...(${existing}), ${declarations.join(', ')} }`;
|
|
367
|
+
context.report({
|
|
368
|
+
node,
|
|
369
|
+
messageId: 'functionStyle',
|
|
370
|
+
fix: (fixer) => [
|
|
371
|
+
fixer.replaceText(node, classReplacement),
|
|
372
|
+
fixer.replaceText(styleAttribute.value.expression, merged),
|
|
373
|
+
],
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
context.report({
|
|
378
|
+
node,
|
|
379
|
+
messageId: 'functionStyle',
|
|
380
|
+
fix: (fixer) => fixer.replaceText(node, `${classReplacement} style={{ ${declarations.join(', ')} }}`),
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
const directFunction = functionStyle(expression);
|
|
385
|
+
if (directFunction) {
|
|
386
|
+
replaceWithFunctionStyle(directFunction.className, directFunction.declarations);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (expression?.type === 'CallExpression' &&
|
|
390
|
+
readsModule(expression.callee)) {
|
|
391
|
+
context.report({
|
|
392
|
+
node,
|
|
393
|
+
messageId: 'unsupportedFunctionStyle',
|
|
394
|
+
});
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (expression?.type === 'ArrayExpression') {
|
|
398
|
+
const elements = expression.elements.filter(Boolean);
|
|
399
|
+
if (elements.length > 0) {
|
|
400
|
+
const declarations = [];
|
|
401
|
+
const texts = elements.map((element) => {
|
|
402
|
+
const resolved = functionStyle(element);
|
|
403
|
+
if (!resolved)
|
|
404
|
+
return sourceCode.getText(element);
|
|
405
|
+
declarations.push(...resolved.declarations);
|
|
406
|
+
return resolved.className;
|
|
407
|
+
});
|
|
408
|
+
const replacement = elements.some(needsFilter)
|
|
409
|
+
? `[${texts.join(', ')}].filter(Boolean).join(' ')`
|
|
410
|
+
: `\`${texts.map((text) => `\${${text}}`).join(' ')}\``;
|
|
411
|
+
if (declarations.length > 0) {
|
|
412
|
+
replaceWithFunctionStyle(replacement, declarations);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
context.report({
|
|
416
|
+
node: expression,
|
|
417
|
+
messageId: 'composition',
|
|
418
|
+
fix: (fixer) => fixer.replaceText(expression, replacement),
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
context.report({
|
|
423
|
+
node: node.name,
|
|
424
|
+
messageId: 'prop',
|
|
425
|
+
fix: (fixer) => fixer.replaceText(node.name, 'className'),
|
|
426
|
+
});
|
|
427
|
+
},
|
|
428
|
+
};
|
|
429
|
+
},
|
|
430
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/codemod",
|
|
3
|
-
"version": "18.2.
|
|
3
|
+
"version": "18.2.19",
|
|
4
4
|
"description": "Codemods for migrating Plumeria APIs",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,8 +34,10 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@typescript-eslint/parser": "^8.60.0",
|
|
36
36
|
"eslint": "^10.4.1",
|
|
37
|
+
"get-tsconfig": "^4.14.2",
|
|
37
38
|
"postcss": "8.5.25",
|
|
38
|
-
"postcss-selector-parser": "^7.1.1"
|
|
39
|
+
"postcss-selector-parser": "^7.1.1",
|
|
40
|
+
"zss-engine": "2.6.0"
|
|
39
41
|
},
|
|
40
42
|
"publishConfig": {
|
|
41
43
|
"access": "public",
|