@kcws/lintstaged-config
Version:
kamontat's lintstaged config
77 lines • 3.1 kB
JavaScript
;
/**
* A programming config for lintstaged.
*
* @packageDocumentation
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const micromatch_1 = __importDefault(require("micromatch"));
/**
* This is a function to define a configuration for lintstaged file.
*
* @param builder - a setting for configure lintstaged.
* @returns a lintstaged configuration.
*
* @example
*
* Use lintstaged-config with default configuration
* ```ts
* const { default: defineConfig, Config } = require("@kcws/lintstaged-config");
* module.exports = defineConfig(Config.default());
* ```
*
* @example
*
* Use lintstaged-config with custom configuration
* ```ts
* const { default: defineConfig, Config } = require("@kcws/lintstaged-config");
* module.exports = defineConfig(Config.builder().append("group_name", {}));
* ```
*
* @beta
*/
function defineConfig(builder) {
const options = {
dot: true,
};
const config = builder.build();
return (stagedFiles) => __awaiter(this, void 0, void 0, function* () {
return yield config.getCommands((_key, regexs) => {
return (0, micromatch_1.default)(stagedFiles, regexs, options);
});
});
}
exports.default = defineConfig;
__exportStar(require("./models/IConfig"), exports);
__exportStar(require("./actions/_base"), exports);
__exportStar(require("./actions"), exports);
var Config_1 = require("./models/Config");
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return Config_1.Config; } });
//# sourceMappingURL=index.js.map