-
Notifications
You must be signed in to change notification settings - Fork 210
fix(create): preserve shorthand fmt/lint config keys #1843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+300
−8
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
42a571f
fix(create): preserve shorthand fmt/lint config keys
fengmk2 b16b9f3
chore(snap): format starter-template fixture files
fengmk2 0ea1d05
Merge branch 'main' into fix/1836-shorthand-config-keys
fengmk2 048b20d
Merge branch 'main' into fix/1836-shorthand-config-keys
fengmk2 e3bd8ec
Merge branch 'main' into fix/1836-shorthand-config-keys
fengmk2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/cli/snap-tests/create-monorepo-local-template-shorthand/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "local-template-monorepo-fixture", | ||
| "private": true, | ||
| "packageManager": "pnpm@10.0.0" | ||
| } |
49 changes: 49 additions & 0 deletions
49
...ap-tests/create-monorepo-local-template-shorthand/packages/starter-template/bin/index.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/usr/bin/env node | ||
| // Minimal local template generator. Writes a package that declares its `fmt` | ||
| // and `lint` config via shorthand properties, plus standalone Oxlint/Oxfmt | ||
| // config files. `vp create` must merge-skip the standalone files instead of | ||
| // injecting duplicate inline `fmt:`/`lint:` blocks into vite.config.ts (#1836). | ||
| import { mkdirSync, writeFileSync } from 'node:fs'; | ||
| import path from 'node:path'; | ||
|
|
||
| const args = process.argv.slice(2); | ||
| const dirFlag = args.indexOf('--directory'); | ||
| const dir = dirFlag !== -1 && args[dirFlag + 1] ? args[dirFlag + 1] : 'starter-app'; | ||
|
|
||
| mkdirSync(dir, { recursive: true }); | ||
|
|
||
| const write = (name, content) => writeFileSync(path.join(dir, name), content); | ||
|
|
||
| write( | ||
| 'package.json', | ||
| `${JSON.stringify({ name: path.basename(dir), version: '0.0.0', private: true }, null, 2)}\n`, | ||
| ); | ||
|
|
||
| write( | ||
| 'vite.config.ts', | ||
| `import { defineConfig } from 'vite-plus'; | ||
|
|
||
| import { fmt } from './tooling/format'; | ||
| import { lint } from './tooling/lint'; | ||
|
|
||
| export default defineConfig(({ mode }) => { | ||
| return { | ||
| server: { port: 3000 }, | ||
| fmt, | ||
| lint, | ||
| }; | ||
| }); | ||
| `, | ||
| ); | ||
|
|
||
| write('.oxlintrc.json', `${JSON.stringify({ rules: {} }, null, 2)}\n`); | ||
| write('.oxfmtrc.json', `${JSON.stringify({}, null, 2)}\n`); | ||
|
|
||
| mkdirSync(path.join(dir, 'tooling'), { recursive: true }); | ||
| writeFileSync( | ||
| path.join(dir, 'tooling', 'format.ts'), | ||
| 'export const fmt = { ignorePatterns: [] };\n', | ||
| ); | ||
| writeFileSync(path.join(dir, 'tooling', 'lint.ts'), 'export const lint = { rules: {} };\n'); | ||
|
|
||
| console.log(`cloned starter-template to ${dir}`); |
8 changes: 8 additions & 0 deletions
8
...nap-tests/create-monorepo-local-template-shorthand/packages/starter-template/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "starter-template", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "description": "A local starter template that wires fmt/lint via shorthand.", | ||
| "bin": "./bin/index.mjs", | ||
| "type": "module" | ||
| } |
2 changes: 2 additions & 0 deletions
2
packages/cli/snap-tests/create-monorepo-local-template-shorthand/pnpm-workspace.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| packages: | ||
| - packages/* |
36 changes: 36 additions & 0 deletions
36
packages/cli/snap-tests/create-monorepo-local-template-shorthand/snap.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| > vp create starter --no-interactive --no-agent -- --directory my-app # run the local create.templates entry; generated pkg declares fmt/lint via shorthand | ||
|
|
||
| Generating project… | ||
|
|
||
| Running: node <cwd>/packages/starter-template/bin/index.mjs --directory my-app | ||
| cloned starter-template to my-app | ||
|
|
||
| Monorepo integration... | ||
|
|
||
| lint config already present in packages/my-app/vite.config.ts — removed redundant packages/my-app/.oxlintrc.json | ||
|
|
||
| fmt config already present in packages/my-app/vite.config.ts — removed redundant packages/my-app/.oxfmtrc.json | ||
|
|
||
| Formatting code... | ||
|
|
||
| Code formatted | ||
| ◇ Scaffolded packages/my-app | ||
| • Node <semver> pnpm <semver> | ||
| → Next: cd packages/my-app && vp run | ||
|
|
||
| > cat packages/my-app/vite.config.ts # fmt/lint stay shorthand only, no injected duplicate inline fmt:/lint: blocks (#1836) | ||
| import { defineConfig } from "vite-plus"; | ||
|
|
||
| import { fmt } from "./tooling/format"; | ||
| import { lint } from "./tooling/lint"; | ||
|
|
||
| export default defineConfig(({ mode }) => { | ||
| return { | ||
| server: { port: 3000 }, | ||
| fmt, | ||
| lint, | ||
| }; | ||
| }); | ||
|
|
||
| > test ! -f packages/my-app/.oxlintrc.json # standalone lint config merge-skipped and removed | ||
| > test ! -f packages/my-app/.oxfmtrc.json # standalone fmt config merge-skipped and removed |
8 changes: 8 additions & 0 deletions
8
packages/cli/snap-tests/create-monorepo-local-template-shorthand/steps.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "commands": [ | ||
| "vp create starter --no-interactive --no-agent -- --directory my-app # run the local create.templates entry; generated pkg declares fmt/lint via shorthand", | ||
| "cat packages/my-app/vite.config.ts # fmt/lint stay shorthand only, no injected duplicate inline fmt:/lint: blocks (#1836)", | ||
| "test ! -f packages/my-app/.oxlintrc.json # standalone lint config merge-skipped and removed", | ||
| "test ! -f packages/my-app/.oxfmtrc.json # standalone fmt config merge-skipped and removed" | ||
| ] | ||
| } |
13 changes: 13 additions & 0 deletions
13
packages/cli/snap-tests/create-monorepo-local-template-shorthand/vite.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { defineConfig } from 'vite-plus'; | ||
|
|
||
| export default defineConfig({ | ||
| create: { | ||
| templates: [ | ||
| { | ||
| name: 'starter', | ||
| description: 'A local starter template that wires fmt/lint via shorthand.', | ||
| template: './packages/starter-template', | ||
| }, | ||
| ], | ||
| }, | ||
| }); |
9 changes: 9 additions & 0 deletions
9
packages/cli/snap-tests/migration-inline-config-shorthand/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "migration-inline-config-shorthand", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "devDependencies": { | ||
| "oxfmt": "1", | ||
| "oxlint": "1" | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
packages/cli/snap-tests/migration-inline-config-shorthand/snap.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| > vp migrate --no-interactive --no-hooks 2>&1 # must NOT duplicate fmt/lint already declared as shorthand properties (#1836) | ||
| ◇ Migrated . to Vite+ | ||
| • Node <semver> pnpm <semver> | ||
|
|
||
| > cat vite.config.ts # fmt/lint stay as shorthand only, no injected inline fmt:/lint: blocks | ||
| import { defineConfig } from 'vite-plus'; | ||
|
|
||
| // Mirrors a custom template that keeps tooling config in separate modules and | ||
| // wires them in with shorthand properties (`fmt,` / `lint,`). See #1836. | ||
| const fmt = { ignorePatterns: [] }; | ||
| const lint = { rules: {} }; | ||
|
|
||
| export default defineConfig(({ mode }) => { | ||
| return { | ||
| server: { port: 3000 }, | ||
| fmt, | ||
| lint, | ||
| }; | ||
| }); | ||
|
|
||
| > test ! -f .oxlintrc.json # no standalone lint config generated | ||
| > test ! -f .oxfmtrc.json # no standalone fmt config generated |
8 changes: 8 additions & 0 deletions
8
packages/cli/snap-tests/migration-inline-config-shorthand/steps.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "commands": [ | ||
| "vp migrate --no-interactive --no-hooks 2>&1 # must NOT duplicate fmt/lint already declared as shorthand properties (#1836)", | ||
| "cat vite.config.ts # fmt/lint stay as shorthand only, no injected inline fmt:/lint: blocks", | ||
| "test ! -f .oxlintrc.json # no standalone lint config generated", | ||
| "test ! -f .oxfmtrc.json # no standalone fmt config generated" | ||
| ] | ||
| } |
14 changes: 14 additions & 0 deletions
14
packages/cli/snap-tests/migration-inline-config-shorthand/vite.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { defineConfig } from 'vite-plus'; | ||
|
|
||
| // Mirrors a custom template that keeps tooling config in separate modules and | ||
| // wires them in with shorthand properties (`fmt,` / `lint,`). See #1836. | ||
| const fmt = { ignorePatterns: [] }; | ||
| const lint = { rules: {} }; | ||
|
|
||
| export default defineConfig(({ mode }) => { | ||
| return { | ||
| server: { port: 3000 }, | ||
| fmt, | ||
| lint, | ||
| }; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.