Skip to content

其他辅助类

  • 这些文件都在根目录下面

pnpm 工作区(关键)

  • 新建 pnpm-workspace.yaml

  • 新建build文件夹

  • 新建apps文件夹

  • 新建packages文件夹

bash

packages:
  # 根目录下的 docs 是一个独立的文档应用,应该被划分为一个模块
  - apps
  # packages 目录下的每一个目录都作为一个独立的模块
  - packages/*
  # - demo
  - build

样式格式化

  • 新建 .editorconfig
ts
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[Makefile]
indent_style = tab

lint-staged 配置文件

  • 新建 .lintstagedrc.json
ts
{
  "**/*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"],
  "**/*.vue": ["eslint --fix", "prettier --write", "stylelint --fix"],
  "**/*.{css,scss,less}": ["stylelint --fix", "prettier --write"],
  "**/*.{json,md,yml,yaml}": ["prettier --write"],
  "package.json": ["prettier --write"]
}

npm 配置文件

  • 新建 .npmrc
ts
# 默认 registry(继承全局配置)
registry=https://registry.npmmirror.com/
# pnpm 特有配置
shamefully-hoist=true
strict-peer-dependencies=false

# npm 配置
legacy-peer-deps=false

nvm 配置文件

  • 新建 .nvmrc,相当于不能低于这个版本
ts
22.14.0

stylelint 配置文件

  • 新建 .stylelintrc.json
json
{
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-standard-scss",
    "stylelint-config-recommended-vue"
  ],
  "overrides": [
    {
      "files": ["**/*.vue"],
      "customSyntax": "postcss-html"
    },
    {
      "files": ["**/*.scss"],
      "customSyntax": "postcss-scss"
    }
  ],
  "rules": {
    "color-hex-length": "short",
    "color-named": null,
    "selector-class-pattern": "^([a-z][a-z0-9]*)(-[a-z0-9]+)*(__[a-z0-9]+(-[a-z0-9]+)*)?(--[a-z0-9]+(-[a-z0-9]+)*)?$",
    "selector-max-universal": 1,
    "shorthand-property-no-redundant-values": true,
    "comment-whitespace-inside": "always",
    "max-nesting-depth": 4,
    "scss/load-no-partial-leading-underscore": true,
    "scss/at-import-partial-extension-disallowed-list": ["scss"],
    "scss/dollar-variable-colon-space-after": "always",
    "scss/dollar-variable-colon-space-before": "never",
    "scss/selector-no-redundant-nesting-selector": true
  },
  "ignoreFiles": [
    "node_modules/**",
    "**/node_modules/**",
    "**/dist/**",
    "**/build/**",
    "**/.vitepress/dist/**",
    "**/.vitepress/cache/**",
    "**/*.min.css",
    "**/*.min.js",
    "coverage/**",
    "**/coverage/**",
    "**/.turbo/**",
    ".turbo/**"
  ]
}