Commit 20b4ca0
committed
feat(migrate): preserve packages referenced via lint.jsPlugins
Before this commit, `rewriteEslintPackageJson` stripped every package
matching `isEslintEcosystemDep` — including ones `@oxlint/migrate` had
just referenced via `lint.jsPlugins`. Result: the generated config
listed `jsPlugins: ["eslint-plugin-foo"]` but the package was no
longer in `package.json`, so the sanitizer (or Oxlint at runtime)
would strip / fail to load it. Two passes in a row, two opposite
decisions about the same package.
Now the cleanup honors what `@oxlint/migrate` actually wrote:
1. After `@oxlint/migrate` produces `.oxlintrc.json`, collect every
string-form package name appearing in `lint.jsPlugins[]` (and in
each `overrides[].jsPlugins[]`), skipping local-path specifiers
(`./X`, `../X`, `/X`) which don't map to a `package.json` entry.
2. Pass that set to `rewriteEslintPackageJson` as `preserveJsPlugins`.
3. The cleanup loop skips removal for any name in that set — even
when it matches `isEslintEcosystemDep`'s named / prefix / scope /
scoped-regex patterns.
Net effect:
- User had `eslint-plugin-vue` in devDeps AND imported it from
`eslint.config.mjs` → `@oxlint/migrate` lists it in jsPlugins →
cleanup keeps it → sanitizer keeps it → `vp lint` actually loads
the plugin and runs its rules.
- User had `eslint-plugin-vue` in devDeps but didn't import it →
`@oxlint/migrate` doesn't list it → cleanup removes it as before
(no regression).
- `@oxlint/migrate` invented a reference to a package the user never
installed (the WeakAuras `eslint-plugin-unocss` case) → not in
devDeps, nothing to preserve → sanitizer still strips the orphan
reference + warns (no regression).
New snap-test `migration-eslint-jsplugins-preserve` exercises the
preserve path end-to-end: a fixture with `eslint-plugin-survives` in
devDeps + an inline `survives` plugin in `eslint.config.mjs`. After
migration, the package is still in devDeps, the jsPlugins reference is
intact in `vite.config.ts`, and the `survives/no-fiction` rule
survived in `lint.rules` — all without firing any "stripped" warning.
Three unit tests cover the API surface:
- preserveJsPlugins keeps named jsPlugins through cleanup
- preserveJsPlugins overrides every branch of isEslintEcosystemDep
(named / prefix / scope / scoped regex)
- empty preserveJsPlugins set behaves identically to no argument
(default-compatible, can't accidentally weaken cleanup for
existing callers)
No existing snap-test drifted.1 parent 21d581a commit 20b4ca0
6 files changed
Lines changed: 247 additions & 2 deletions
File tree
- packages/cli
- snap-tests-global/migration-eslint-jsplugins-preserve
- src/migration
- __tests__
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
546 | 624 | | |
547 | 625 | | |
548 | 626 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
332 | 341 | | |
333 | 342 | | |
334 | 343 | | |
| |||
346 | 355 | | |
347 | 356 | | |
348 | 357 | | |
349 | | - | |
| 358 | + | |
350 | 359 | | |
351 | 360 | | |
352 | 361 | | |
353 | 362 | | |
354 | 363 | | |
355 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
356 | 404 | | |
357 | 405 | | |
358 | 406 | | |
| |||
442 | 490 | | |
443 | 491 | | |
444 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
445 | 498 | | |
446 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
447 | 503 | | |
448 | 504 | | |
449 | 505 | | |
| |||
465 | 521 | | |
466 | 522 | | |
467 | 523 | | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
468 | 527 | | |
469 | 528 | | |
470 | 529 | | |
| |||
0 commit comments