项目配置文件规范

Git忽略文件:.gitignore

# Misc files
*~
~*
._*
.DS_Store
Desktop.ini
Thumbs.db
.Spotlight-V100
.Trashes
 
# dependencies
node_modules
/.pnp
.pnp.js
 
# testing
/coverage
 
# Output files
dist/
 
# local env files
.env.local
.env.*.local
 
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
 
# Editor directories and files
.idea
.vscode
.settings/
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*

IDE配置文件:.editorconfig

root = true
  
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
  
[*.md]
indent_size = 4
trim_trailing_whitespace = false

NPM配置文件:.npmrc

save-prefix="~"
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
registry=https://registry.npm.taobao.org
@mi:registry=http://registry.npm.pt.mi.com

CSS样式检查文件:.stylelintrc


{
  // 引入标准配置文件和scss配置扩展
  extends: ['stylelint-config-standard', 'stylelint-config-recommended-scss'],
  // 根据组内约定修改以下自定义规则覆盖默认规则
  rules: {
    // 最大嵌套层级3层
    'max-nesting-depth': [3],
    // 引号必须为单引号
    'string-quotes': ['single'],
    // 冒号后要加空格
    'declaration-colon-space-after': ['always'],
    // 冒号前不加空格
    'declaration-colon-space-before': ['never'],
    // 变量后必须添加!default,本地局部变量可以不加
    'scss/dollar-variable-default': [true, { ignore: 'local' }],
    // 属性单独成行
    'declaration-block-single-line-max-declarations': [1],
    // 属性和值前不带厂商标记(通过autofixer自动添加,不要自己手工写)
    'property-no-vendor-prefix': [true],
    'value-no-vendor-prefix': [true],
    // 不能使用颜色名定义颜色,只能使用HEX、rgab或hsl格式
    'color-named': ['never'],
    // url值必须使用单引号包裹
    'function-url-quotes': ['always'],
    // 不要使用@while
    'at-rule-blacklist': ['while'],
    // 多选择器必须单独成行,逗号结尾
    'selector-list-comma-newline-after': ['always'],
    // 不能有无效的16进制颜色值
    'color-no-invalid-hex': [true]
  },
}

TS 配置文件:tsconfig.json

{
  "compilerOptions": {
    "baseUrl": ".",
    "experimentalDecorators": true,
    "downlevelIteration": true,
    "outDir": "ts-out",
    "module": "esnext",
    "target": "es5",
    "lib": [
      "es6",
      "dom"
    ],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDir": ".",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "resolveJsonModule": true
  },
  "exclude": [
    "node_modules"
  ],
}

TS 检查文件:tslint.json
 

{
  "extends": [
    "tslint-react"
  ],
  "rules": {
    "align": [
      true,
      "parameters",
      "arguments",
      "statements"
    ],
    "ban": false,
    "class-name": true,
    "comment-format": [
      true,
      "check-space"
    ],
    "curly": true,
    "eofline": false,
    "forin": false,
    "indent": [
      true,
      "spaces"
    ],
    "interface-name": [
      true,
      "never-prefix"
    ],
    "jsdoc-format": true,
    "jsx-no-lambda": false,
    "jsx-no-multiline-js": false,
    "label-position": true,
    "max-line-length": [
      true,
      0
    ],
    "no-any": false,
    "no-arg": true,
    "no-bitwise": false,
    "no-console": [
      false,
      "log",
      "error",
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-consecutive-blank-lines": true,
    "no-construct": true,
    "no-debugger": false,
    "no-duplicate-variable": true,
    "no-empty": false,
    "no-eval": true,
    "no-shadowed-variable": false,
    "no-string-literal": true,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": false,
    "no-unused-expression": false,
    "no-use-before-declare": true,
    "one-line": [
      true,
      "check-catch",
      "check-else",
      "check-open-brace",
      "check-whitespace"
    ],
    "quotemark": [
      true,
      "single",
      "jsx-single"
    ],
    "radix": false,
    "semicolon": [
      true,
      "never"
    ],
    "switch-default": true,
    "trailing-comma": false,
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef": [
      true,
      "parameter",
      "property-declaration"
    ],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      }
    ],
    "variable-name": [
      true,
      "ban-keywords",
      "check-format",
      "allow-leading-underscore",
      "allow-pascal-case"
    ],
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-module",
      "check-operator",
      "check-separator",
      "check-type",
      "check-typecast"
    ]
  }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值