bsg
Version:
Lint all in one tool for BSG-FE
88 lines (83 loc) • 2.64 kB
JavaScript
var engine = require("./engine");
var config = {
types: {
"[feature]": {
description: "针对用户的新特性,而不是针对构建脚本的新特性",
title: "[feature]",
},
"[fix]": {
description: "针对用户修复的错误,而不是针对构建脚本的修复",
title: "[fix]",
},
"[update]": {
description: "特性更新,而不是新增特性",
title: "[update]",
},
"[docs]": {
description: "文档修改",
title: "[docs]",
},
"[style]": {
description: "不会影响代码含义的更改(空格,格式,缺少分号等)",
title: "[style]",
},
"[refactor]": {
description: "重构生产代码,例如重命名变量;既不是修复问题也不是新增功能",
title: "[refactor]",
},
"[test]": {
description: "添加缺失的测试用例,重构测试用例;生产代码无变化",
title: "[test]",
},
"[chore]": {
description: "更新构建工具等;生产代码无变化",
title: "[chore]",
},
"[bump]": {
description: "新版本",
title: "[bump]",
},
},
};
var options = {
types: config.types,
defaultType: process.env.CZ_TYPE || config.defaultType,
defaultScope: process.env.CZ_SCOPE || config.defaultScope,
defaultSubject: process.env.CZ_SUBJECT || config.defaultSubject,
defaultBody: process.env.CZ_BODY || config.defaultBody,
defaultIssues: process.env.CZ_ISSUES || config.defaultIssues,
disableScopeLowerCase:
process.env.DISABLE_SCOPE_LOWERCASE || config.disableScopeLowerCase,
disableSubjectLowerCase:
process.env.DISABLE_SUBJECT_LOWERCASE || config.disableSubjectLowerCase,
maxHeaderWidth:
(process.env.CZ_MAX_HEADER_WIDTH &&
parseInt(process.env.CZ_MAX_HEADER_WIDTH)) ||
config.maxHeaderWidth ||
100,
maxLineWidth:
(process.env.CZ_MAX_LINE_WIDTH &&
parseInt(process.env.CZ_MAX_LINE_WIDTH)) ||
config.maxLineWidth ||
100,
};
(function (options) {
try {
var commitlintLoad = require("@commitlint/load");
commitlintLoad().then(function (clConfig) {
if (clConfig.rules) {
var maxHeaderLengthRule = clConfig.rules["header-max-length"];
if (
typeof maxHeaderLengthRule === "object" &&
maxHeaderLengthRule.length >= 3 &&
!process.env.CZ_MAX_HEADER_WIDTH &&
!config.maxHeaderWidth
) {
options.maxHeaderWidth = maxHeaderLengthRule[2];
}
}
});
// eslint-disable-next-line no-empty
} catch (err) {}
})(options);
module.exports = engine(options);