@kcws/lintstaged-config
Version:
kamontat's lintstaged config
55 lines • 1.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.yamllint = exports.DEFAULT_YAMLLINT_CONFIGS = void 0;
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
const cmd_1 = require("../utils/cmd");
/**
* Default yamllint config path from root repository
*
* @beta
*/
exports.DEFAULT_YAMLLINT_CONFIGS = [
".github/linters/.yamllint.yml",
".github/linters/.yamllint.yaml",
];
/**
* create command with input option
*
* @remarks
*
* Function type: {@link BaseActionFn} and
* Option type: {@link IYamllintOptions}
*
* @param option - customize option
* @returns command
*
* @beta
*/
const yamllint = option => {
var _a, _b;
const args = [(0, cmd_1.getCommand)("yamllint")];
// If config option existed, always use option regardless of file existence
if (option === null || option === void 0 ? void 0 : option.config) {
args.push("--config-file", option === null || option === void 0 ? void 0 : option.config);
// Else check if default config is existed, then use the default config
}
else {
for (const config of exports.DEFAULT_YAMLLINT_CONFIGS) {
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(process.cwd(), config))) {
args.push("--config-file", (0, node_path_1.join)(process.cwd(), config));
break;
}
}
}
if ((_a = option === null || option === void 0 ? void 0 : option.strict) !== null && _a !== void 0 ? _a : true)
args.push("--strict");
const files = (_b = option === null || option === void 0 ? void 0 : option.files) !== null && _b !== void 0 ? _b : [];
if (files.length > 0)
args.push(...files);
else
args.push("."); // Run all files in current directory
return args.join(" ");
};
exports.yamllint = yamllint;
//# sourceMappingURL=yamllint.js.map