瀏覽代碼

refactor(其它变更): 基础框架

初始化基础框架
gemercheung 2 年之前
當前提交
95106bb7db

+ 42 - 0
.cz-config.js

@@ -0,0 +1,42 @@
+module.exports = {
+  types: [
+    { value: "feat", name: "feat 🍄:    新增新的特性" },
+    { value: "fix", name: "fix 🐛:    修复 BUG" },
+    { value: "docs", name: "docs 📄:    修改文档、注释" }, 
+    {
+      value: "refactor",
+      name: "refactor 🎸:    代码重构,注意和特性、修复区分开",
+    },
+    { value: "chore", name: "chore 🧹:   构建过程或辅助工具的变动" },
+    { value: "perf", name: "perf ⚡:    提升性能" },
+    { value: "test", name: "test 👀:    添加一个测试" },
+    { value: "tool", name: "tool 🚗:    开发工具变动(构建、脚手架工具等)" },
+    { value: "style", name: "style ✂:    对代码格式的修改不影响逻辑" },
+    { value: "revert", name: "revert 🌝:     版本回滚" },
+    { value: "update", name: "update ⬆:    第三方库升级 " },
+  ],
+
+  scopes: [
+    { name: "组件" },
+    { name: "样式" },
+    { name: "文档更改" },
+    { name: "其它变更" },
+  ],
+  allowTicketNumber: false,
+  isTicketNumberRequired: false,
+  ticketNumberPrefix: "TICKET-",
+  ticketNumberRegExp: "d{1,5}",
+  messages: {
+    type: "选择一种你的提交类型:",
+    scope: "选择一个scope (可选):",
+    customScope: "Denote the SCOPE of this change:",
+    subject: "简要说明:\n",
+    body: '详细说明,使用"|"换行(可选):\n',
+    breaking: "非兼容性说明 (可选):\n",
+    footer: "关联关闭的issue,例如:#31, #34(可选):\n",
+    confirmCommit: "确定提交?",
+  },
+  allowCustomScopes: true,
+  allowBreakingChanges: ["新增", "修复"],
+  subjectLimit: 100,
+};

+ 7 - 0
.eslintignore

@@ -0,0 +1,7 @@
+node_modules
+!.*
+dist
+build
+
+
+examples/cra-ejected-babel

+ 81 - 0
.eslintrc.js

@@ -0,0 +1,81 @@
+// @ts-check
+const { defineConfig } = require("eslint-define-config");
+module.exports = defineConfig({
+  root: true,
+  env: {
+    browser: true,
+    node: true,
+    es6: true,
+  },
+  parser: "vue-eslint-parser",
+  parserOptions: {
+    parser: "@typescript-eslint/parser",
+    ecmaVersion: 2020,
+    sourceType: "module",
+    jsxPragma: "React",
+    ecmaFeatures: {
+      jsx: true,
+    },
+  },
+  extends: [
+    "plugin:vue/vue3-recommended",
+    "plugin:@typescript-eslint/recommended",
+    "prettier",
+    "plugin:prettier/recommended",
+    "plugin:jest/recommended",
+  ],
+  rules: {
+    "vue/script-setup-uses-vars": "error",
+    "@typescript-eslint/ban-ts-ignore": "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",
+    "vue/custom-event-name-casing": "off",
+    "no-use-before-define": "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",
+    "@typescript-eslint/no-unused-vars": [
+      "error",
+      {
+        argsIgnorePattern: "^_",
+        varsIgnorePattern: "^_",
+      },
+    ],
+    "no-unused-vars": [
+      "error",
+      {
+        argsIgnorePattern: "^_",
+        varsIgnorePattern: "^_",
+      },
+    ],
+    "space-before-function-paren": "off",
+
+    "vue/attributes-order": "off",
+    "vue/one-component-per-file": "off",
+    "vue/html-closing-bracket-newline": "off",
+    "vue/max-attributes-per-line": "off",
+    "vue/multiline-html-element-content-newline": "off",
+    "vue/singleline-html-element-content-newline": "off",
+    "vue/attribute-hyphenation": "off",
+    "vue/require-default-prop": "off",
+    "vue/require-explicit-emits": "off",
+    "vue/no-useless-template-attributes": "off",
+    "vue/html-self-closing": [
+      "error",
+      {
+        html: {
+          void: "always",
+          normal: "never",
+          component: "always",
+        },
+        svg: "always",
+        math: "always",
+      },
+    ],
+    "vue/multi-word-component-names": "off",
+  },
+});

+ 36 - 0
.github/workflows/tests.yml

@@ -0,0 +1,36 @@
+name: tests
+
+on:
+  push:
+  pull_request:
+    branches: [ $default-branch ]
+
+jobs:
+  tests:
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - uses: pnpm/action-setup@v2.2.2
+        with:
+          version: latest
+
+      - name: Install Node
+        uses: actions/setup-node@v3
+        with:
+          node-version: 14
+          cache: 'pnpm'
+
+      - name: Install dependencies
+        run: pnpm i
+
+      - name: Lint
+        run: pnpm run lint
+
+      - name: Build
+        run: pnpm run build
+
+      - name: Test
+        run: pnpm run test

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+node_modules
+**/dist
+results
+.nyc_output
+*.tsbuildinfo

+ 21 - 0
LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2019 Gemer Cheung
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 1 - 0
README.md

@@ -0,0 +1 @@
+# 4dkankan components collection

+ 39 - 0
package.json

@@ -0,0 +1,39 @@
+{
+  "name": "4dkankan-components",
+  "description": "a collection of 4dkankan components",
+  "private": true,
+  "workspaces": [
+    "packages/*",
+    "apps/*"
+  ],
+  "scripts": {
+    "docs": "doctoc --title '**Table of content**' README.md",
+    "clean": "pnpm run -r clean",
+    "build": "pnpm run -r build",
+    "test": "pnpm run -r test",
+    "lint": "eslint --ext js,ts . --fix",
+    "commit": "git cz"
+  },
+  "devDependencies": {
+    "@commitlint/cli": "^17.1.2",
+    "@nighttrax/eslint-config-tsx": "~10.0.0-beta.0",
+    "commitizen": "^4.2.5",
+    "commitlint-config-cz": "^0.13.3",
+    "cz-customizable": "^7.0.0",
+    "doctoc": "~2.2.0",
+    "eslint": "~8.23.0",
+    "eslint-plugin-import": "~2.26.0",
+    "husky": "^8.0.1",
+    "typescript": "~4.7.0",
+    "eslint-config-prettier": "^8.5.0",
+    "eslint-define-config": "^1.7.0",
+    "eslint-plugin-jest": "^25.7.0",
+    "eslint-plugin-prettier": "^4.2.1",
+    "eslint-plugin-vue": "^8.7.1"
+  },
+  "config": {
+    "commitizen": {
+      "path": "cz-customizable"
+    }
+  }
+}

+ 13 - 0
packages/commitlint-config.js

@@ -0,0 +1,13 @@
+module.exports = {
+  extends: ["cz"],
+  parserPreset: {
+    parserOpts: {
+      headerPattern: /^(\w*)\(([\u4e00-\u9fa5]*)\)/,
+      headerCorrespondence: ["type", "scope"],
+    },
+  },
+  rules: {
+    "type-empty": [2, "never"],
+    "scope-empty": [2, "never"],
+  },
+};

+ 19 - 0
packages/foo/package.json

@@ -0,0 +1,19 @@
+{
+  "name": "@kankan-components/foo",
+  "version": "1.0.0",
+  "main": "dist/index",
+  "types": "dist/index",
+  "files": [
+    "dist"
+  ],
+  "scripts": {
+    "build": "pnpm run clean && pnpm run compile",
+    "clean": "rimraf -rf ./dist",
+    "compile": "tsc -p tsconfig.build.json",
+    "prepublishOnly": "pnpm run build"
+  },
+  "devDependencies": {
+    "rimraf": "~3.0.2",
+    "typescript": "~4.7.0"
+  }
+}

+ 0 - 0
packages/foo/src/index.ts


+ 11 - 0
packages/foo/tsconfig.build.json

@@ -0,0 +1,11 @@
+{
+  "extends": "../../tsconfig.build.json",
+
+  "compilerOptions": {
+    "outDir": "./dist"
+  },
+
+  "include": [
+    "src/**/*"
+  ]
+}

+ 3 - 0
packages/foo/tsconfig.json

@@ -0,0 +1,3 @@
+{
+  "extends": "../../tsconfig.json"
+}

文件差異過大導致無法顯示
+ 19348 - 0
pnpm-lock.yaml


+ 3 - 0
pnpm-workspace.yaml

@@ -0,0 +1,3 @@
+packages:
+  - 'packages/**'
+  - 'apps/**'

+ 8 - 0
renovate.json

@@ -0,0 +1,8 @@
+{
+  "extends": [
+    "config:base"
+  ],
+  "ignorePresets": [":ignoreModulesAndTests"],
+  "rangeStrategy": "replace",
+  "automerge": true
+}

+ 19 - 0
tsconfig.build.json

@@ -0,0 +1,19 @@
+{
+  "compilerOptions": {
+    "module": "commonjs",
+    "target": "es5",
+    "sourceMap": true,
+    "declaration": true,
+    "declarationMap": true,
+    "noEmitOnError": true,
+    "skipLibCheck": true,
+    "esModuleInterop": true,
+    "types": [],
+    "jsx": "react",
+    "noEmit": false
+  },
+  "exclude": [
+    "node_modules",
+    "dist"
+  ]
+}

+ 12 - 0
tsconfig.json

@@ -0,0 +1,12 @@
+{
+  "extends": "./tsconfig.build.json",
+
+  "compilerOptions": {
+    "baseUrl": ".",
+    "paths": {
+      "@nighttrax/components/*": ["packages/components/src/*"],
+      "@nighttrax/*": ["packages/*/src"]
+    },
+    "noEmit": true
+  }
+}