Commit 9aa3b7d
committed
fix(lint): address review on the Oxlint plugin API rewrite
Seven fixes from review on #2328.
Correctness of the rewrite:
- A statement that mixes the two `oxlint` surfaces, such as
`import { defineConfig, defineRule } from 'oxlint'`, is now left alone.
The rewrite replaces the whole specifier, so moving it stripped
`defineConfig` of its module. Splitting is the user's call.
- `require('@oxlint/plugins')` and `require('oxlint/plugins-dev')` no
longer rewrite. The `vite-plus/lint/*` exports are ESM-only, so a
rewritten `require()` failed with ERR_PACKAGE_PATH_NOT_EXPORTED. Static
import, export, and dynamic `import()` still rewrite, because those
resolve through the `import` condition.
The published-plugin exemption, which did not work end to end:
- `rewritePackageJson` strips `oxlint` before the import rewriter reads the
manifests, so `SkipPackages::skip_oxlint` never saw the signal in a real
migration. `collectOxlintOwnerDirs` now captures it before the edit and
passes the directories through to the rewriter. Note that `skip_tsdown`
has the same latent flaw, since `tsdown` is also in `REMOVE_PACKAGES`;
this change does not touch it.
- `vp lint --fix` rewrote a published plugin's source unconditionally,
undoing the exemption the migration had just honored. The rule now checks
the nearest manifest, reusing the mtime-keyed cache shape already used
for `@nuxt/test-utils`.
- The `oxlint` peer entry is no longer stripped from a package that owns
the plugin API. A peer is a consumer contract, not a tool the package
runs, and removing it left the source importing a package the manifest
no longer declared.
- `declare module '@oxlint/plugins'` and the `oxlint` forms are preserved,
the same way the rule already preserves Vitest-family augmentations. The
re-exported types keep their upstream module identity, so a retargeted
augmentation stopped merging.
Cleanup:
- The migration now drops a dead `@oxlint/plugins` devDependency, since
nothing imports it after the rewrite. Only from devDependencies: a
`dependencies` or `peerDependencies` edge marks a published plugin.
Tests: 3 Rust cases for the mixed, `require`, and dynamic-import rules; 8
lint-rule cases for the published-plugin and augmentation guards; and a new
`migration_oxlint_published_plugin` snapshot fixture covering the skip.1 parent cf00aad commit 9aa3b7d
17 files changed
Lines changed: 492 additions & 80 deletions
File tree
- crates
- vp_cli_snapshots/tests/cli_snapshots/fixtures
- migration_oxlint_js_plugin_imports
- snapshots
- migration_oxlint_published_plugin
- lint
- snapshots
- vp_migration/src
- packages/cli
- binding
- src
- src
- __tests__
- fixtures/oxlint-plugin-package
- migration/migrator
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
Lines changed: 14 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 | + | |
Lines changed: 13 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 | + | |
Lines changed: 20 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 | + | |
Lines changed: 63 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 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
1596 | 1596 | | |
1597 | 1597 | | |
1598 | 1598 | | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
1599 | 1604 | | |
1600 | 1605 | | |
1601 | 1606 | | |
1602 | 1607 | | |
1603 | 1608 | | |
1604 | | - | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
1605 | 1613 | | |
1606 | 1614 | | |
1607 | 1615 | | |
| |||
1639 | 1647 | | |
1640 | 1648 | | |
1641 | 1649 | | |
1642 | | - | |
1643 | | - | |
1644 | | - | |
1645 | | - | |
1646 | | - | |
1647 | | - | |
1648 | | - | |
1649 | | - | |
1650 | | - | |
1651 | | - | |
1652 | | - | |
1653 | | - | |
1654 | | - | |
1655 | | - | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
1660 | | - | |
1661 | | - | |
1662 | | - | |
1663 | 1650 | | |
1664 | 1651 | | |
1665 | 1652 | | |
| |||
1713 | 1700 | | |
1714 | 1701 | | |
1715 | 1702 | | |
1716 | | - | |
1717 | | - | |
1718 | | - | |
1719 | | - | |
1720 | | - | |
1721 | | - | |
1722 | | - | |
1723 | | - | |
1724 | | - | |
1725 | | - | |
1726 | | - | |
1727 | | - | |
1728 | | - | |
1729 | | - | |
1730 | | - | |
1731 | | - | |
1732 | | - | |
1733 | | - | |
1734 | | - | |
1735 | | - | |
1736 | | - | |
1737 | 1703 | | |
1738 | 1704 | | |
1739 | 1705 | | |
| |||
1763 | 1729 | | |
1764 | 1730 | | |
1765 | 1731 | | |
1766 | | - | |
1767 | | - | |
1768 | | - | |
1769 | | - | |
1770 | | - | |
1771 | | - | |
1772 | | - | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
1773 | 1743 | | |
1774 | 1744 | | |
1775 | 1745 | | |
| |||
2187 | 2157 | | |
2188 | 2158 | | |
2189 | 2159 | | |
2190 | | - | |
| 2160 | + | |
2191 | 2161 | | |
2192 | 2162 | | |
2193 | 2163 | | |
2194 | 2164 | | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
2195 | 2176 | | |
2196 | 2177 | | |
2197 | 2178 | | |
| |||
2406 | 2387 | | |
2407 | 2388 | | |
2408 | 2389 | | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
2409 | 2395 | | |
2410 | 2396 | | |
2411 | 2397 | | |
2412 | 2398 | | |
2413 | 2399 | | |
2414 | 2400 | | |
2415 | | - | |
| 2401 | + | |
2416 | 2402 | | |
2417 | | - | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
2418 | 2410 | | |
2419 | 2411 | | |
2420 | 2412 | | |
| |||
3379 | 3371 | | |
3380 | 3372 | | |
3381 | 3373 | | |
3382 | | - | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
3383 | 3378 | | |
3384 | 3379 | | |
3385 | 3380 | | |
| |||
3417 | 3412 | | |
3418 | 3413 | | |
3419 | 3414 | | |
3420 | | - | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
| 3418 | + | |
3421 | 3419 | | |
3422 | 3420 | | |
3423 | 3421 | | |
| |||
4028 | 4026 | | |
4029 | 4027 | | |
4030 | 4028 | | |
| 4029 | + | |
| 4030 | + | |
| 4031 | + | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
| 4035 | + | |
| 4036 | + | |
| 4037 | + | |
| 4038 | + | |
| 4039 | + | |
| 4040 | + | |
| 4041 | + | |
| 4042 | + | |
| 4043 | + | |
| 4044 | + | |
| 4045 | + | |
| 4046 | + | |
| 4047 | + | |
| 4048 | + | |
| 4049 | + | |
| 4050 | + | |
| 4051 | + | |
| 4052 | + | |
| 4053 | + | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
| 4060 | + | |
| 4061 | + | |
| 4062 | + | |
4031 | 4063 | | |
4032 | 4064 | | |
4033 | 4065 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3621 | 3621 | | |
3622 | 3622 | | |
3623 | 3623 | | |
| 3624 | + | |
3624 | 3625 | | |
3625 | 3626 | | |
3626 | 3627 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
293 | 294 | | |
294 | 295 | | |
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
298 | 304 | | |
299 | 305 | | |
300 | 306 | | |
| |||
0 commit comments