feat: 更新模板
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*]
|
[*]
|
||||||
indent_size = 2
|
|
||||||
max_line_length = 100
|
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
indent_style = space
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/prettierrc.json",
|
"$schema": "https://json.schemastore.org/prettierrc",
|
||||||
"tabWidth": 2,
|
|
||||||
"printWidth": 100,
|
"printWidth": 100,
|
||||||
"semi": true,
|
"tabWidth": 2,
|
||||||
"useTabs": false,
|
"singleQuote": true,
|
||||||
"singleQuote": false,
|
"jsxSingleQuote": true,
|
||||||
"bracketSpacing": false,
|
"trailingComma": "all",
|
||||||
"endOfLine": "auto",
|
"semi": false,
|
||||||
|
"bracketSpacing": true,
|
||||||
"arrowParens": "always",
|
"arrowParens": "always",
|
||||||
"trailingComma": "all"
|
"endOfLine": "lf"
|
||||||
}
|
}
|
||||||
|
|||||||
175
eslint.config.js
175
eslint.config.js
@@ -1,139 +1,46 @@
|
|||||||
import {defineConfig, globalIgnores} from 'eslint/config'
|
|
||||||
import {fixupConfigRules, fixupPluginRules} from '@eslint/compat'
|
|
||||||
import react from 'eslint-plugin-react'
|
|
||||||
import unusedImports from 'eslint-plugin-unused-imports'
|
|
||||||
import _import from 'eslint-plugin-import'
|
|
||||||
import typescriptEslint from '@typescript-eslint/eslint-plugin'
|
|
||||||
import jsxA11Y from 'eslint-plugin-jsx-a11y'
|
|
||||||
import prettier from 'eslint-plugin-prettier'
|
|
||||||
import globals from 'globals'
|
|
||||||
import tsParser from '@typescript-eslint/parser'
|
|
||||||
import path from 'node:path'
|
|
||||||
import {fileURLToPath} from 'node:url'
|
|
||||||
import js from '@eslint/js'
|
import js from '@eslint/js'
|
||||||
import {FlatCompat} from '@eslint/eslintrc'
|
import prettierConfig from 'eslint-config-prettier'
|
||||||
|
import importPlugin from 'eslint-plugin-import'
|
||||||
|
import prettierPlugin from 'eslint-plugin-prettier'
|
||||||
|
import reactHooks from 'eslint-plugin-react-hooks'
|
||||||
|
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||||
|
import globals from 'globals'
|
||||||
|
import tseslint from 'typescript-eslint'
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url)
|
export default [
|
||||||
const __dirname = path.dirname(__filename)
|
{
|
||||||
const compat = new FlatCompat({
|
ignores: ['dist'],
|
||||||
baseDirectory: __dirname,
|
|
||||||
recommendedConfig: js.configs.recommended,
|
|
||||||
allConfig: js.configs.all
|
|
||||||
})
|
|
||||||
|
|
||||||
export default defineConfig([globalIgnores([
|
|
||||||
'**/*.css',
|
|
||||||
'**/.changeset',
|
|
||||||
'**/dist',
|
|
||||||
'esm/*',
|
|
||||||
'public/*',
|
|
||||||
'tests/*',
|
|
||||||
'scripts/*',
|
|
||||||
'**/*.config.js',
|
|
||||||
'**/.DS_Store',
|
|
||||||
'**/node_modules',
|
|
||||||
'**/coverage'
|
|
||||||
]), {
|
|
||||||
extends: fixupConfigRules(compat.extends(
|
|
||||||
'plugin:react/recommended',
|
|
||||||
'plugin:prettier/recommended',
|
|
||||||
'plugin:react-hooks/recommended',
|
|
||||||
'plugin:jsx-a11y/recommended'
|
|
||||||
)),
|
|
||||||
|
|
||||||
plugins: {
|
|
||||||
react: fixupPluginRules(react),
|
|
||||||
'unused-imports': unusedImports,
|
|
||||||
import: fixupPluginRules(_import),
|
|
||||||
'@typescript-eslint': typescriptEslint,
|
|
||||||
'jsx-a11y': fixupPluginRules(jsxA11Y),
|
|
||||||
prettier: fixupPluginRules(prettier)
|
|
||||||
},
|
},
|
||||||
|
js.configs.recommended,
|
||||||
languageOptions: {
|
...tseslint.configs.recommended,
|
||||||
globals: {
|
{
|
||||||
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])),
|
files: ['**/*.{ts,tsx,js,jsx}'],
|
||||||
...globals.node
|
plugins: {
|
||||||
|
'@typescript-eslint': tseslint.plugin,
|
||||||
|
'react-hooks': reactHooks,
|
||||||
|
'react-refresh': reactRefresh,
|
||||||
|
prettier: prettierPlugin,
|
||||||
|
import: importPlugin,
|
||||||
|
},
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: 2020,
|
||||||
|
globals: globals.browser,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...reactHooks.configs.recommended.rules,
|
||||||
|
'prettier/prettier': ['error', { endOfLine: 'auto' }],
|
||||||
|
'import/order': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
groups: [['builtin', 'external'], 'internal', ['parent', 'sibling', 'index']],
|
||||||
|
'newlines-between': 'always',
|
||||||
|
alphabetize: {
|
||||||
|
order: 'asc',
|
||||||
|
caseInsensitive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
parser: tsParser,
|
|
||||||
ecmaVersion: 12,
|
|
||||||
sourceType: 'module',
|
|
||||||
|
|
||||||
parserOptions: {
|
|
||||||
ecmaFeatures: {
|
|
||||||
jsx: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
prettierConfig,
|
||||||
settings: {
|
]
|
||||||
react: {
|
|
||||||
version: 'detect'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
files: [
|
|
||||||
'**/*.{ts,tsx,js,jsx}'
|
|
||||||
],
|
|
||||||
|
|
||||||
rules: {
|
|
||||||
'no-console': 'warn',
|
|
||||||
'react/prop-types': 'off',
|
|
||||||
'react/jsx-uses-react': 'off',
|
|
||||||
'react/react-in-jsx-scope': 'off',
|
|
||||||
'react-hooks/exhaustive-deps': 'off',
|
|
||||||
'jsx-a11y/click-events-have-key-events': 'warn',
|
|
||||||
'jsx-a11y/interactive-supports-focus': 'warn',
|
|
||||||
'prettier/prettier': 'warn',
|
|
||||||
'no-unused-vars': 'off',
|
|
||||||
'unused-imports/no-unused-vars': 'off',
|
|
||||||
'unused-imports/no-unused-imports': 'warn',
|
|
||||||
|
|
||||||
'@typescript-eslint/no-unused-vars': ['warn', {
|
|
||||||
args: 'after-used',
|
|
||||||
ignoreRestSiblings: false,
|
|
||||||
argsIgnorePattern: '^_.*?$'
|
|
||||||
}],
|
|
||||||
|
|
||||||
'import/order': ['error', {
|
|
||||||
'groups': [['external', 'builtin'], 'internal', 'parent', 'sibling', 'index'],
|
|
||||||
|
|
||||||
alphabetize: {
|
|
||||||
order: 'asc',
|
|
||||||
caseInsensitive: true
|
|
||||||
},
|
|
||||||
|
|
||||||
'newlines-between': 'always'
|
|
||||||
}],
|
|
||||||
|
|
||||||
'react/self-closing-comp': 'warn',
|
|
||||||
|
|
||||||
'react/jsx-sort-props': ['warn', {
|
|
||||||
callbacksLast: true,
|
|
||||||
shorthandFirst: true,
|
|
||||||
noSortAlphabetically: false,
|
|
||||||
reservedFirst: true
|
|
||||||
}],
|
|
||||||
|
|
||||||
'padding-line-between-statements': ['warn', {
|
|
||||||
blankLine: 'always',
|
|
||||||
prev: '*',
|
|
||||||
next: 'return'
|
|
||||||
}, {
|
|
||||||
blankLine: 'always',
|
|
||||||
prev: ['const', 'let', 'var'],
|
|
||||||
next: '*'
|
|
||||||
}, {
|
|
||||||
blankLine: 'any',
|
|
||||||
prev: ['const', 'let', 'var'],
|
|
||||||
next: ['const', 'let', 'var']
|
|
||||||
}],
|
|
||||||
|
|
||||||
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
|
|
||||||
|
|
||||||
'@typescript-eslint/consistent-type-imports': ['error', {
|
|
||||||
fixStyle: 'inline-type-imports'
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}])
|
|
||||||
|
|||||||
21
package.json
21
package.json
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "react-template",
|
"name": "react-tmpl",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -7,45 +7,34 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"lint": "npm run eslint && npm run stylelint",
|
"lint": "eslint . --fix",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
"eslint": "eslint . --cache",
|
"format": "prettier --write src/",
|
||||||
"stylelint": "stylelint '**/*.css' --cache",
|
"type-check": "vue-tsc --build"
|
||||||
"prettier": "prettier --check \"**/*.{ts,tsx}\"",
|
|
||||||
"prettier:write": "prettier --write \"**/*.{ts,tsx}\""
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^19.1.1",
|
"react": "^19.1.1",
|
||||||
"react-dom": "^19.1.1"
|
"react-dom": "^19.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^1.3.2",
|
|
||||||
"@eslint/eslintrc": "^3.3.1",
|
|
||||||
"@eslint/js": "^9.33.0",
|
"@eslint/js": "^9.33.0",
|
||||||
"@types/node": "^24.5.1",
|
|
||||||
"@types/react": "^19.1.10",
|
"@types/react": "^19.1.10",
|
||||||
"@types/react-dom": "^19.1.7",
|
"@types/react-dom": "^19.1.7",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
||||||
"@typescript-eslint/parser": "^8.44.0",
|
|
||||||
"@vitejs/plugin-react-swc": "^4.0.0",
|
"@vitejs/plugin-react-swc": "^4.0.0",
|
||||||
"eslint": "^9.33.0",
|
"eslint": "^9.33.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
||||||
"eslint-plugin-prettier": "^5.5.4",
|
"eslint-plugin-prettier": "^5.5.4",
|
||||||
"eslint-plugin-react": "^7.37.5",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.20",
|
"eslint-plugin-react-refresh": "^0.4.20",
|
||||||
"eslint-plugin-unused-imports": "^4.2.0",
|
|
||||||
"globals": "^16.3.0",
|
"globals": "^16.3.0",
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.6.2",
|
||||||
"prettier-eslint": "^16.4.2",
|
|
||||||
"prettier-eslint-cli": "^8.0.1",
|
|
||||||
"stylelint": "^16.24.0",
|
|
||||||
"typescript": "~5.8.3",
|
"typescript": "~5.8.3",
|
||||||
"typescript-eslint": "^8.39.1",
|
"typescript-eslint": "^8.39.1",
|
||||||
"vite": "^7.1.2",
|
"vite": "^7.1.2",
|
||||||
|
"vite-plugin-checker": "^0.10.3",
|
||||||
"vite-tsconfig-paths": "^5.1.4"
|
"vite-tsconfig-paths": "^5.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1832
pnpm-lock.yaml
generated
1832
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
|||||||
ignoredBuiltDependencies:
|
|
||||||
- esbuild
|
|
||||||
|
|
||||||
onlyBuiltDependencies:
|
|
||||||
- '@swc/core'
|
|
||||||
17
src/main.tsx
17
src/main.tsx
@@ -1,13 +1,12 @@
|
|||||||
import {StrictMode} from "react";
|
import { StrictMode } from 'react'
|
||||||
import {createRoot} from "react-dom/client";
|
import { createRoot } from 'react-dom/client'
|
||||||
import "./index.js";
|
|
||||||
import "./index.css";
|
|
||||||
import "./aaa.css";
|
|
||||||
|
|
||||||
import App from "@/pages/app/index";
|
import Home from '@/pages/home/index'
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
import './index.css'
|
||||||
|
|
||||||
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<App />
|
<Home />
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
);
|
)
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
export default function App() {
|
|
||||||
|
|
||||||
return <div>app</div>
|
|
||||||
}
|
|
||||||
12
src/pages/home/index.tsx
Normal file
12
src/pages/home/index.tsx
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
const [num, setNum] = useState(0)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setNum(1)
|
||||||
|
console.log(num)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return <div>home</div>
|
||||||
|
}
|
||||||
@@ -9,10 +9,13 @@
|
|||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
"lib": [
|
||||||
|
"ES2022",
|
||||||
|
"DOM",
|
||||||
|
"DOM.Iterable"
|
||||||
|
],
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|
||||||
/* Bundler mode */
|
/* Bundler mode */
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"allowImportingTsExtensions": true,
|
"allowImportingTsExtensions": true,
|
||||||
@@ -20,7 +23,6 @@
|
|||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
|
|
||||||
/* Linting */
|
/* Linting */
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
@@ -29,5 +31,7 @@
|
|||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"noUncheckedSideEffectImports": true
|
"noUncheckedSideEffectImports": true
|
||||||
},
|
},
|
||||||
"include": ["src"]
|
"include": [
|
||||||
|
"src"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
{
|
{
|
||||||
"files": [],
|
"files": [],
|
||||||
"references": [
|
"references": [
|
||||||
{
|
{ "path": "./tsconfig.app.json" },
|
||||||
"path": "./tsconfig.app.json"
|
{ "path": "./tsconfig.node.json" }
|
||||||
},
|
]
|
||||||
{
|
|
||||||
"path": "./tsconfig.node.json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
"target": "ES2023",
|
"target": "ES2023",
|
||||||
"lib": [
|
"lib": ["ES2023"],
|
||||||
"ES2023"
|
|
||||||
],
|
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|
||||||
/* Bundler mode */
|
/* Bundler mode */
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"allowImportingTsExtensions": true,
|
"allowImportingTsExtensions": true,
|
||||||
"verbatimModuleSyntax": true,
|
"verbatimModuleSyntax": true,
|
||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
|
||||||
/* Linting */
|
/* Linting */
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
@@ -21,7 +21,5 @@
|
|||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"noUncheckedSideEffectImports": true
|
"noUncheckedSideEffectImports": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["vite.config.ts"]
|
||||||
"vite.config.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
import {defineConfig} from 'vite'
|
import {defineConfig} from "vite";
|
||||||
import react from '@vitejs/plugin-react-swc'
|
import react from "@vitejs/plugin-react-swc";
|
||||||
import tsconfigPaths from "vite-tsconfig-paths";
|
import tsconfigPaths from "vite-tsconfig-paths";
|
||||||
|
import checker from "vite-plugin-checker";
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react(), tsconfigPaths()],
|
plugins: [
|
||||||
})
|
react(),
|
||||||
|
tsconfigPaths(),
|
||||||
|
checker({
|
||||||
|
typescript: true, // 开启 TypeScript 检查
|
||||||
|
eslint: {
|
||||||
|
lintCommand: "eslint \"./src/**/*.{ts,tsx}\"", // 自定义 eslint 命令
|
||||||
|
},
|
||||||
|
})],
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user