Skip to content
Closed
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
86 changes: 80 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import globals from 'globals'

export default tseslint.config(
{
ignores: [
'**/dist/**',
'**/playground-temp/**',
'**/temp/**',
'packages/plugin-rsc/**',
],
ignores: ['**/dist/**', '**/playground-temp/**', '**/temp/**'],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
Expand Down Expand Up @@ -168,4 +163,83 @@ export default tseslint.config(
'@typescript-eslint/triple-slash-reference': 'off',
},
},
{
name: 'plugin-rsc/import-sorting-only',
files: ['packages/plugin-rsc/**/*.?([cm])[jt]s?(x)'],
plugins: {
'import-x': pluginImportX,
},
rules: {
// Disable all existing rules from the main config
eqeqeq: 'off',
'no-debugger': 'off',
'no-empty': 'off',
'no-empty-pattern': 'off',
'no-constant-condition': 'off',
'no-extra-boolean-cast': 'off',
'prefer-const': 'off',
'prefer-spread': 'off',

// Disable Node.js plugin rules
'n/no-process-exit': 'off',
'n/no-deprecated-api': 'off',
'n/no-unpublished-import': 'off',
'n/no-unpublished-require': 'off',
'n/no-unsupported-features/es-syntax': 'off',
'n/no-unsupported-features/node-builtins': 'off',
'n/no-unsupported-features/es-builtins': 'off',
'n/no-missing-import': 'off',
'n/no-missing-require': 'off',
'n/no-extraneous-import': 'off',
'n/no-extraneous-require': 'off',

// Disable TypeScript rules
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-semi': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/prefer-for-of': 'off',
'@typescript-eslint/prefer-function-type': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-namespace': 'off',

// Disable regexp rules
'regexp/prefer-regexp-exec': 'off',
'regexp/prefer-regexp-test': 'off',
'regexp/use-ignore-case': 'off',
'regexp/no-super-linear-backtracking': 'off',
'regexp/no-unused-capturing-group': 'off',

// Disable other import rules except the ones we want
'import-x/no-nodejs-modules': 'off',

// Disable globals restriction
'no-restricted-globals': 'off',

// Enable only import sorting related rules
'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,
},
],
},
},
)
2 changes: 1 addition & 1 deletion packages/plugin-rsc/e2e/browser-mode.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, type Page } from '@playwright/test'
import { type Page, expect, test } from '@playwright/test'
import { useFixture } from './fixture'
import { defineStarterTest } from './starter'

Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rsc/e2e/build-app.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'
import { setupInlineFixture, useFixture } from './fixture'
import { expect, test } from '@playwright/test'
import { x } from 'tinyexec'
import { setupInlineFixture, useFixture } from './fixture'
import { waitForHydration } from './helper'

test.describe('buildApp hook', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rsc/e2e/isolated.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'node:path'
import os from 'node:os'
import { test } from '@playwright/test'
import { setupIsolatedFixture, useFixture } from './fixture'
import { defineStarterTest } from './starter'
import path from 'node:path'
import os from 'node:os'

test.describe(() => {
// use RUNNER_TEMP on Github Actions
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rsc/e2e/no-ssr.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'node:path'
import fs from 'node:fs'
import { expect, test } from '@playwright/test'
import { useFixture } from './fixture'
import { defineStarterTest } from './starter'
import path from 'node:path'
import fs from 'node:fs'

test.describe('dev-no-ssr', () => {
const f = useFixture({ root: 'examples/no-ssr', mode: 'dev' })
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rsc/e2e/react-router.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createHash } from 'node:crypto'
import { readFileSync } from 'node:fs'
import { expect, test } from '@playwright/test'
import React from 'react'
import { type Fixture, useFixture } from './fixture'
import { expectNoReload, testNoJs, waitForHydration } from './helper'
import { readFileSync } from 'node:fs'
import React from 'react'

test.describe('dev-default', () => {
test.skip(/canary|experimental/.test(React.version))
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/e2e/render-built-url.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'node:fs'
import { expect, test } from '@playwright/test'
import { setupInlineFixture, useFixture } from './fixture'
import { defineStarterTest } from './starter'
import { expectNoPageError, waitForHydration } from './helper'
import fs from 'node:fs'

test.describe(() => {
const root = 'examples/e2e/temp/renderBuiltUrl-runtime'
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/e2e/ssr-thenable.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '@playwright/test'
import { setupInlineFixture, type Fixture, useFixture } from './fixture'
import { type Fixture, setupInlineFixture, useFixture } from './fixture'
import {
expectNoPageError,
waitForHydration as waitForHydration_,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rsc/e2e/syntax-error.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'
import { setupInlineFixture, useFixture } from './fixture'
import { waitForHydration, expectNoReload } from './helper'
import { expectNoReload, waitForHydration } from './helper'

test.describe(() => {
const root = 'examples/e2e/temp/syntax-error'
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rsc/e2e/validate-imports.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'
import { setupInlineFixture, useFixture, type Fixture } from './fixture'
import { expect, test } from '@playwright/test'
import { x } from 'tinyexec'
import { type Fixture, setupInlineFixture, useFixture } from './fixture'
import { expectNoPageError, waitForHydration } from './helper'

test.describe('validate imports', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/examples/basic/src/routes/root.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import TestDepCssInServer from '@vitejs/test-dep-css-in-server/server'
import {
TestServerActionBindAction,
TestServerActionBindClient,
Expand Down Expand Up @@ -31,7 +32,6 @@ import { TestReactCache } from './react-cache/server'
import { TestHydrationMismatch } from './hydration-mismatch/server'
import { TestBrowserOnly } from './browser-only/client'
import { TestTransitiveCjsClient } from './deps/transitive-cjs/client'
import TestDepCssInServer from '@vitejs/test-dep-css-in-server/server'
import { TestHmrSharedServer } from './hmr-shared/server'
import { TestHmrSharedClient } from './hmr-shared/client'
import { TestHmrSharedAtomic } from './hmr-shared/atomic/server'
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/examples/basic/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import assert from 'node:assert'
import path from 'node:path'
import rsc, { transformHoistInlineDirective } from '@vitejs/plugin-rsc'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import { type Plugin, defineConfig, normalizePath, parseAstAsync } from 'vite'
import inspect from 'vite-plugin-inspect'
import path from 'node:path'

export default defineConfig({
clearScreen: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ReactServer from '@vitejs/plugin-rsc/react/rsc'
import type React from 'react'
import { Root } from '../root'
import type { ReactFormState } from 'react-dom/client'
import { Root } from '../root'

export type RscPayload = {
root: React.ReactNode
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rsc/examples/no-ssr/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fsp from 'node:fs/promises'
import rsc from '@vitejs/plugin-rsc'
import react from '@vitejs/plugin-react'
import { defineConfig, type Plugin } from 'vite'
import fsp from 'node:fs/promises'
import { type Plugin, defineConfig } from 'vite'

export default defineConfig({
plugins: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
encodeReply,
setServerCallback,
} from '@vitejs/plugin-rsc/browser'
import { startTransition, StrictMode } from 'react'
import { StrictMode, startTransition } from 'react'
import { hydrateRoot } from 'react-dom/client'
import {
unstable_createCallServer as createCallServer,
unstable_getRSCStream as getRSCStream,
unstable_RSCHydratedRouter as RSCHydratedRouter,
type unstable_RSCPayload as RSCServerPayload,
unstable_createCallServer as createCallServer,
unstable_getRSCStream as getRSCStream,
} from 'react-router'

// Create and set the callServer function to support post-hydration server actions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createFromReadableStream } from '@vitejs/plugin-rsc/ssr'
import { renderToReadableStream as renderHTMLToReadableStream } from 'react-dom/server.edge'
import {
unstable_routeRSCServerRequest as routeRSCServerRequest,
unstable_RSCStaticRouter as RSCStaticRouter,
unstable_routeRSCServerRequest as routeRSCServerRequest,
} from 'react-router'

export async function generateHTML(
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/src/core/rsc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { memoize, tinyassert } from '@hiogawa/utils'
import * as ReactServer from '@vitejs/plugin-rsc/vendor/react-server-dom/server.edge'

Check failure on line 2 in packages/plugin-rsc/src/core/rsc.ts

View workflow job for this annotation

GitHub Actions / Lint: node-20, ubuntu-latest

`@vitejs/plugin-rsc/vendor/react-server-dom/server.edge` import should occur after import of `./shared`
import type { BundlerConfig, ImportManifestEntry, ModuleMap } from '../types'
import {
SERVER_DECODE_CLIENT_PREFIX,
Expand All @@ -9,7 +10,6 @@
} from './shared'

// @ts-ignore
import * as ReactServer from '@vitejs/plugin-rsc/vendor/react-server-dom/server.edge'

let init = false
let requireModule!: (id: string) => unknown
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/src/transforms/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dirname } from 'path'
import { hashString } from '@hiogawa/utils'
import { mkdir, writeFile } from 'fs/promises'
import { hashString } from '@hiogawa/utils'
import type MagicString from 'magic-string'

export async function debugSourceMap(output: MagicString): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/src/vite-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import fs from 'node:fs'
import path from 'node:path'
import type { DevEnvironment, ErrorPayload, Rollup } from 'vite'
import { stripVTControlCharacters as strip } from 'node:util'
import type { DevEnvironment, ErrorPayload, Rollup } from 'vite'

export const VALID_ID_PREFIX = `/@id/`

Expand Down
Loading