UNPKG

@kcws/lintstaged-config

Version:
56 lines 1.98 kB
/** * A programming config for lintstaged. * * @packageDocumentation */ 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()); }); }; import micromatch from "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 micromatch(stagedFiles, regexs, options); }); }); } export default defineConfig; export * from "./models/IConfig"; export * from "./actions/_base"; export * from "./actions"; export { Config } from "./models/Config"; //# sourceMappingURL=index.js.map