Skip to content

Commit 371779b

Browse files
committed
feat!: add workspace alias for @antfu/eslint-config
- Introduced a new package `@antfu/eslint-config` to serve as a workspace alias for `@pixpilot/eslint-config`. - This allows test fixtures and configurations that import `@antfu/eslint-config` to function without modification. - Maintains compatibility with upstream changes while using a custom package name. - Updated `pnpm-workspace.yaml` and `pnpm-lock.yaml` to include the new alias package.
1 parent 1d0cec8 commit 371779b

File tree

8 files changed

+2134
-55
lines changed

8 files changed

+2134
-55
lines changed

FORK_TESTING_SOLUTION.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Package Name Fork Solution
2+
3+
This document explains how to maintain test compatibility when forking `@antfu/eslint-config` and changing the package name to `@pixpilot/eslint-config`.
4+
5+
## Problem
6+
7+
When you fork the original `@antfu/eslint-config` repository and change the package name in `package.json` to `@pixpilot/eslint-config`, the test fixtures fail because they still import `@antfu/eslint-config`.
8+
9+
## Solution: Workspace Package Alias
10+
11+
Instead of changing all test references (which would make merging upstream changes difficult), we create a **workspace package** that acts as an alias, redirecting `@antfu/eslint-config` imports to our local `@pixpilot/eslint-config` build.
12+
13+
### How It Works
14+
15+
1. **Main package**: Your `@pixpilot/eslint-config` builds to `dist/`
16+
2. **Workspace alias**: `packages/antfu-eslint-config/` contains a package named `@antfu/eslint-config` that re-exports your main package
17+
3. **PNPM workspace**: Both packages are part of the same workspace with `@antfu/eslint-config: workspace:*` dependency
18+
4. **Tests work**: Test fixtures import `@antfu/eslint-config` but get your `@pixpilot/eslint-config` code
19+
20+
### File Structure
21+
22+
```
23+
eslint-config/
24+
├── packages/
25+
│ └── antfu-eslint-config/
26+
│ ├── package.json # {"name": "@antfu/eslint-config"}
27+
│ └── index.js # Re-exports @pixpilot/eslint-config
28+
├── pnpm-workspace.yaml # includes "packages/*"
29+
├── package.json # "@antfu/eslint-config": "workspace:*"
30+
└── dist/ # Your built @pixpilot/eslint-config
31+
```
32+
33+
### Setup
34+
35+
The workspace package is already set up in this repository. Simply:
36+
37+
```bash
38+
# Install workspace dependencies
39+
pnpm install
40+
41+
# Build your package
42+
pnpm build
43+
44+
# Run tests (they'll work automatically!)
45+
pnpm test
46+
```
47+
48+
### Benefits
49+
50+
1. **Native PNPM support** - Uses official workspace features, no hacks
51+
2. **No code changes** - Test files remain exactly as upstream
52+
3. **Easy merges** - No conflicts when pulling upstream changes
53+
4. **Version controlled** - The alias package is tracked in git, ensuring consistency
54+
5. **Clean dependency graph** - PNPM properly manages the workspace dependency
55+
6. **No manual setup** - Works automatically after `pnpm install`
56+
57+
### Configuration Details
58+
59+
**pnpm-workspace.yaml:**
60+
61+
```yaml
62+
packages:
63+
- fixtures/*
64+
- packages/* # Includes our alias package
65+
```
66+
67+
**Main package.json devDependencies:**
68+
69+
```json
70+
{
71+
"devDependencies": {
72+
"@antfu/eslint-config": "workspace:*"
73+
}
74+
}
75+
```
76+
77+
**Alias package (packages/antfu-eslint-config/package.json):**
78+
79+
```json
80+
{
81+
"name": "@antfu/eslint-config",
82+
"dependencies": {
83+
"@pixpilot/eslint-config": "workspace:*"
84+
}
85+
}
86+
```
87+
88+
**Alias index.js:**
89+
90+
```javascript
91+
export * from '@pixpilot/eslint-config'
92+
export { default } from '@pixpilot/eslint-config'
93+
```
94+
95+
### Integration with CI/CD
96+
97+
No special setup needed! Standard workflow:
98+
99+
```yaml
100+
- name: Install dependencies
101+
run: pnpm install
102+
103+
- name: Build package
104+
run: pnpm build
105+
106+
- name: Run tests
107+
run: pnpm test
108+
```
109+
110+
### Alternative Solutions Considered
111+
112+
1. **Manual node_modules alias**: Works but not version controlled, requires scripts
113+
2. **PNPM Package Resolutions**: Doesn't work because test fixtures run in isolated directories
114+
3. **Symlinks**: Platform-specific and could cause issues in CI/CD
115+
4. **Changing test imports**: Would make upstream merges difficult
116+
117+
### Maintenance
118+
119+
- **Zero maintenance** - The workspace package is committed and works automatically
120+
- **Upstream merges** - No conflicts since test files remain unchanged
121+
- **New contributors** - Just run `pnpm install && pnpm build && pnpm test`
122+
123+
This solution provides the cleanest, most maintainable approach to keeping your fork's tests working while preserving upstream compatibility.

README.md

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
# @antfu/eslint-config
1+
# @pixpilot/eslint-config
22

3-
[![npm](https://img.shields.io/npm/v/@antfu/eslint-config?color=444&label=)](https://npmjs.com/package/@antfu/eslint-config) [![code style](https://antfu.me/badge-code-style.svg)](https://github.com/antfu/eslint-config)
3+
> [!IMPORTANT] > **Fork Notice:**
4+
> This repository is a fork of [@antfu/eslint-config](https://github.com/antfu/eslint-config).
5+
>
6+
> **Reason for Fork:**
7+
> The main purpose of this fork is to move Vue-related dependencies to `peerDependencies`, making this library more generic and suitable for any project—whether it is a library, React, Vue, or others. Only essential libraries are included as dependencies; framework-specific integrations should be added as peer dependencies by the consumer as needed.
8+
9+
[![npm](https://img.shields.io/npm/v/@pixpilot/eslint-config?color=444&label=)](https://npmjs.com/package/@pixpilot/eslint-config)
410

511
- Auto fix for formatting (aimed to be used standalone **without** Prettier)
612
- Reasonable defaults, best practices, only one line of config
@@ -38,24 +44,24 @@
3844
We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config with one command.
3945

4046
```bash
41-
pnpm dlx @antfu/eslint-config@latest
47+
pnpm dlx @pixpilot/eslint-config@latest
4248
```
4349

4450
### Manual Install
4551

4652
If you prefer to set up manually:
4753

4854
```bash
49-
pnpm i -D eslint @antfu/eslint-config
55+
pnpm i -D eslint @pixpilot/eslint-config
5056
```
5157

5258
And create `eslint.config.mjs` in your project root:
5359

5460
```js
5561
// eslint.config.mjs
56-
import antfu from '@antfu/eslint-config'
62+
import config from '@pixpilot/eslint-config'
5763

58-
export default antfu()
64+
export default config()
5965
```
6066

6167
<details>
@@ -66,9 +72,9 @@ Combined with legacy config:
6672
If you still use some configs from the legacy eslintrc format, you can use the [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) package to convert them to the flat config.
6773

6874
```js
69-
// eslint.config.mjs
70-
import antfu from '@antfu/eslint-config'
7175
import { FlatCompat } from '@eslint/eslintrc'
76+
// eslint.config.mjs
77+
import antfu from '@pixpilot/eslint-config'
7278

7379
const compat = new FlatCompat()
7480

@@ -262,7 +268,7 @@ Normally you only need to import the `antfu` preset:
262268

263269
```js
264270
// eslint.config.js
265-
import antfu from '@antfu/eslint-config'
271+
import antfu from '@pixpilot/eslint-config'
266272

267273
export default antfu()
268274
```
@@ -271,7 +277,7 @@ And that's it! Or you can configure each integration individually, for example:
271277

272278
```js
273279
// eslint.config.js
274-
import antfu from '@antfu/eslint-config'
280+
import antfu from '@pixpilot/eslint-config'
275281

276282
export default antfu({
277283
// Type of the project. 'lib' for libraries, the default is 'app'
@@ -306,7 +312,7 @@ The `antfu` factory function also accepts any number of arbitrary custom config
306312

307313
```js
308314
// eslint.config.js
309-
import antfu from '@antfu/eslint-config'
315+
import antfu from '@pixpilot/eslint-config'
310316

311317
export default antfu(
312318
{
@@ -352,7 +358,7 @@ import {
352358
unicorn,
353359
vue,
354360
yaml,
355-
} from '@antfu/eslint-config'
361+
} from '@pixpilot/eslint-config'
356362

357363
export default combine(
358364
ignores(),
@@ -418,7 +424,7 @@ Since v2.9.0, this preset will automatically rename the plugins also for your cu
418424
If you really want to use the original prefix, you can revert the plugin renaming by:
419425

420426
```ts
421-
import antfu from '@antfu/eslint-config'
427+
import antfu from '@pixpilot/eslint-config'
422428

423429
export default antfu()
424430
.renamePlugins({
@@ -437,7 +443,7 @@ Certain rules would only be enabled in specific files, for example, `ts/*` rules
437443

438444
```js
439445
// eslint.config.js
440-
import antfu from '@antfu/eslint-config'
446+
import antfu from '@pixpilot/eslint-config'
441447

442448
export default antfu(
443449
{
@@ -464,7 +470,7 @@ We also provided the `overrides` options in each integration to make it easier:
464470

465471
```js
466472
// eslint.config.js
467-
import antfu from '@antfu/eslint-config'
473+
import antfu from '@pixpilot/eslint-config'
468474

469475
export default antfu({
470476
vue: {
@@ -491,7 +497,7 @@ Since v2.10.0, the factory function `antfu()` returns a [`FlatConfigComposer` ob
491497

492498
```js
493499
// eslint.config.js
494-
import antfu from '@antfu/eslint-config'
500+
import antfu from '@pixpilot/eslint-config'
495501

496502
export default antfu()
497503
.prepend(
@@ -520,7 +526,7 @@ Vue support is detected automatically by checking if `vue` is installed in your
520526

521527
```js
522528
// eslint.config.js
523-
import antfu from '@antfu/eslint-config'
529+
import antfu from '@pixpilot/eslint-config'
524530

525531
export default antfu({
526532
vue: true
@@ -533,7 +539,7 @@ We have limited support for Vue 2 (as it's already [reached EOL](https://v2.vuej
533539

534540
```js
535541
// eslint.config.js
536-
import antfu from '@antfu/eslint-config'
542+
import antfu from '@pixpilot/eslint-config'
537543

538544
export default antfu({
539545
vue: {
@@ -550,7 +556,7 @@ To enable Vue accessibility support, you need to explicitly turn it on:
550556

551557
```js
552558
// eslint.config.js
553-
import antfu from '@antfu/eslint-config'
559+
import antfu from '@pixpilot/eslint-config'
554560

555561
export default antfu({
556562
vue: {
@@ -575,7 +581,7 @@ Use external formatters to format files that ESLint cannot handle yet (`.css`, `
575581

576582
```js
577583
// eslint.config.js
578-
import antfu from '@antfu/eslint-config'
584+
import antfu from '@pixpilot/eslint-config'
579585

580586
export default antfu({
581587
formatters: {
@@ -611,7 +617,7 @@ To enable React support, you need to explicitly turn it on:
611617

612618
```js
613619
// eslint.config.js
614-
import antfu from '@antfu/eslint-config'
620+
import antfu from '@pixpilot/eslint-config'
615621

616622
export default antfu({
617623
react: true,
@@ -630,7 +636,7 @@ To enable Next.js support, you need to explicitly turn it on:
630636

631637
```js
632638
// eslint.config.js
633-
import antfu from '@antfu/eslint-config'
639+
import antfu from '@pixpilot/eslint-config'
634640

635641
export default antfu({
636642
nextjs: true,
@@ -649,7 +655,7 @@ To enable svelte support, you need to explicitly turn it on:
649655

650656
```js
651657
// eslint.config.js
652-
import antfu from '@antfu/eslint-config'
658+
import antfu from '@pixpilot/eslint-config'
653659

654660
export default antfu({
655661
svelte: true,
@@ -668,7 +674,7 @@ To enable astro support, you need to explicitly turn it on:
668674

669675
```js
670676
// eslint.config.js
671-
import antfu from '@antfu/eslint-config'
677+
import antfu from '@pixpilot/eslint-config'
672678

673679
export default antfu({
674680
astro: true,
@@ -687,7 +693,7 @@ To enable Solid support, you need to explicitly turn it on:
687693

688694
```js
689695
// eslint.config.js
690-
import antfu from '@antfu/eslint-config'
696+
import antfu from '@pixpilot/eslint-config'
691697

692698
export default antfu({
693699
solid: true,
@@ -706,7 +712,7 @@ To enable UnoCSS support, you need to explicitly turn it on:
706712

707713
```js
708714
// eslint.config.js
709-
import antfu from '@antfu/eslint-config'
715+
import antfu from '@pixpilot/eslint-config'
710716

711717
export default antfu({
712718
unocss: true,
@@ -763,7 +769,7 @@ You can optionally enable the [type aware rules](https://typescript-eslint.io/li
763769

764770
```js
765771
// eslint.config.js
766-
import antfu from '@antfu/eslint-config'
772+
import antfu from '@pixpilot/eslint-config'
767773

768774
export default antfu({
769775
typescript: {
@@ -786,7 +792,7 @@ This is to prevent unused imports from getting removed by the editor during refa
786792

787793
```js
788794
// eslint.config.js
789-
import antfu from '@antfu/eslint-config'
795+
import antfu from '@pixpilot/eslint-config'
790796

791797
export default antfu({
792798
isInEditor: false
@@ -879,7 +885,7 @@ I am a very opinionated person, so as this config. I prefer the top-level functi
879885
I know they are not necessarily the popular opinions. If you really want to get rid of them, you can disable them with:
880886

881887
```ts
882-
import antfu from '@antfu/eslint-config'
888+
import antfu from '@pixpilot/eslint-config'
883889

884890
export default antfu({
885891
lessOpinionated: true

0 commit comments

Comments
 (0)