Repository navigation
Feat/oxlint toolchain #524
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
Open
AustinDavisTech
wants to merge
5
commits into
TanStack:main
Choose a base branch
from
AustinDavisTech:feat/oxlint-toolchain
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+223
−15
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
06b06be
feat(create): add Oxlint toolchain option
AustinDavisTech cab1c13
feat(cli): suggest Oxlint in the Rsbuild toolchain error
AustinDavisTech ca3f42d
docs: list Oxlint in toolchain docs
AustinDavisTech da8e557
test(create): check Oxlint is listed without fixing toolchain order
AustinDavisTech fd1e1f3
docs: describe the Oxlint toolchain in alias READMEs
AustinDavisTech 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@tanstack/cli': minor | ||
| '@tanstack/create': minor | ||
| --- | ||
|
|
||
| Add Oxlint as a toolchain option for React and Solid scaffolds. It generates an | ||
| `.oxlintrc.json` with a `lint` script. |
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
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
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
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
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
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
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
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
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
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
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
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
19 changes: 19 additions & 0 deletions
19
packages/create/src/frameworks/react/toolchains/oxlint/assets/_dot_oxlintrc.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,19 @@ | ||
| { | ||
| "$schema": "./node_modules/oxlint/configuration_schema.json", | ||
| "plugins": ["typescript", "unicorn", "oxc", "react"], | ||
| "categories": { | ||
| "correctness": "error" | ||
| }, | ||
| "rules": { | ||
| "react/rules-of-hooks": "error", | ||
| "react/exhaustive-deps": "warn", | ||
| "react/incompatible-library": "warn", | ||
| "react/unsupported-syntax": "warn", | ||
| "react/purity": "off", | ||
| "react/set-state-in-effect": "off" | ||
| }, | ||
| "env": { | ||
| "builtin": true | ||
| }, | ||
| "ignorePatterns": ["src/routeTree.gen.ts"] | ||
| } |
11 changes: 11 additions & 0 deletions
11
packages/create/src/frameworks/react/toolchains/oxlint/info.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,11 @@ | ||
| { | ||
| "name": "Oxlint", | ||
| "description": "Oxlint toolchain support.", | ||
| "phase": "setup", | ||
| "type": "toolchain", | ||
| "category": "tooling", | ||
| "exclusive": ["linter"], | ||
| "color": "#195EFF", | ||
| "modes": ["code-router", "file-router"], | ||
| "link": "https://oxc.rs/docs/guide/usage/linter" | ||
| } |
8 changes: 8 additions & 0 deletions
8
packages/create/src/frameworks/react/toolchains/oxlint/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 @@ | ||
| { | ||
| "scripts": { | ||
| "lint": "oxlint" | ||
| }, | ||
| "devDependencies": { | ||
| "oxlint": "^1.90.0" | ||
| } | ||
| } |
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
12 changes: 12 additions & 0 deletions
12
packages/create/src/frameworks/solid/toolchains/oxlint/assets/_dot_oxlintrc.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,12 @@ | ||
| { | ||
| "$schema": "./node_modules/oxlint/configuration_schema.json", | ||
| "plugins": ["typescript", "unicorn", "oxc"], | ||
| "categories": { | ||
| "correctness": "error" | ||
| }, | ||
| "rules": {}, | ||
| "env": { | ||
| "builtin": true | ||
| }, | ||
| "ignorePatterns": ["src/routeTree.gen.ts"] | ||
| } |
11 changes: 11 additions & 0 deletions
11
packages/create/src/frameworks/solid/toolchains/oxlint/info.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,11 @@ | ||
| { | ||
| "name": "Oxlint", | ||
| "description": "Oxlint toolchain support.", | ||
| "phase": "setup", | ||
| "type": "toolchain", | ||
| "category": "tooling", | ||
| "exclusive": ["linter"], | ||
| "color": "#195EFF", | ||
| "modes": ["code-router", "file-router"], | ||
| "link": "https://oxc.rs/docs/guide/usage/linter" | ||
| } |
8 changes: 8 additions & 0 deletions
8
packages/create/src/frameworks/solid/toolchains/oxlint/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 @@ | ||
| { | ||
| "scripts": { | ||
| "lint": "oxlint" | ||
| }, | ||
| "devDependencies": { | ||
| "oxlint": "^1.90.0" | ||
| } | ||
| } |
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,102 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import { finalizeAddOns, getAllAddOns } from '../src/add-ons.js' | ||
| import { createApp } from '../src/create-app.js' | ||
| import { createMemoryEnvironment } from '../src/environment.js' | ||
| import { createFrameworkDefinition as createReactFrameworkDefinition } from '../src/frameworks/react/index.js' | ||
| import { createFrameworkDefinition as createSolidFrameworkDefinition } from '../src/frameworks/solid/index.js' | ||
|
|
||
| import type { Framework, FrameworkDefinition } from '../src/types.js' | ||
|
|
||
| function frameworkFromDefinition(definition: FrameworkDefinition): Framework { | ||
| const { addOns, base, ...framework } = definition | ||
|
|
||
| return { | ||
| ...framework, | ||
| getFiles: () => Promise.resolve(Object.keys(base)), | ||
| getFileContents: (path: string) => Promise.resolve(base[path]), | ||
| getDeletedFiles: () => Promise.resolve([]), | ||
| getAddOns: () => addOns, | ||
| } | ||
| } | ||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllGlobals() | ||
| }) | ||
|
|
||
| describe('toolchains', () => { | ||
| it.each([ | ||
| ['react', createReactFrameworkDefinition], | ||
| ['solid', createSolidFrameworkDefinition], | ||
| ])('%s includes Oxlint as a toolchain', (_, createDefinition) => { | ||
| const framework = frameworkFromDefinition(createDefinition()) | ||
| const toolchains = getAllAddOns(framework, 'file-router') | ||
| .filter((addOn) => addOn.type === 'toolchain') | ||
| .map((addOn) => addOn.id) | ||
|
|
||
| expect(toolchains).toContain('oxlint') | ||
| }) | ||
|
|
||
| it.each([ | ||
| ['react', createReactFrameworkDefinition, true], | ||
| ['solid', createSolidFrameworkDefinition, false], | ||
| ])( | ||
| '%s generates an Oxlint lint setup', | ||
| async (_, createDefinition, usesReactPlugin) => { | ||
| vi.stubGlobal( | ||
| 'fetch', | ||
| vi.fn( | ||
| async () => | ||
| new Response(JSON.stringify({ version: '1.0.0' }), { | ||
| status: 200, | ||
| }), | ||
| ), | ||
| ) | ||
|
|
||
| const framework = frameworkFromDefinition(createDefinition()) | ||
| const chosenAddOns = await finalizeAddOns(framework, 'file-router', [ | ||
| 'oxlint', | ||
| ]) | ||
| const { environment, output } = createMemoryEnvironment() | ||
|
|
||
| await createApp(environment, { | ||
| projectName: 'oxlint-app', | ||
| targetDir: '/oxlint-app', | ||
| framework, | ||
| mode: 'file-router', | ||
| typescript: true, | ||
| tailwind: true, | ||
| packageManager: 'pnpm', | ||
| git: false, | ||
| install: false, | ||
| intent: false, | ||
| chosenAddOns, | ||
| addOnOptions: {}, | ||
| }) | ||
|
|
||
| const packageJSON = JSON.parse(output.files['/oxlint-app/package.json']) | ||
| const oxlintConfig = JSON.parse( | ||
| output.files['/oxlint-app/.oxlintrc.json'], | ||
| ) | ||
| const readme = output.files['/oxlint-app/README.md'] | ||
|
|
||
| expect(packageJSON.scripts.lint).toBe('oxlint') | ||
| expect(packageJSON.scripts).not.toHaveProperty('format') | ||
| expect(packageJSON.scripts).not.toHaveProperty('check') | ||
| expect(packageJSON.devDependencies).toHaveProperty('oxlint') | ||
| expect(packageJSON.devDependencies).not.toHaveProperty('@biomejs/biome') | ||
| expect(packageJSON.devDependencies).not.toHaveProperty('eslint') | ||
| expect(packageJSON.devDependencies).not.toHaveProperty('prettier') | ||
|
|
||
| expect(oxlintConfig.ignorePatterns).toContain('src/routeTree.gen.ts') | ||
| expect(oxlintConfig.plugins.includes('react')).toBe(usesReactPlugin) | ||
| expect(oxlintConfig.rules['react/rules-of-hooks']).toBe( | ||
| usesReactPlugin ? 'error' : undefined, | ||
| ) | ||
|
|
||
| expect(readme).toContain('## Linting\n') | ||
| expect(readme).toContain('[Oxlint]') | ||
| expect(readme).not.toContain('## Linting & Formatting') | ||
| }, | ||
| ) | ||
| }) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include the Oxlint instructions in blank scaffolds.
When
projectPresetisblank, this section does not render because it sits inside the nonblank README branch. The generated package still has alintscript, but the README does not document it. The Solid template has the same gap at Line 146. Add the Linting section to both blank branches, or place it outside the blank/nonblank conditional. (raw.githubusercontent.com)