Browse Source

feat 增加配置

Jason 1 month ago
parent
commit
454ab16a5b
7 changed files with 152 additions and 0 deletions
  1. 15 0
      .editorconfig
  2. 3 0
      .eslintignore
  3. 49 0
      .eslintrc.cjs
  4. 25 0
      .gitignore
  5. 21 0
      .prettierrc.cjs
  6. 3 0
      .vscode/extensions.json
  7. 36 0
      .vscode/settings.json

+ 15 - 0
.editorconfig

@@ -0,0 +1,15 @@
+# @see: http://editorconfig.org
+
+root = true
+
+[*] # 表示所有文件适用
+charset = utf-8 # 设置文件字符集为 utf-8
+end_of_line = lf # 控制换行类型(lf | cr | crlf)
+insert_final_newline = true # 始终在文件末尾插入一个新行
+indent_style = space # 缩进风格(tab | space)
+indent_size = 2 # 缩进大小
+max_line_length = 130 # 最大行长度
+
+[*.md] # 表示仅对 md 文件适用以下规则
+max_line_length = off # 关闭最大行长度限制
+trim_trailing_whitespace = false # 关闭末尾空格修剪

+ 3 - 0
.eslintignore

@@ -0,0 +1,3 @@
+node_modules
+public
+dist

+ 49 - 0
.eslintrc.cjs

@@ -0,0 +1,49 @@
+module.exports = {
+  root: true,
+  env: {
+    browser: true,
+    node: true,
+    es2021: true
+  },
+  parser: 'vue-eslint-parser',
+  extends: [
+    'eslint:recommended',
+    'plugin:vue/vue3-recommended',
+    'plugin:@typescript-eslint/recommended',
+    'plugin:prettier/recommended',
+    // eslint-config-prettier 的缩写
+    'prettier',
+    'vue-global-api'
+  ],
+  parserOptions: {
+    ecmaVersion: 12,
+    parser: '@typescript-eslint/parser',
+    sourceType: 'module',
+    ecmaFeatures: {
+      jsx: true
+    }
+  },
+  // eslint-plugin-vue @typescript-eslint/eslint-plugin eslint-plugin-prettier的缩写
+  plugins: ['vue', '@typescript-eslint', 'prettier'],
+  rules: {
+    '@typescript-eslint/ban-ts-ignore': 'off',
+    '@typescript-eslint/no-unused-vars': 'off',
+    '@typescript-eslint/explicit-function-return-type': 'off',
+    '@typescript-eslint/no-explicit-any': 'off',
+    '@typescript-eslint/no-var-requires': 'off',
+    '@typescript-eslint/no-empty-function': 'off',
+    '@typescript-eslint/no-use-before-define': 'off',
+    '@typescript-eslint/ban-ts-comment': 'off',
+    '@typescript-eslint/ban-types': 'off',
+    '@typescript-eslint/no-non-null-assertion': 'off',
+    '@typescript-eslint/explicit-module-boundary-types': 'off',
+    'vue/multi-word-component-names': 'off',
+    'no-undef': 'off'
+  },
+  globals: {
+    defineProps: 'readonly',
+    defineEmits: 'readonly',
+    defineExpose: 'readonly',
+    withDefaults: 'readonly'
+  }
+};

+ 25 - 0
.gitignore

@@ -0,0 +1,25 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+lerna-debug.log*
+
+node_modules
+dist
+dist-ssr
+*.local
+
+# Editor directories and files
+.DS_Store
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
+
+# auto-import, auto-components
+src/types/auto-imports.d.ts
+src/types/components.d.ts

+ 21 - 0
.prettierrc.cjs

@@ -0,0 +1,21 @@
+module.exports = {
+  printWidth: 130, // 超过最大值换行
+  tabWidth: 2, // 缩进字节数
+  useTabs: false, // 缩进使用tab,不使用空格
+  semi: true, // 句尾添加分号
+  singleQuote: true, // 使用单引号代替双引号
+  proseWrap: "preserve", // 默认值。因为使用了一些折行敏感型的渲染器(如GitHub comment)而按照markdown文本样式进行折行
+  arrowParens: "avoid", //  (x) => {} 箭头函数参数只有一个时是否要有小括号。avoid:省略括号
+  bracketSpacing: true, // 在对象,数组括号与文字之间加空格 "{ foo: bar }"
+  endOfLine: "auto", // 结尾是 \n \r \n\r auto
+  jsxSingleQuote: false, // 在jsx中使用单引号代替双引号
+  trailingComma: "none", // 在对象或数组最后一个元素后面是否加逗号(在ES5中加尾逗号)
+  overrides: [
+    {
+      files: "*.html",
+      options: {
+        parser: "html",
+      },
+    },
+  ],
+};

+ 3 - 0
.vscode/extensions.json

@@ -0,0 +1,3 @@
+{
+  "recommendations": ["Vue.volar"]
+}

+ 36 - 0
.vscode/settings.json

@@ -0,0 +1,36 @@
+{
+  // 开启自动修复
+  "editor.codeActionsOnSave": {
+    "source.fixAll": "explicit",
+    "source.fixAll.eslint": "explicit",
+    "source.fixAll.stylelint": "explicit"
+  },
+  "eslint.validate": [
+    "javascript",
+    "javascriptreact",
+    "typescript",
+    "typescriptreact",
+    "html",
+    "vue",
+    "markdown",
+    "json",
+    "jsonc"
+  ],
+  // 保存的时候自动格式化
+  "editor.formatOnSave": true,
+  // 默认格式化工具选择prettier
+  "editor.defaultFormatter": "esbenp.prettier-vscode",
+  // 配置该项,新建文件时默认就是space:2
+  "editor.tabSize": 2,
+  // stylelint校验的文件格式
+  "stylelint.validate": ["css", "less", "vue", "html", "scss", "sass"],
+  "cSpell.words": [
+    "composables",
+    "oper",
+    "sider",
+    "yapi"
+  ],
+  "i18n-ally.localesPaths": [
+    "src/i18n"
+  ]
+}