chore: 🔨 代码格式化
This commit is contained in:
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"editor.tabSize": 2,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
|
||||
|
||||
@@ -1,123 +1,99 @@
|
||||
// https://eslint.nodejs.cn/docs/latest/use/configure/configuration-files
|
||||
|
||||
import globals from "globals";
|
||||
import js from "@eslint/js";
|
||||
import pluginJs from "@eslint/js"; // JavaScript 规则
|
||||
import pluginVue from "eslint-plugin-vue"; // Vue 规则
|
||||
import pluginTypeScript from "@typescript-eslint/eslint-plugin"; // TypeScript 规则
|
||||
|
||||
// ESLint 核心插件
|
||||
import pluginVue from "eslint-plugin-vue";
|
||||
import pluginTypeScript from "@typescript-eslint/eslint-plugin";
|
||||
import parserVue from "vue-eslint-parser"; // Vue 解析器
|
||||
import parserTypeScript from "@typescript-eslint/parser"; // TypeScript 解析器
|
||||
|
||||
// Prettier 插件及配置
|
||||
import configPrettier from "eslint-config-prettier";
|
||||
import pluginPrettier from "eslint-plugin-prettier";
|
||||
import configPrettier from "eslint-config-prettier"; // 禁用与 Prettier 冲突的规则
|
||||
import pluginPrettier from "eslint-plugin-prettier"; // 运行 Prettier 规则
|
||||
|
||||
// 解析器
|
||||
import * as parserVue from "vue-eslint-parser";
|
||||
import * as parserTypeScript from "@typescript-eslint/parser";
|
||||
// 解析自动导入配置
|
||||
import fs from "fs";
|
||||
const autoImportConfig = JSON.parse(fs.readFileSync(".eslintrc-auto-import.json", "utf-8"));
|
||||
|
||||
// 定义 ESLint 配置
|
||||
/** @type {import('eslint').Linter.Config[]} */
|
||||
export default [
|
||||
// 通用 JavaScript 配置
|
||||
// 指定检查文件和忽略文件
|
||||
{
|
||||
files: ["**/*.{js,mjs,cjs,ts,vue}"],
|
||||
ignores: ["**/*.d.ts"],
|
||||
},
|
||||
// 全局配置
|
||||
{
|
||||
...js.configs.recommended,
|
||||
ignores: [
|
||||
"/dist",
|
||||
"/public",
|
||||
"/node_modules",
|
||||
"**/*.min.js",
|
||||
"**/*.config.mjs",
|
||||
"**/*.tsbuildinfo",
|
||||
"/src/manifest.json",
|
||||
],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser, // 浏览器变量 (window, document 等)
|
||||
...globals.node, // Node.js 变量 (process, require 等)
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
...autoImportConfig.globals,
|
||||
...{
|
||||
PageQuery: "readonly",
|
||||
PageResult: "readonly",
|
||||
OptionType: "readonly",
|
||||
ResponseData: "readonly",
|
||||
ExcelResult: "readonly",
|
||||
TagView: "readonly",
|
||||
AppSettings: "readonly",
|
||||
__APP_INFO__: "readonly",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
prettier: pluginPrettier,
|
||||
},
|
||||
plugins: { prettier: pluginPrettier },
|
||||
rules: {
|
||||
...configPrettier.rules,
|
||||
...pluginPrettier.configs.recommended.rules,
|
||||
"no-debug": "off", // 禁止 debugger
|
||||
"prettier/prettier": [
|
||||
...configPrettier.rules, // 关闭与 Prettier 冲突的规则
|
||||
...pluginPrettier.configs.recommended.rules, // 启用 Prettier 规则
|
||||
"prettier/prettier": "error", // 强制 Prettier 格式化
|
||||
"no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
endOfLine: "auto", // 自动识别换行符
|
||||
argsIgnorePattern: "^_", // 忽略参数名以 _ 开头的参数未使用警告
|
||||
varsIgnorePattern: "^[A-Z0-9_]+$", // 忽略变量名为大写字母、数字或下划线组合的未使用警告(枚举定义未使用场景)
|
||||
ignoreRestSiblings: true, // 忽略解构赋值中同级未使用变量的警告
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
// JavaScript 配置
|
||||
pluginJs.configs.recommended,
|
||||
|
||||
// TypeScript 配置
|
||||
{
|
||||
files: ["**/*.?([cm])ts"],
|
||||
files: ["**/*.ts"],
|
||||
ignores: ["**/*.d.ts"], // 排除d.ts文件
|
||||
languageOptions: {
|
||||
parser: parserTypeScript,
|
||||
parserOptions: {
|
||||
sourceType: "module",
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
"@typescript-eslint": pluginTypeScript,
|
||||
},
|
||||
plugins: { "@typescript-eslint": pluginTypeScript },
|
||||
rules: {
|
||||
...pluginTypeScript.configs.strict.rules,
|
||||
...pluginTypeScript.configs.strict.rules, // TypeScript 严格规则
|
||||
"@typescript-eslint/no-explicit-any": "off", // 允许使用 any
|
||||
"@typescript-eslint/no-empty-function": "off", // 允许空函数
|
||||
"@typescript-eslint/no-empty-object-type": "off", // 允许空对象类型
|
||||
"@typescript-eslint/consistent-type-imports": [
|
||||
"error",
|
||||
{ disallowTypeAnnotations: false, fixStyle: "inline-type-imports" },
|
||||
], // 统一类型导入风格
|
||||
},
|
||||
},
|
||||
|
||||
// TypeScript 声明文件的特殊配置
|
||||
{
|
||||
files: ["**/*.d.ts"],
|
||||
rules: {
|
||||
"eslint-comments/no-unlimited-disable": "off",
|
||||
"unused-imports/no-unused-vars": "off",
|
||||
"@typescript-eslint/ban-ts-comment": "off", // 允许使用 @ts-nocheck 注释
|
||||
},
|
||||
},
|
||||
|
||||
// JavaScript (commonjs) 配置
|
||||
{
|
||||
files: ["**/*.?([cm])js"],
|
||||
rules: {
|
||||
"@typescript-eslint/no-var-requires": "off", // 允许 require
|
||||
},
|
||||
},
|
||||
|
||||
// Vue 文件配置
|
||||
// Vue 配置
|
||||
{
|
||||
files: ["**/*.vue"],
|
||||
languageOptions: {
|
||||
parser: parserVue,
|
||||
parserOptions: {
|
||||
parser: "@typescript-eslint/parser",
|
||||
parser: parserTypeScript,
|
||||
sourceType: "module",
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
vue: pluginVue,
|
||||
},
|
||||
plugins: { vue: pluginVue, "@typescript-eslint": pluginTypeScript },
|
||||
processor: pluginVue.processors[".vue"],
|
||||
rules: {
|
||||
...pluginVue.configs["vue3-recommended"].rules,
|
||||
...pluginVue.configs["vue3-recommended"].rules, // Vue 3 推荐规则
|
||||
"vue/no-v-html": "off", // 允许 v-html
|
||||
"vue/require-default-prop": "off", // 允许没有默认值的 prop
|
||||
"vue/multi-word-component-names": "off", // 关闭组件名称多词要求
|
||||
"vue/html-self-closing": [
|
||||
"error",
|
||||
{
|
||||
html: { void: "always", normal: "always", component: "always" },
|
||||
svg: "always",
|
||||
math: "always",
|
||||
},
|
||||
], // 自闭合标签
|
||||
"vue/multi-word-component-names": "off", // 允许单个单词组件名
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
12
index.html
12
index.html
@@ -1,13 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<script>
|
||||
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
|
||||
CSS.supports('top: constant(a)'))
|
||||
var coverSupport =
|
||||
"CSS" in window &&
|
||||
typeof CSS.supports === "function" &&
|
||||
(CSS.supports("top: env(a)") || CSS.supports("top: constant(a)"));
|
||||
document.write(
|
||||
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
|
||||
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
||||
(coverSupport ? ", viewport-fit=cover" : "") +
|
||||
'" />'
|
||||
);
|
||||
</script>
|
||||
<title></title>
|
||||
<!--preload-links-->
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "vue-uniapp-template",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev:app": "uni -p app",
|
||||
"dev:app-android": "uni -p app-android",
|
||||
@@ -42,6 +43,7 @@
|
||||
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
|
||||
"type-check": "vue-tsc --noEmit",
|
||||
"lint:eslint": "eslint --fix ./src",
|
||||
"lint:prettier": "prettier --write \"**/*.{js,cjs,ts,json,css,scss,vue,html,md}\"",
|
||||
"lint:stylelint": "stylelint \"**/*.{css,scss,vue,html}\" --fix",
|
||||
"lint:lint-staged": "lint-staged",
|
||||
"prepare": "husky",
|
||||
|
||||
8
shims-uni.d.ts
vendored
8
shims-uni.d.ts
vendored
@@ -1,10 +1,8 @@
|
||||
/// <reference types='@dcloudio/types' />
|
||||
import 'vue'
|
||||
import "vue";
|
||||
|
||||
declare module '@vue/runtime-core' {
|
||||
declare module "@vue/runtime-core" {
|
||||
type Hooks = App.AppInstance & Page.PageInstance;
|
||||
|
||||
interface ComponentCustomOptions extends Hooks {
|
||||
|
||||
}
|
||||
interface ComponentCustomOptions extends Hooks {}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,4 @@ $uni-font-size-title: 20px;
|
||||
$uni-color-subtitle: #555; // 二级标题颜色
|
||||
$uni-font-size-subtitle: 18px;
|
||||
$uni-color-paragraph: #3f536e; // 文章段落颜色
|
||||
$uni-font-size-paragraph: 15px;
|
||||
$uni-font-size-paragraph: 15px;
|
||||
|
||||
@@ -15,10 +15,7 @@ export default {
|
||||
"flex-center": "flex justify-center items-center flex-wrap",
|
||||
"flex-start": "flex justify-start items-center",
|
||||
"flex-end": "flex justify-end items-center",
|
||||
"flex-col-center": "flex flex-col justify-center items-center",
|
||||
"flex-between": "flex justify-between items-center",
|
||||
"fixed-bottom": "fixed bottom-0 left-0 right-0",
|
||||
"absolute-center": "absolute inset-0 flex justify-center items-center",
|
||||
},
|
||||
],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user