UNPKG

830 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const utils_1 = require("./utils");
4/**
5 * Get forced leading for rule
6 * @param rule to parse
7 * @return transform function applying the leading
8 */
9function getForcedLeadingFn(rule) {
10 if (!rule || !(0, utils_1.ruleIsActive)(rule)) {
11 return (input) => input;
12 }
13 const remove = (input) => {
14 const fragments = input.split('\n');
15 return fragments[0] === '' ? fragments.slice(1).join('\n') : input;
16 };
17 const lead = (input) => {
18 const fragments = input.split('\n');
19 return fragments[0] === '' ? input : ['', ...fragments].join('\n');
20 };
21 return !(0, utils_1.ruleIsNotApplicable)(rule) ? lead : remove;
22}
23exports.default = getForcedLeadingFn;
24//# sourceMappingURL=get-forced-leading-fn.js.map
\No newline at end of file