2.0.3 • Published 4 months ago

@zpcscc/configs v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@zpcscc/configs

NPM version NPM downloads

简介

通用配置库

安装

npm install --save-dev @zpcscc/configs

使用

eslint

.eslintrc.js

基础配置

module.exports = {
  extends: [require.resolve('@zpcscc/configs/eslint-config')],
};

react的eslint配置

module.exports = {
  extends: [require.resolve('@zpcscc/configs/eslint-config/react')],
};

vue的eslint配置

module.exports = {
  extends: [require.resolve('@zpcscc/configs/eslint-config/vue')],
};

node的eslint配置

module.exports = {
  extends: [require.resolve('@zpcscc/configs/eslint-config/node')],
};

补充配置

module.exports = {
  // 由于使用了eslint-config-standard-with-typescript插件对ts的支持
  // 部分规则需要tsconfig.json配置,需要在这里引入tsconfig.json文件
  parserOptions: {
    project: ['./tsconfig.json'],
  },
};

tsconfig.json

tsconfig.json 文件中,也需要在 include 中引入.eslintrc.js 文件

{
  "include": [".eslintrc.js"]
}

prettier

.prettierrc

'@zpcscc/configs/prettier-config';

.prettierrc.js

module.exports = {
  ...require('@zpcscc/configs/prettier-config'),
};

stylelint

.stylelintrc

{
  "extends": "@zpcscc/configs/stylelint-config"
}

stylelint.config.js

module.exports = { 
  extends: ['@zpcscc/configs/stylelint-config'],
}

tsconfig

tsconfig.json

基础配置

{
  "extends": "@zpcscc/configs/tsconfig/tsconfig.base.json",
}

react的tsconfig配置

{
  "extends": "@zpcscc/configs/tsconfig/tsconfig.react.json",
}

vue的tsconfig配置

{
  "extends": "@zpcscc/configs/tsconfig/tsconfig.vue.json",
}

commitlint

package.json

"scripts": {
  "commit": "git add . && git-cz",
},

.czrc

{
  "path": "@commitlint/cz-commitlint"
}

commitlint.config.js

module.exports = {
  extends: ['@zpcscc/configs/commitlint-config'],
};

上述文件设置好后,提交代码时使用下列命令

npm run commit

若要默认使用git cz则需全局安装相关依赖

npm i -g commitizen  inquirer@8 @commitlint/cz-commitlint

types

types.d.ts

// 基础配置
/// <reference types="@zpcscc/configs/types" />
// react配置
/// <reference types="@zpcscc/configs/types/react" />
// vue配置
/// <reference types="@zpcscc/configs/types/vue" />

License

MIT © zpcscc