.eslintrc.json
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "formatjs", "prettier"],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"import/prefer-default-export": "off",
"react/prop-types": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/promise-function-async": "warn",
"@typescript-eslint/quotes": "off",
"@typescript-eslint/restrict-plus-operands": "warn",
"react/display-name": "off",
"no-redeclare": "off",
"id-blacklist": [
"error",
"any",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined"
],
"one-var": ["error", "never"],
"prefer-const": "error",
"prefer-object-spread": "error",
"prefer-template": "error",
"quote-props": "off",
"radix": "off",
"react/jsx-boolean-value": "error",
"react/jsx-key": "error",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
]
}
}
.eslintignore
node_modules
.DS_Store
dist
dist-ssr
*.local
vite.config.ts
tsconfig.json
src*.d.ts
scripts
mocks
.prettierignore
*.styl
.*ignore
.npmrc
.umi/
.DS_Store
CODEOWNERS
*.ejs
src/assets
!.*.js
dist/
nginx.conf
Dockerfile
Jenkinsfile
*.png
*.xml
*.styl.d.ts
/.docz
.gitignore
node_modules
.DS_Store
dist
dist-ssr
*.local
yarn-error.log
.vscode
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["vite/client"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"baseUrl": "./src",
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"sourceMap": true,
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["./src"],
"exclude": ["node_modules"]
}
vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import fs from 'fs'
import getThemeVariables from '@ant-design/aliyun-theme/'
import { viteMockServe } from 'vite-plugin-mock'
const paths = fs.readdirSync(path.resolve(__dirname, 'src'))
const alias = paths
.filter((p) => {
const stat = fs.statSync(path.resolve(__dirname, 'src/', p))
return stat.isDirectory()
})
.map((p) => ({
find: p,
replacement: path.resolve(__dirname, 'src/', p),
}))
export default defineConfig({
plugins: [
react({
jsxRuntime: 'classic',
babel: {
plugins: [
['@emotion'],
[
'formatjs',
{
idInterpolationPattern: '[sha512:contenthash:base64:6]',
removeDefaultMessage: true,
},
],
],
},
}),
viteMockServe({
mockPath: './mocks',
localEnabled: !!process.env.VITE_APP_MOCK,
}),
],
resolve: {
alias: [...alias, { find: /^~/, replacement: '' }],
},
css: {
preprocessorOptions: {
less: {
modifyVars: getThemeVariables,
javascriptEnabled: true,
},
},
},
esbuild: {},
server: {
hmr: {
protocol: 'ws',
host: 'localhost',
port: 3001,
},
port: 3001,
proxy: process.env.VITE_APP_MOCK
? null
: {
'/api/': {
target: '项目IP:端口号 或者网址',
secure: false,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
})
|