Skip to content

Commit b90e76c

Browse files
Copilothi-ogawa
andcommitted
chore: add printWidth 80 and enable experimentalSortImports
Co-authored-by: hi-ogawa <[email protected]>
1 parent aa82e65 commit b90e76c

File tree

265 files changed

+2619
-956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+2619
-956
lines changed

.oxfmtrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"printWidth": 80,
34
"semi": false,
4-
"singleQuote": true
5+
"singleQuote": true,
6+
"experimentalSortImports": {}
57
}

eslint.config.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
// @ts-check
2-
import { builtinModules } from 'node:module'
31
import eslint from '@eslint/js'
4-
import pluginN from 'eslint-plugin-n'
52
import pluginImportX from 'eslint-plugin-import-x'
3+
import pluginN from 'eslint-plugin-n'
64
import pluginRegExp from 'eslint-plugin-regexp'
7-
import tseslint from 'typescript-eslint'
85
import globals from 'globals'
6+
// @ts-check
7+
import { builtinModules } from 'node:module'
8+
import tseslint from 'typescript-eslint'
99

1010
export default tseslint.config(
1111
{
12-
ignores: ['**/dist/**', '**/playground-temp/**', '**/temp/**', 'packages/plugin-rsc/**'],
12+
ignores: [
13+
'**/dist/**',
14+
'**/playground-temp/**',
15+
'**/temp/**',
16+
'packages/plugin-rsc/**',
17+
],
1318
},
1419
eslint.configs.recommended,
1520
...tseslint.configs.recommended,
@@ -60,7 +65,10 @@ export default tseslint.config(
6065
'error',
6166
{ allowArgumentsExplicitlyTypedAsAny: true },
6267
],
63-
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],
68+
'@typescript-eslint/no-empty-function': [
69+
'error',
70+
{ allow: ['arrowFunctions'] },
71+
],
6472
'@typescript-eslint/no-empty-interface': 'off',
6573
'@typescript-eslint/no-explicit-any': 'off',
6674
'no-extra-semi': 'off',
@@ -95,17 +103,18 @@ export default tseslint.config(
95103
{ allow: builtinModules.map((mod) => `node:${mod}`) },
96104
],
97105
'import-x/no-duplicates': 'error',
98-
'import-x/order': 'error',
99-
'sort-imports': [
100-
'error',
101-
{
102-
ignoreCase: false,
103-
ignoreDeclarationSort: true,
104-
ignoreMemberSort: false,
105-
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
106-
allowSeparatedGroups: false,
107-
},
108-
],
106+
// import ordering handled by oxfmt
107+
// 'import-x/order': 'error',
108+
// 'sort-imports': [
109+
// 'error',
110+
// {
111+
// ignoreCase: false,
112+
// ignoreDeclarationSort: true,
113+
// ignoreMemberSort: false,
114+
// memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
115+
// allowSeparatedGroups: false,
116+
// },
117+
// ],
109118

110119
'regexp/prefer-regexp-exec': 'error',
111120
'regexp/prefer-regexp-test': 'error',

packages/common/refresh-runtime.js

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ function performReactRefresh() {
190190
failedRootsSnapshot.forEach((root) => {
191191
const helpers = helpersByRootSnapshot.get(root)
192192
if (helpers === undefined) {
193-
throw new Error('Could not find helpers for a root. This is a bug in React Refresh.')
193+
throw new Error(
194+
'Could not find helpers for a root. This is a bug in React Refresh.',
195+
)
194196
}
195197
if (!failedRoots.has(root)) {
196198
// No longer failed.
@@ -215,7 +217,9 @@ function performReactRefresh() {
215217
mountedRootsSnapshot.forEach((root) => {
216218
const helpers = helpersByRootSnapshot.get(root)
217219
if (helpers === undefined) {
218-
throw new Error('Could not find helpers for a root. This is a bug in React Refresh.')
220+
throw new Error(
221+
'Could not find helpers for a root. This is a bug in React Refresh.',
222+
)
219223
}
220224
if (!mountedRoots.has(root)) {
221225
// No longer mounted.
@@ -401,7 +405,8 @@ export function injectIntoGlobalHook(globalObject) {
401405
alternate.memoizedState.element != null &&
402406
mountedRoots.has(root)
403407

404-
const isMounted = current.memoizedState != null && current.memoizedState.element != null
408+
const isMounted =
409+
current.memoizedState != null && current.memoizedState.element != null
405410

406411
if (!wasMounted && isMounted) {
407412
// Mount a new root.
@@ -476,7 +481,10 @@ export function createSignatureFunctionForTransform() {
476481
// Set the signature for all types (even wrappers!) in case
477482
// they have no signatures of their own. This is to prevent
478483
// problems like https://github.com/facebook/react/issues/20417.
479-
if (type != null && (typeof type === 'function' || typeof type === 'object')) {
484+
if (
485+
type != null &&
486+
(typeof type === 'function' || typeof type === 'object')
487+
) {
480488
setSignature(type, key, forceReset, getCustomHooks)
481489
}
482490
return type
@@ -570,7 +578,10 @@ export function registerExportsForReactRefresh(filename, moduleExports) {
570578
register(exportValue, filename + ' export ' + key)
571579
} else if (isCompoundComponent(exportValue)) {
572580
for (const subKey in exportValue) {
573-
register(exportValue[subKey], filename + ' export ' + key + '-' + subKey)
581+
register(
582+
exportValue[subKey],
583+
filename + ' export ' + key + '-' + subKey,
584+
)
574585
}
575586
}
576587
}
@@ -593,12 +604,28 @@ const enqueueUpdate = debounce(async () => {
593604
performReactRefresh()
594605
}, 16)
595606

596-
export function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
607+
export function validateRefreshBoundaryAndEnqueueUpdate(
608+
id,
609+
prevExports,
610+
nextExports,
611+
) {
597612
const ignoredExports = window.__getReactRefreshIgnoredExports?.({ id }) ?? []
598-
if (predicateOnExport(ignoredExports, prevExports, (key) => key in nextExports) !== true) {
613+
if (
614+
predicateOnExport(
615+
ignoredExports,
616+
prevExports,
617+
(key) => key in nextExports,
618+
) !== true
619+
) {
599620
return 'Could not Fast Refresh (export removed)'
600621
}
601-
if (predicateOnExport(ignoredExports, nextExports, (key) => key in prevExports) !== true) {
622+
if (
623+
predicateOnExport(
624+
ignoredExports,
625+
nextExports,
626+
(key) => key in prevExports,
627+
) !== true
628+
) {
602629
return 'Could not Fast Refresh (new export)'
603630
}
604631

packages/common/refresh-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Plugin } from 'vite'
2+
23
import { exactRegex } from '@rolldown/pluginutils'
34

45
export const runtimePublicPath = '/@react-refresh'
@@ -14,7 +15,8 @@ injectIntoGlobalHook(window);
1415
window.$RefreshReg$ = () => {};
1516
window.$RefreshSig$ = () => (type) => type;`
1617

17-
export const getPreambleCode = (base: string): string => preambleCode.replace('__BASE__', base)
18+
export const getPreambleCode = (base: string): string =>
19+
preambleCode.replace('__BASE__', base)
1820

1921
export function addRefreshWrapper(
2022
code: string,

packages/common/warning.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import type { BuildOptions, UserConfig } from 'vite'
22

3-
export const silenceUseClientWarning = (userConfig: UserConfig): BuildOptions => ({
3+
export const silenceUseClientWarning = (
4+
userConfig: UserConfig,
5+
): BuildOptions => ({
46
rollupOptions: {
57
onwarn(warning, defaultHandler) {
68
if (
79
warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
8-
(warning.message.includes('use client') || warning.message.includes('use server'))
10+
(warning.message.includes('use client') ||
11+
warning.message.includes('use server'))
912
) {
1013
return
1114
}

packages/plugin-react-oxc/src/index.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { dirname, join } from 'node:path'
2-
import { fileURLToPath } from 'node:url'
3-
import { readFileSync } from 'node:fs'
41
import type { BuildOptions, Plugin } from 'vite'
2+
3+
import { exactRegex } from '@rolldown/pluginutils'
54
import {
65
addRefreshWrapper,
76
getPreambleCode,
87
runtimePublicPath,
98
silenceUseClientWarning,
109
} from '@vitejs/react-common'
11-
import { exactRegex } from '@rolldown/pluginutils'
10+
import { readFileSync } from 'node:fs'
11+
import { dirname, join } from 'node:path'
12+
import { fileURLToPath } from 'node:url'
1213

1314
const _dirname = dirname(fileURLToPath(import.meta.url))
1415
const refreshRuntimePath = join(_dirname, 'refresh-runtime.js')
@@ -51,7 +52,12 @@ export default function viteReact(opts: Options = {}): Plugin[] {
5152
jsxRefreshExclude: exclude,
5253
},
5354
optimizeDeps: {
54-
include: ['react', 'react-dom', jsxImportDevRuntime, jsxImportRuntime],
55+
include: [
56+
'react',
57+
'react-dom',
58+
jsxImportDevRuntime,
59+
jsxImportRuntime,
60+
],
5561
rolldownOptions: { transform: { jsx: { runtime: 'automatic' } } },
5662
},
5763
}
@@ -129,7 +135,9 @@ export default function viteReact(opts: Options = {}): Plugin[] {
129135
const useFastRefresh =
130136
!skipFastRefresh &&
131137
!ssr &&
132-
(isJSX || code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime))
138+
(isJSX ||
139+
code.includes(jsxImportDevRuntime) ||
140+
code.includes(jsxImportRuntime))
133141
if (!useFastRefresh) return
134142

135143
const newCode = addRefreshWrapper(code, '@vitejs/plugin-react-oxc', id)

packages/plugin-react-swc/playground/base-path/__tests__/base-path.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect, test } from '@playwright/test'
2+
23
import { setupDevServer, setupWaitForLogs } from '../../utils.ts'
34

45
test('Base path HMR', async ({ page }) => {

packages/plugin-react-swc/playground/base-path/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { StrictMode } from 'react'
22
import { createRoot } from 'react-dom/client'
3+
34
import { App } from './App.tsx'
45

56
createRoot(document.getElementById('root')!).render(

packages/plugin-react-swc/playground/base-path/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { defineConfig } from 'vite'
21
import react from '@vitejs/plugin-react-swc'
2+
import { defineConfig } from 'vite'
33

44
export default defineConfig({
55
plugins: [react()],

packages/plugin-react-swc/playground/class-components/__tests__/class-components.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect, test } from '@playwright/test'
2+
23
import { setupDevServer, setupWaitForLogs } from '../../utils.ts'
34

45
test('Class component HMR', async ({ page }) => {

0 commit comments

Comments
 (0)