@kcws/lintstaged-config
Version:
kamontat's lintstaged config
47 lines • 2.13 kB
JavaScript
import { prettier, eslint, shellcheck, yamllint, } from "../actions";
/**
* A function to define default configuration for lintstaged,
* So you don't have to configure each action by yourself.
*
* @param builder - Config.Builder
* @returns same builder with default configuration
*
* @remarks
*
* Notes: This function will append default config groups, not replace it.
*
* @internal
*/
export const defineDefaultConfig = (builder, custom) => {
return builder
.set("jsts", {
regexs: ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
actionFn: files => [
(custom === null || custom === void 0 ? void 0 : custom.eslint) === false
? undefined
: eslint(Object.assign({ files, fix: true, maxWarnings: 0 }, custom === null || custom === void 0 ? void 0 : custom.eslint)),
(custom === null || custom === void 0 ? void 0 : custom.jstsPrettier) === false
? undefined
: prettier(Object.assign({ fix: true, files }, custom === null || custom === void 0 ? void 0 : custom.jstsPrettier)),
].filter(v => v !== undefined),
})
.set("json", {
regexs: ["**/*.json"],
actionFn: files => (custom === null || custom === void 0 ? void 0 : custom.jsonPrettier) === false
? []
: prettier(Object.assign({ fix: true, files }, custom === null || custom === void 0 ? void 0 : custom.jsonPrettier)),
})
.set("sh", {
regexs: ["**/*.sh", "**/*.bash", "**/*.zsh"],
actionFn: files => (custom === null || custom === void 0 ? void 0 : custom.shellcheck) === false
? []
: shellcheck(Object.assign({ files }, custom === null || custom === void 0 ? void 0 : custom.shellcheck)),
})
.set("yaml", {
regexs: ["**/*.yaml", "**/*.yml"],
actionFn: files => (custom === null || custom === void 0 ? void 0 : custom.yamllint) === false
? []
: yamllint(Object.assign({ files }, custom === null || custom === void 0 ? void 0 : custom.yamllint)),
});
};
//# sourceMappingURL=default.js.map