Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .oxfmtrc.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
// "printWidth": 120,
"singleQuote": true,
"semi": false,
"experimentalSortImports": {}
// "ignorePatterns": [
// "tasks/transform_conformance/tests/**",
// "tasks/coverage/node-compat-table",
// "tasks/coverage/misc",
// "**/tests/**",
// "**/fixtures/**",
// "**/*.snap.*",
// "**/CHANGELOG.md",
// "pnpm-workspace.yaml",
// "pnpm-lock.yaml",
// "apps/oxlint/src-js/bindings.js",
// "apps/oxlint/src-js/bindings.d.ts",
// "!apps/oxlint/test/fixtures/**",
// "apps/oxlint/test/fixtures/**/*.snap.md",
// "napi/{transform,minify,playground}/index.js",
// "napi/{parser,transform,minify,playground}/**/index.d.ts",
// "napi/{parser,transform,minify,playground}/**/*.wasi-browser.js",
// "napi/{parser,transform,minify,playground}/**/*.wasi.cjs",
// "napi/{parser,transform,minify,playground}/**/wasi-worker-browser.mjs",
// "napi/{parser,transform,minify,playground}/**/wasi-worker.mjs",
// "napi/{parser,transform,minify,playground}/**/browser.js",
// "napi/parser/src-js/bindings.js",
// "npm/*/package.json",
// "npm/oxlint/configuration_schema.json",
// "npm/oxc-wasm/**",
// "npm/runtime/src",
// ".github/generated/ast_changes_watch_list.yml"
// ]
}
30 changes: 15 additions & 15 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @ts-check
import { builtinModules } from 'node:module'
import eslint from '@eslint/js'
import pluginN from 'eslint-plugin-n'
import pluginImportX from 'eslint-plugin-import-x'
import pluginN from 'eslint-plugin-n'
import pluginRegExp from 'eslint-plugin-regexp'
import tseslint from 'typescript-eslint'
import globals from 'globals'
// @ts-check
import { builtinModules } from 'node:module'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{
Expand Down Expand Up @@ -103,17 +103,17 @@ export default tseslint.config(
{ allow: builtinModules.map((mod) => `node:${mod}`) },
],
'import-x/no-duplicates': 'error',
'import-x/order': 'error',
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false,
},
],
// "import-x/order": "error",
// "sort-imports": [
// "error",
// {
// ignoreCase: false,
// ignoreDeclarationSort: true,
// ignoreMemberSort: false,
// memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
// allowSeparatedGroups: false,
// },
// ],

'regexp/prefer-regexp-exec': 'error',
'regexp/prefer-regexp-test': 'error',
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"scripts": {
"preinstall": "npx only-allow pnpm",
"postinstall": "simple-git-hooks",
"format": "prettier --write --cache .",
"format": "oxfmt",
"lint": "eslint --cache .",
"typecheck": "tsc -p scripts && tsc -p playground && tsc -p packages/plugin-react",
"test": "pnpm run test-unit && pnpm run test-serve && pnpm run test-build && pnpm --filter ./packages/plugin-react-swc run test",
Expand All @@ -44,6 +44,7 @@
"fs-extra": "^11.3.2",
"globals": "^16.4.0",
"lint-staged": "^16.2.4",
"oxfmt": "^0.8.0",
"picocolors": "^1.1.1",
"playwright-chromium": "^1.56.1",
"prettier": "^3.6.2",
Expand All @@ -59,7 +60,7 @@
},
"lint-staged": {
"*": [
"prettier --write --cache --ignore-unknown"
"oxfmt"
],
"packages/*/{src,types}/**/*.ts": [
"eslint --cache --fix"
Expand Down
2 changes: 1 addition & 1 deletion packages/common/refresh-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Plugin } from 'vite'
import { exactRegex } from '@rolldown/pluginutils'
import type { Plugin } from 'vite'

export const runtimePublicPath = '/@react-refresh'

Expand Down
10 changes: 5 additions & 5 deletions packages/plugin-react-oxc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { readFileSync } from 'node:fs'
import type { BuildOptions, Plugin } from 'vite'
import { exactRegex } from '@rolldown/pluginutils'
import {
addRefreshWrapper,
getPreambleCode,
runtimePublicPath,
silenceUseClientWarning,
} from '@vitejs/react-common'
import { exactRegex } from '@rolldown/pluginutils'
import { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { BuildOptions, Plugin } from 'vite'

const _dirname = dirname(fileURLToPath(import.meta.url))
const refreshRuntimePath = join(_dirname, 'refresh-runtime.js')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test'
import { setupDevServer, setupWaitForLogs } from '../../utils.ts'
import { expect, test } from '@playwright/test'

test('Base path HMR', async ({ page }) => {
const { testUrl, server, editFile } = await setupDevServer('base-path')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from './App.tsx'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { App } from './App.tsx'

createRoot(document.getElementById('root')!).render(
<StrictMode>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test'
import { setupDevServer, setupWaitForLogs } from '../../utils.ts'
import { expect, test } from '@playwright/test'

test('Class component HMR', async ({ page }) => {
const { testUrl, server, editFile } = await setupDevServer('class-components')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from 'react'
import { getGetting } from './utils.tsx'
import { Component } from 'react'

export class App extends Component {
render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from './App.tsx'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { App } from './App.tsx'

createRoot(document.getElementById('root')!).render(
<StrictMode>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test'
import { setupBuildAndPreview, setupDevServer } from '../../utils.ts'
import { expect, test } from '@playwright/test'

test('Decorators build', async ({ page }) => {
const { testUrl, server } = await setupBuildAndPreview('decorators')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from './App.tsx'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { App } from './App.tsx'

createRoot(document.getElementById('root')!).render(
<StrictMode>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react({ tsDecorators: true })],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect, test } from '@playwright/test'
import {
expectColor,
setupBuildAndPreview,
setupDevServer,
setupWaitForLogs,
} from '../../utils.ts'
import { expect, test } from '@playwright/test'

test('Emotion plugin build', async ({ page }) => {
const { testUrl, server } = await setupBuildAndPreview('emotion-plugin')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from '@emotion/styled'
import { css } from '@emotion/react'
import styled from '@emotion/styled'
import { useState } from 'react'

// Ensure HMR of styled component alongside other components
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from './App.jsx'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { App } from './App.jsx'
import './index.css'

createRoot(document.getElementById('root')).render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect, test } from '@playwright/test'
import {
expectColor,
setupBuildAndPreview,
setupDevServer,
setupWaitForLogs,
} from '../../utils.ts'
import { expect, test } from '@playwright/test'

test('Emotion build', async ({ page }) => {
const { testUrl, server } = await setupBuildAndPreview('emotion')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from '@emotion/styled'
import { css } from '@emotion/react'
import styled from '@emotion/styled'
import { useState } from 'react'

// Ensure HMR of styled component alongside other components
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/emotion/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from './App.tsx'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels weird for me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we need to wait for proper import sorting. It looks like it's only sorting by string, so relative import comes first . < @ < a.

import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { App } from './App.tsx'
import './index.css'

createRoot(document.getElementById('root')!).render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react({ jsxImportSource: '@emotion/react' })],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test } from '@playwright/test'
import {
setupBuildAndPreview,
setupDevServer,
setupWaitForLogs,
} from '../../utils.ts'
import { expect, test } from '@playwright/test'

test('Default build', async ({ page }) => {
const { testUrl, server } = await setupBuildAndPreview('hmr')
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react-swc/playground/hmr/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react'
import reactLogo from './react.svg'
import './App.css'
import { TitleWithExport, framework } from './TitleWithExport.tsx'
import './App.css'
import { useState } from 'react'

export const App = () => {
const [count, setCount] = useState(0)
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/hmr/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from './App.tsx'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { App } from './App.tsx'
import './index.css'

createRoot(document.getElementById('root')!).render(
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/hmr/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test } from '@playwright/test'
import {
setupBuildAndPreview,
setupDevServer,
setupWaitForLogs,
} from '../../utils.ts'
import { expect, test } from '@playwright/test'

test('MDX build', async ({ page }) => {
const { testUrl, server } = await setupBuildAndPreview('mdx')
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/mdx/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Hello from './hello.mdx'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import Hello from './hello.mdx'

createRoot(document.getElementById('root')!).render(
<StrictMode>
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/mdx/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'vite'
import mdx from '@mdx-js/rollup'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [mdx(), react()],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test } from '@playwright/test'
import {
setupBuildAndPreview,
setupDevServer,
setupWaitForLogs,
} from '../../utils.ts'
import { expect, test } from '@playwright/test'

test('Default build', async ({ page }) => {
const { testUrl, server } = await setupBuildAndPreview('react-18')
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react-swc/playground/react-18/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react'
import reactLogo from './react.svg'
import './App.css'
import { TitleWithExport, framework } from './TitleWithExport.tsx'
import './App.css'
Copy link
Member

@ArnaudBarre ArnaudBarre Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really fan of plugins that re-order side-effect imports

import { useState } from 'react'

export const App = () => {
const [count, setCount] = useState(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from './App.tsx'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { App } from './App.tsx'
import './index.css'

createRoot(document.getElementById('root')!).render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test'
import { setupDevServer, setupWaitForLogs } from '../../utils.ts'
import { expect, test } from '@playwright/test'

test('Shadow export HMR', async ({ page }) => {
const { testUrl, server, editFile } = await setupDevServer('shadow-export')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from './App.tsx'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { App } from './App.tsx'

createRoot(document.getElementById('root')!).render(
<StrictMode>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
Loading
Loading