Skip to content

Commit 08ea755

Browse files
committed
style: code format
1 parent f08abc8 commit 08ea755

File tree

19 files changed

+171
-171
lines changed

19 files changed

+171
-171
lines changed

postcss.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
22
plugins: {
3-
'@tailwindcss/postcss': {},
3+
"@tailwindcss/postcss": {},
44
},
55
};

rspack.config.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
import { defineConfig } from '@rspack/cli';
2-
import { rspack } from '@rspack/core';
3-
import * as RefreshPlugin from '@rspack/plugin-react-refresh';
4-
import * as path from 'node:path';
1+
import { defineConfig } from "@rspack/cli";
2+
import { rspack } from "@rspack/core";
3+
import * as RefreshPlugin from "@rspack/plugin-react-refresh";
4+
import * as path from "node:path";
55

6-
const isDev = process.env.NODE_ENV === 'development';
6+
const isDev = process.env.NODE_ENV === "development";
77

88
// Target browsers, see: https://github.com/browserslist/browserslist
9-
const targets = ['chrome >= 87', 'edge >= 88', 'firefox >= 78', 'safari >= 14'];
9+
const targets = ["chrome >= 87", "edge >= 88", "firefox >= 78", "safari >= 14"];
1010

1111
const splitChunkGroupConfig = {
12-
filename: 'js/[name].js',
12+
filename: "js/[name].js",
1313
priority: 100,
1414
enforce: true,
1515
};
1616

1717
export default defineConfig({
1818
context: __dirname,
1919
entry: {
20-
main: './src/main.tsx',
20+
main: "./src/main.tsx",
2121
},
22-
devtool: isDev ? 'source-map' : false,
22+
devtool: isDev ? "source-map" : false,
2323
output: {
2424
clean: true,
25-
filename: 'js/[name].[contenthash:8].js',
26-
cssFilename: 'css/[name].[contenthash:8].css',
27-
assetModuleFilename: 'assets/[hash][ext][query]',
25+
filename: "js/[name].[contenthash:8].js",
26+
cssFilename: "css/[name].[contenthash:8].css",
27+
assetModuleFilename: "assets/[hash][ext][query]",
2828
},
2929
resolve: {
30-
extensions: ['...', '.ts', '.tsx', '.jsx'],
30+
extensions: ["...", ".ts", ".tsx", ".jsx"],
3131
alias: {
32-
'@': path.resolve(__dirname, './src'),
32+
"@": path.resolve(__dirname, "./src"),
3333
},
3434
},
3535
module: {
@@ -41,17 +41,17 @@ export default defineConfig({
4141
rules: [
4242
{
4343
test: /\.svg$/,
44-
type: 'asset',
44+
type: "asset",
4545
},
4646
{
4747
test: /\.css$/,
48-
use: ['postcss-loader'],
49-
type: 'css',
48+
use: ["postcss-loader"],
49+
type: "css",
5050
},
5151
// support raw resource: https://rspack.dev/zh/guide/features/asset-module
5252
{
5353
resourceQuery: /raw/,
54-
type: 'asset/source',
54+
type: "asset/source",
5555
},
5656
{
5757
test: /\.(jsx?|tsx?)$/,
@@ -60,16 +60,16 @@ export default defineConfig({
6060
resourceQuery: { not: /raw/ },
6161
use: [
6262
{
63-
loader: 'builtin:swc-loader',
63+
loader: "builtin:swc-loader",
6464
options: {
6565
jsc: {
6666
parser: {
67-
syntax: 'typescript',
67+
syntax: "typescript",
6868
tsx: true,
6969
},
7070
transform: {
7171
react: {
72-
runtime: 'automatic',
72+
runtime: "automatic",
7373
development: isDev,
7474
refresh: isDev,
7575
},
@@ -84,10 +84,10 @@ export default defineConfig({
8484
},
8585
plugins: [
8686
new rspack.HtmlRspackPlugin({
87-
template: './index.html',
87+
template: "./index.html",
8888
}),
8989
new rspack.CopyRspackPlugin({
90-
patterns: [{ from: './public', to: '.' }],
90+
patterns: [{ from: "./public", to: "." }],
9191
}),
9292
isDev ? new RefreshPlugin() : null,
9393
].filter(Boolean),
@@ -99,21 +99,21 @@ export default defineConfig({
9999
}),
100100
],
101101
splitChunks: {
102-
chunks: 'all',
102+
chunks: "all",
103103
cacheGroups: {
104104
react: {
105105
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
106-
name: 'lib-react',
106+
name: "lib-react",
107107
...splitChunkGroupConfig,
108108
},
109109
babelStandalone: {
110110
test: /[\\/]node_modules[\\/]@babel[\\/]standalone[\\/]/,
111-
name: 'lib-babel',
111+
name: "lib-babel",
112112
...splitChunkGroupConfig,
113113
},
114114
typescript: {
115115
test: /[\\/]node_modules[\\/]typescript[\\/]/,
116-
name: 'lib-ts',
116+
name: "lib-ts",
117117
...splitChunkGroupConfig,
118118
},
119119
},

src/components/CodeContainer/ata.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { setupTypeAcquisition } from '@typescript/ata';
2-
import ts from 'typescript';
1+
import { setupTypeAcquisition } from "@typescript/ata";
2+
import ts from "typescript";
33

44
export function createATA(onDownloadFile: (code: string, path: string) => void) {
55
const ata = setupTypeAcquisition({
6-
projectName: 'react-playground',
6+
projectName: "react-playground",
77
typescript: ts,
88
logger: console,
99
fetcher(input, init) {
1010
const fetchUrl = new URL(input as string);
1111
// use cdn mirror, same split `cdn` to `fastly`
12-
fetchUrl.hostname = fetchUrl.hostname.replace(/^cdn\./, 'fastly.');
13-
console.log('fetching....', fetchUrl.href, init);
12+
fetchUrl.hostname = fetchUrl.hostname.replace(/^cdn\./, "fastly.");
13+
console.log("fetching....", fetchUrl.href, init);
1414
return fetch(fetchUrl.href, init);
1515
},
1616
delegate: {

src/components/CodeContainer/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Editor, type EditorProps, type OnMount, loader } from '@monaco-editor/react';
2-
import { createATA } from './ata';
1+
import { Editor, type EditorProps, type OnMount, loader } from "@monaco-editor/react";
2+
import { createATA } from "./ata";
33

44
loader.config({
55
paths: {
66
// node_modules\@monaco-editor\loader\lib\es\config\index.js
7-
vs: 'https://fastly.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs',
7+
vs: "https://fastly.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs",
88
},
99
});
1010

@@ -17,8 +17,8 @@ export interface CodeContainerFileInfo {
1717

1818
interface CodeContainerProps {
1919
file: CodeContainerFileInfo;
20-
onChange?: EditorProps['onChange'];
21-
options?: EditorProps['options'];
20+
onChange?: EditorProps["onChange"];
21+
options?: EditorProps["options"];
2222
}
2323

2424
export default function CodeContainer(props: CodeContainerProps) {
@@ -44,14 +44,14 @@ export default function CodeContainer(props: CodeContainerProps) {
4444

4545
return (
4646
<Editor
47-
height="100%"
48-
className="flex-1"
47+
height='100%'
48+
className='flex-1'
4949
path={file.name}
5050
language={file.language}
5151
value={file.value}
5252
onMount={handleEditorDidMount}
5353
onChange={onChange}
54-
loading="Feching monaco source"
54+
loading='Feching monaco source'
5555
options={{
5656
scrollBeyondLastLine: false,
5757
minimap: {

src/components/LazyLoading.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ interface LazyLoadingProps {
44

55
export default function LazyLoading(props: LazyLoadingProps) {
66
return (
7-
<div className="flex h-full w-full flex-col items-center justify-center">
8-
<div className="h-12 w-12 animate-spin rounded-full border-4 border-accent-foreground border-t-transparent" />
9-
{props.text && <p className="mt-4 text-center text-foreground">{props.text}</p>}
7+
<div className='flex h-full w-full flex-col items-center justify-center'>
8+
<div className='h-12 w-12 animate-spin rounded-full border-4 border-accent-foreground border-t-transparent' />
9+
{props.text && <p className='mt-4 text-center text-foreground'>{props.text}</p>}
1010
</div>
1111
);
1212
}

src/core/context/PlaygroundProvider.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { useCallback, useState } from 'react';
2-
import { type MultipleFiles, PlaygroundContext } from '.';
3-
import { fileName2Language } from '../util';
4-
import { defaultFiles } from '../files';
1+
import { useCallback, useState } from "react";
2+
import { type MultipleFiles, PlaygroundContext } from ".";
3+
import { fileName2Language } from "../util";
4+
import { defaultFiles } from "../files";
55

66
interface PlaygroundProviderProps {
77
children: React.ReactNode;
88
}
99
export const PlaygroundProvider = (props: PlaygroundProviderProps) => {
1010
const { children } = props;
1111
const [files, setFiles] = useState<MultipleFiles>(defaultFiles);
12-
const [selectedFileName, setSelectedFileName] = useState('main.tsx');
12+
const [selectedFileName, setSelectedFileName] = useState("main.tsx");
1313

1414
const addFile = useCallback(
1515
(name: string) => {
1616
files[name] = {
1717
name,
1818
language: fileName2Language(name),
19-
value: '',
19+
value: "",
2020
};
2121
setFiles({ ...files });
2222
},

src/core/context/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { CodeContainerFileInfo } from '@/components/CodeContainer';
2-
import { createContext } from 'react';
1+
import type { CodeContainerFileInfo } from "@/components/CodeContainer";
2+
import { createContext } from "react";
33

44
export interface MultipleFiles {
55
[key: string]: CodeContainerFileInfo;
@@ -16,5 +16,5 @@ export interface PlaygroundContextProps {
1616
}
1717

1818
export const PlaygroundContext = createContext<PlaygroundContextProps>({
19-
selectedFileName: 'App.tsx',
19+
selectedFileName: "App.tsx",
2020
} as PlaygroundContextProps);

src/core/files.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import type { MultipleFiles } from './context';
2-
import importMap from './templates/import-map.json?raw';
3-
import AppCss from './templates/App.css?raw';
4-
import App from './templates/App.tsx?raw';
5-
import main from './templates/main.tsx?raw';
6-
import { fileName2Language } from './util';
1+
import type { MultipleFiles } from "./context";
2+
import importMap from "./templates/import-map.json?raw";
3+
import AppCss from "./templates/App.css?raw";
4+
import App from "./templates/App.tsx?raw";
5+
import main from "./templates/main.tsx?raw";
6+
import { fileName2Language } from "./util";
77

88
// app 文件名
9-
export const APP_COMPONENT_FILE_NAME = 'App.tsx';
9+
export const APP_COMPONENT_FILE_NAME = "App.tsx";
1010
// esm 模块映射文件名
11-
export const IMPORT_MAP_FILE_NAME = 'import-map.json';
11+
export const IMPORT_MAP_FILE_NAME = "import-map.json";
1212
// app 入口文件名
13-
export const ENTRY_FILE_NAME = 'main.tsx';
13+
export const ENTRY_FILE_NAME = "main.tsx";
1414

1515
export const defaultFiles: MultipleFiles = {
1616
[ENTRY_FILE_NAME]: {
@@ -25,9 +25,9 @@ export const defaultFiles: MultipleFiles = {
2525
value: App,
2626
readonly: true,
2727
},
28-
'App.css': {
29-
name: 'App.css',
30-
language: 'css',
28+
"App.css": {
29+
name: "App.css",
30+
language: "css",
3131
value: AppCss,
3232
},
3333
[IMPORT_MAP_FILE_NAME]: {

src/core/templates/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { useState } from 'react';
2-
import './App.css';
1+
import { useState } from "react";
2+
import "./App.css";
33

44
function App() {
55
const [count, setCount] = useState(0);
66

77
return (
8-
<div className="App">
8+
<div className='App'>
99
<h1>Rspack + React + TypeScript</h1>
10-
<div className="card">
11-
<button type="button" onClick={() => setCount((count) => count + 1)}>
10+
<div className='card'>
11+
<button type='button' onClick={() => setCount((count) => count + 1)}>
1212
count is {count}
1313
</button>
1414
<p>

src/core/templates/main.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ReactDOM from 'react-dom/client';
2-
import App from './App.tsx';
1+
import ReactDOM from "react-dom/client";
2+
import App from "./App.tsx";
33

4-
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(<App />);
4+
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(<App />);

0 commit comments

Comments
 (0)