ember-codemod-remove-ember-css-modules 4.0.1 → 4.0.2

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.
@@ -1,4 +1,4 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
1
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  import { AST } from '@codemod-utils/ast-javascript';
@@ -54,7 +54,7 @@ function importStylesInClass(file, data) {
54
54
  visitImportDeclaration(path) {
55
55
  if (!lastImportDeclarationPath) {
56
56
  lastImportDeclarationPath = path;
57
- // @ts-ignore: Assume that types from external packages are correct
57
+ // @ts-expect-error: Incorrect type
58
58
  }
59
59
  else if (path.node.start > lastImportDeclarationPath.node.start) {
60
60
  lastImportDeclarationPath = path;
@@ -63,9 +63,9 @@ function importStylesInClass(file, data) {
63
63
  },
64
64
  });
65
65
  // Append the styles import
66
- // @ts-ignore: Assume that types from external packages are correct
66
+ // @ts-expect-error: Incorrect type
67
67
  const nodes = ast.program.body;
68
- // @ts-ignore: Assume that types from external packages are correct
68
+ // @ts-expect-error: Incorrect type
69
69
  const index = lastImportDeclarationPath?.name ?? -1;
70
70
  nodes.splice(index + 1, 0, AST.builders.importDeclaration([AST.builders.importDefaultSpecifier(AST.builders.identifier('styles'))], AST.builders.literal(`./${data.fileName}.css`)));
71
71
  return AST.print(ast);
@@ -79,7 +79,7 @@ function addStylesAsClassProperty(file, data) {
79
79
  AST.builders.classProperty(AST.builders.identifier('styles'), AST.builders.identifier('styles')),
80
80
  ];
81
81
  if (body.length > 0) {
82
- // @ts-ignore: Assume that types from external packages are correct
82
+ // @ts-expect-error: Incorrect type
83
83
  nodesToAdd.push(AST.builders.noop());
84
84
  }
85
85
  body.unshift(...nodesToAdd);
@@ -1,4 +1,4 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/explicit-function-return-type */
1
+ /* eslint-disable @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  import { AST } from '@codemod-utils/ast-template';
@@ -6,22 +6,22 @@ import { createFiles } from '@codemod-utils/files';
6
6
  function sanitizeClassAndLocalClassAttributes(file) {
7
7
  function removeAttributeWithoutValue(attributeName, attributes) {
8
8
  const attributeIndex = attributes.findIndex(
9
- // @ts-ignore: Assume that types from external packages are correct
9
+ // @ts-expect-error: Incorrect type
10
10
  (attribute) => attribute.name === attributeName);
11
11
  if (attributeIndex === -1) {
12
12
  return;
13
13
  }
14
14
  const attribute = attributes[attributeIndex];
15
- // @ts-ignore: Assume that types from external packages are correct
15
+ // @ts-expect-error: Incorrect type
16
16
  if (attribute.isValueless) {
17
17
  attributes.splice(attributeIndex, 1);
18
18
  return;
19
19
  }
20
- // @ts-ignore: Assume that types from external packages are correct
20
+ // @ts-expect-error: Incorrect type
21
21
  if (attribute.value.type !== 'TextNode') {
22
22
  return;
23
23
  }
24
- // @ts-ignore: Assume that types from external packages are correct
24
+ // @ts-expect-error: Incorrect type
25
25
  const attributeValue = attribute.value.chars.trim();
26
26
  if (attributeValue === '') {
27
27
  attributes.splice(attributeIndex, 1);
@@ -90,14 +90,14 @@ function removeLocalClassHelpers(file) {
90
90
  to be a concatenated string or `undefined`.
91
91
  */
92
92
  function canRemoveLocalClassHelper(path) {
93
- // @ts-ignore: Assume that types from external packages are correct
93
+ // @ts-expect-error: Incorrect type
94
94
  const hasFromArgument = path.hash.pairs.some((pair) => pair.key === 'from');
95
95
  if (hasFromArgument) {
96
96
  throw new RangeError(
97
- // @ts-ignore: Assume that types from external packages are correct
97
+ // @ts-expect-error: Incorrect type
98
98
  `Unable to handle the {{local-class}} helper's \`from\` key. See lines ${path.loc.start.line}-${path.loc.end.line}.`);
99
99
  }
100
- // @ts-ignore: Assume that types from external packages are correct
100
+ // @ts-expect-error: Incorrect type
101
101
  const param = path.params[0];
102
102
  if (param === undefined) {
103
103
  return true;
@@ -110,13 +110,13 @@ function removeLocalClassHelpers(file) {
110
110
  }
111
111
  const traverse = AST.traverse();
112
112
  const ast = traverse(file, {
113
- // @ts-ignore: Assume that types from external packages are correct
113
+ // @ts-expect-error: Incorrect type
114
114
  AttrNode(node) {
115
115
  if (node.name !== 'class') {
116
116
  return;
117
117
  }
118
118
  const hasLocalClassHelper = node.value.type === 'MustacheStatement' &&
119
- // @ts-ignore: Assume that types from external packages are correct
119
+ // @ts-expect-error: Incorrect type
120
120
  node.value.path.original === 'local-class';
121
121
  if (!hasLocalClassHelper) {
122
122
  return;
@@ -124,7 +124,7 @@ function removeLocalClassHelpers(file) {
124
124
  if (canRemoveLocalClassHelper(node.value)) {
125
125
  return null;
126
126
  }
127
- // @ts-ignore: Assume that types from external packages are correct
127
+ // @ts-expect-error: Incorrect type
128
128
  const param = node.value.params[0];
129
129
  if (param.type !== 'StringLiteral') {
130
130
  return;
@@ -158,7 +158,7 @@ function removeLocalClassHelpers(file) {
158
158
  ]);
159
159
  },
160
160
  SubExpression(node) {
161
- // @ts-ignore: Assume that types from external packages are correct
161
+ // @ts-expect-error: Incorrect type
162
162
  const hasLocalClassHelper = node.path.original === 'local-class';
163
163
  if (!hasLocalClassHelper) {
164
164
  return;
@@ -184,13 +184,13 @@ function removeLocalClassHelpers(file) {
184
184
  }
185
185
  function removeLocalClassAttributes(file) {
186
186
  function transformParam(param) {
187
- // @ts-ignore: Assume that types from external packages are correct
187
+ // @ts-expect-error: Incorrect type
188
188
  switch (param.type) {
189
189
  case 'StringLiteral': {
190
- // @ts-ignore: Assume that types from external packages are correct
190
+ // @ts-expect-error: Incorrect type
191
191
  const localClassNames = param.value.trim().split(/\s+/);
192
192
  if (localClassNames.length === 1) {
193
- // @ts-ignore: Assume that types from external packages are correct
193
+ // @ts-expect-error: Incorrect type
194
194
  param.value = localClassNames[0];
195
195
  }
196
196
  else {
@@ -199,13 +199,13 @@ function removeLocalClassAttributes(file) {
199
199
  break;
200
200
  }
201
201
  case 'SubExpression': {
202
- // @ts-ignore: Assume that types from external packages are correct
202
+ // @ts-expect-error: Incorrect type
203
203
  switch (param.path.original) {
204
204
  case 'if':
205
205
  case 'unless': {
206
- // @ts-ignore: Assume that types from external packages are correct
206
+ // @ts-expect-error: Incorrect type
207
207
  const subparams = param.params.map(transformParam);
208
- // @ts-ignore: Assume that types from external packages are correct
208
+ // @ts-expect-error: Incorrect type
209
209
  param = AST.builders.sexpr(param.path.original, subparams);
210
210
  break;
211
211
  }
@@ -215,27 +215,27 @@ function removeLocalClassAttributes(file) {
215
215
  }
216
216
  return param;
217
217
  }
218
- // @ts-ignore: Assume that types from external packages are correct
218
+ // @ts-expect-error: Incorrect type
219
219
  function transformPart(part) {
220
- // @ts-ignore: Assume that types from external packages are correct
220
+ // @ts-expect-error: Incorrect type
221
221
  switch (part.type) {
222
222
  case 'MustacheStatement': {
223
- // @ts-ignore: Assume that types from external packages are correct
223
+ // @ts-expect-error: Incorrect type
224
224
  switch (part.path.original) {
225
225
  case 'concat': {
226
226
  function hasPathExpression(params) {
227
- // @ts-ignore: Assume that types from external packages are correct
227
+ // @ts-expect-error: Incorrect type
228
228
  return params.some((param) => param.type === 'PathExpression');
229
229
  }
230
- // @ts-ignore: Assume that types from external packages are correct
230
+ // @ts-expect-error: Incorrect type
231
231
  if (hasPathExpression(part.params)) {
232
232
  return AST.builders.mustache(AST.builders.path('get'), [
233
233
  AST.builders.path('this.styles'),
234
- // @ts-ignore: Assume that types from external packages are correct
234
+ // @ts-expect-error: Incorrect type
235
235
  AST.builders.sexpr(part.path.original, part.params),
236
236
  ]);
237
237
  }
238
- // @ts-ignore: Assume that types from external packages are correct
238
+ // @ts-expect-error: Incorrect type
239
239
  const params = part.params.map(transformParam);
240
240
  return AST.builders.mustache('local', [
241
241
  AST.builders.path('this.styles'),
@@ -244,25 +244,25 @@ function removeLocalClassAttributes(file) {
244
244
  }
245
245
  case 'if':
246
246
  case 'unless': {
247
- // @ts-ignore: Assume that types from external packages are correct
247
+ // @ts-expect-error: Incorrect type
248
248
  const params = part.params.map(transformParam);
249
249
  return AST.builders.mustache('local', [
250
250
  AST.builders.path('this.styles'),
251
- // @ts-ignore: Assume that types from external packages are correct
251
+ // @ts-expect-error: Incorrect type
252
252
  AST.builders.sexpr(part.path.original, params),
253
253
  ]);
254
254
  }
255
255
  default: {
256
256
  return AST.builders.mustache(AST.builders.path('get'), [
257
257
  AST.builders.path('this.styles'),
258
- // @ts-ignore: Assume that types from external packages are correct
258
+ // @ts-expect-error: Incorrect type
259
259
  part.path,
260
260
  ]);
261
261
  }
262
262
  }
263
263
  }
264
264
  case 'TextNode': {
265
- // @ts-ignore: Assume that types from external packages are correct
265
+ // @ts-expect-error: Incorrect type
266
266
  const value = part.chars.trim();
267
267
  if (value === '') {
268
268
  return part;
@@ -281,10 +281,10 @@ function removeLocalClassAttributes(file) {
281
281
  function transformParts(parts) {
282
282
  const numParts = parts.length;
283
283
  return parts.reduce((accumulator, part, index) => {
284
- // @ts-ignore: Assume that types from external packages are correct
284
+ // @ts-expect-error: Incorrect type
285
285
  accumulator.push(transformPart(part));
286
286
  if (index < numParts - 1) {
287
- // @ts-ignore: Assume that types from external packages are correct
287
+ // @ts-expect-error: Incorrect type
288
288
  accumulator.push(AST.builders.text(' '));
289
289
  }
290
290
  return accumulator;
@@ -304,19 +304,19 @@ function removeLocalClassAttributes(file) {
304
304
  switch (localClassAttribute.value.type) {
305
305
  case 'ConcatStatement': {
306
306
  localClassAttribute.name = 'class';
307
- // @ts-ignore: Assume that types from external packages are correct
307
+ // @ts-expect-error: Incorrect type
308
308
  localClassAttribute.value.parts = transformParts(localClassAttribute.value.parts);
309
309
  break;
310
310
  }
311
311
  case 'MustacheStatement': {
312
312
  localClassAttribute.name = 'class';
313
- // @ts-ignore: Assume that types from external packages are correct
313
+ // @ts-expect-error: Incorrect type
314
314
  localClassAttribute.value = transformPart(localClassAttribute.value);
315
315
  break;
316
316
  }
317
317
  case 'TextNode': {
318
318
  localClassAttribute.name = 'class';
319
- // @ts-ignore: Assume that types from external packages are correct
319
+ // @ts-expect-error: Incorrect type
320
320
  localClassAttribute.value = transformPart(localClassAttribute.value);
321
321
  break;
322
322
  }
@@ -328,16 +328,16 @@ function removeLocalClassAttributes(file) {
328
328
  }
329
329
  node.key = 'class';
330
330
  const newValue = transformParam(node.value);
331
- // @ts-ignore: Assume that types from external packages are correct
331
+ // @ts-expect-error: Incorrect type
332
332
  if (newValue.type === 'StringLiteral') {
333
333
  node.value = AST.builders.path(
334
- // @ts-ignore: Assume that types from external packages are correct
334
+ // @ts-expect-error: Incorrect type
335
335
  `this.styles.${newValue.value}`);
336
336
  return;
337
337
  }
338
338
  node.value = AST.builders.sexpr('local', [
339
339
  AST.builders.path('this.styles'),
340
- // @ts-ignore: Assume that types from external packages are correct
340
+ // @ts-expect-error: Incorrect type
341
341
  newValue,
342
342
  ]);
343
343
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-remove-ember-css-modules",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Codemod to replace ember-css-modules with embroider-css-modules",
5
5
  "keywords": [
6
6
  "codemod",
@@ -24,26 +24,26 @@
24
24
  "dist"
25
25
  ],
26
26
  "dependencies": {
27
- "@codemod-utils/ast-javascript": "^3.0.0",
28
- "@codemod-utils/ast-template": "^3.0.0",
29
- "@codemod-utils/blueprints": "^3.0.1",
30
- "@codemod-utils/ember": "^4.1.0",
31
- "@codemod-utils/files": "^4.0.0",
32
- "@codemod-utils/package-json": "^4.0.0",
27
+ "@codemod-utils/ast-javascript": "^3.0.1",
28
+ "@codemod-utils/ast-template": "^3.0.1",
29
+ "@codemod-utils/blueprints": "^3.0.2",
30
+ "@codemod-utils/ember": "^4.1.1",
31
+ "@codemod-utils/files": "^4.0.1",
32
+ "@codemod-utils/package-json": "^4.0.1",
33
33
  "yargs": "^18.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@codemod-utils/tests": "^3.0.0",
36
+ "@codemod-utils/tests": "^3.0.1",
37
37
  "@sondr3/minitest": "^0.1.2",
38
- "@types/node": "^22.19.11",
38
+ "@types/node": "^22.19.15",
39
39
  "@types/yargs": "^17.0.35",
40
40
  "concurrently": "^9.2.1",
41
- "eslint": "^9.39.2",
41
+ "eslint": "^9.39.4",
42
42
  "prettier": "^3.8.1",
43
43
  "typescript": "^5.9.3",
44
44
  "@shared-configs/eslint-config-node": "0.0.0",
45
- "@shared-configs/prettier": "0.0.0",
46
- "@shared-configs/typescript": "0.0.0"
45
+ "@shared-configs/typescript": "0.0.0",
46
+ "@shared-configs/prettier": "0.0.0"
47
47
  },
48
48
  "engines": {
49
49
  "node": "22.* || >= 24"