@next/codemod 16.0.2-canary.8 → 16.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next/codemod",
3
- "version": "16.0.2-canary.8",
3
+ "version": "16.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -113,7 +113,6 @@ function replaceFlatCompatInConfig(configPath) {
113
113
  const j = (0, parser_1.createParserFromPath)(configPath);
114
114
  const root = j(configContent);
115
115
  // Track if we need to add imports and preserve other configs
116
- let needsNext = false;
117
116
  let needsNextVitals = false;
118
117
  let needsNextTs = false;
119
118
  let otherConfigs = [];
@@ -129,10 +128,7 @@ function replaceFlatCompatInConfig(configPath) {
129
128
  // Check arguments for all configs
130
129
  node.arguments.forEach((arg) => {
131
130
  if (arg.type === 'Literal' || arg.type === 'StringLiteral') {
132
- if (arg.value === 'next') {
133
- needsNext = true;
134
- }
135
- else if (arg.value === 'next/core-web-vitals') {
131
+ if (arg.value === 'next/core-web-vitals') {
136
132
  needsNextVitals = true;
137
133
  }
138
134
  else if (arg.value === 'next/typescript') {
@@ -163,10 +159,7 @@ function replaceFlatCompatInConfig(configPath) {
163
159
  prop.value.elements?.forEach((element) => {
164
160
  if (element.type === 'Literal' ||
165
161
  element.type === 'StringLiteral') {
166
- if (element.value === 'next') {
167
- needsNext = true;
168
- }
169
- else if (element.value === 'next/core-web-vitals') {
162
+ if (element.value === 'next/core-web-vitals') {
170
163
  needsNextVitals = true;
171
164
  }
172
165
  else if (element.value === 'next/typescript') {
@@ -184,14 +177,11 @@ function replaceFlatCompatInConfig(configPath) {
184
177
  });
185
178
  }
186
179
  });
187
- if (!needsNext &&
188
- !needsNextVitals &&
189
- !needsNextTs &&
190
- otherConfigs.length === 0) {
180
+ if (!needsNextVitals && !needsNextTs && otherConfigs.length === 0) {
191
181
  console.warn(exports.prefixes.warn, ' No ESLint configs found in FlatCompat usage');
192
182
  return false;
193
183
  }
194
- if (!needsNext && !needsNextVitals && !needsNextTs) {
184
+ if (!needsNextVitals && !needsNextTs) {
195
185
  console.log(' No Next.js configs found, but preserving other configs');
196
186
  }
197
187
  // Only remove FlatCompat setup if no other configs need it
@@ -233,10 +223,7 @@ function replaceFlatCompatInConfig(configPath) {
233
223
  }
234
224
  // Add new imports after the eslint/config import
235
225
  const imports = [];
236
- // Add imports in correct order: next first, then core-web-vitals, then typescript
237
- if (needsNext) {
238
- imports.push(j.importDeclaration([j.importDefaultSpecifier(j.identifier('next'))], j.literal('eslint-config-next')));
239
- }
226
+ // Add imports in correct order: core-web-vitals first, then typescript
240
227
  if (needsNextVitals) {
241
228
  imports.push(j.importDeclaration([j.importDefaultSpecifier(j.identifier('nextCoreWebVitals'))], j.literal('eslint-config-next/core-web-vitals')));
242
229
  }
@@ -278,10 +265,7 @@ function replaceFlatCompatInConfig(configPath) {
278
265
  const replacements = [];
279
266
  node.argument.arguments.forEach((arg) => {
280
267
  if (arg.type === 'Literal' || arg.type === 'StringLiteral') {
281
- if (arg.value === 'next') {
282
- replacements.push(j.spreadElement(j.identifier('next')));
283
- }
284
- else if (arg.value === 'next/core-web-vitals') {
268
+ if (arg.value === 'next/core-web-vitals') {
285
269
  replacements.push(j.spreadElement(j.identifier('nextCoreWebVitals')));
286
270
  }
287
271
  else if (arg.value === 'next/typescript') {
@@ -327,10 +311,7 @@ function replaceFlatCompatInConfig(configPath) {
327
311
  prop.value.elements?.forEach((element) => {
328
312
  if (element.type === 'Literal' ||
329
313
  element.type === 'StringLiteral') {
330
- if (element.value === 'next') {
331
- replacements.push(j.spreadElement(j.identifier('next')));
332
- }
333
- else if (element.value === 'next/core-web-vitals') {
314
+ if (element.value === 'next/core-web-vitals') {
334
315
  replacements.push(j.spreadElement(j.identifier('nextCoreWebVitals')));
335
316
  }
336
317
  else if (element.value === 'next/typescript') {
@@ -389,10 +370,7 @@ function replaceFlatCompatInConfig(configPath) {
389
370
  const replacements = [];
390
371
  prop.value.arguments.forEach((arg) => {
391
372
  if (arg.type === 'Literal' || arg.type === 'StringLiteral') {
392
- if (arg.value === 'next') {
393
- replacements.push(j.spreadElement(j.identifier('next')));
394
- }
395
- else if (arg.value === 'next/core-web-vitals') {
373
+ if (arg.value === 'next/core-web-vitals') {
396
374
  replacements.push(j.spreadElement(j.identifier('nextCoreWebVitals')));
397
375
  }
398
376
  else if (arg.value === 'next/typescript') {
@@ -473,7 +451,6 @@ function updateExistingFlatConfig(configPath, isTypeScript = false) {
473
451
  return false;
474
452
  }
475
453
  // Check if Next.js configs are already imported directly
476
- const hasNext = configContent.includes('eslint-config-next');
477
454
  const hasNextVitals = configContent.includes('eslint-config-next/core-web-vitals');
478
455
  const hasNextTs = configContent.includes('eslint-config-next/typescript');
479
456
  const hasNextConfigs = hasNextVitals || hasNextTs;
@@ -533,9 +510,6 @@ function updateExistingFlatConfig(configPath, isTypeScript = false) {
533
510
  // Add Next.js imports if not present
534
511
  const program = root.find(j.Program);
535
512
  const imports = [];
536
- if (!hasNext) {
537
- imports.push(j.importDeclaration([j.importDefaultSpecifier(j.identifier('next'))], j.literal('eslint-config-next')));
538
- }
539
513
  if (!hasNextVitals) {
540
514
  imports.push(j.importDeclaration([j.importDefaultSpecifier(j.identifier('nextCoreWebVitals'))], j.literal('eslint-config-next/core-web-vitals')));
541
515
  }
@@ -551,9 +525,6 @@ function updateExistingFlatConfig(configPath, isTypeScript = false) {
551
525
  exportedArray.value.elements = [];
552
526
  }
553
527
  const spreadsToAdd = [];
554
- if (!hasNext) {
555
- spreadsToAdd.push(j.spreadElement(j.identifier('next')));
556
- }
557
528
  if (!hasNextVitals) {
558
529
  spreadsToAdd.push(j.spreadElement(j.identifier('nextCoreWebVitals')));
559
530
  }