Skip to content

Commit d271a75

Browse files
committed
Format
1 parent f439f71 commit d271a75

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

src/processors.ts

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,55 +16,56 @@ const STAGED = true;
1616
* them from being processed in the first place, as a performance optimization.
1717
* This is increasingly useful the more files there are in the repository.
1818
*/
19-
const getPreProcessor = (staged = false) => (
20-
text: string,
21-
filename: string
22-
) => {
23-
const shouldBeProcessed = getDiffFileList(staged).includes(filename);
19+
const getPreProcessor =
20+
(staged = false) =>
21+
(text: string, filename: string) => {
22+
const shouldBeProcessed = getDiffFileList(staged).includes(filename);
2423

25-
return shouldBeProcessed ? [text] : [];
26-
};
24+
return shouldBeProcessed ? [text] : [];
25+
};
2726

2827
const isLineWithinRange = (line: number) => (range: Range) =>
2928
range.isWithinRange(line);
3029

31-
const getPostProcessor = (staged = false) => (
32-
messages: Linter.LintMessage[][],
33-
filename: string
34-
): Linter.LintMessage[] => {
35-
if (staged && !hasCleanIndex(filename)) {
36-
const fatal = true;
37-
const message = `${filename} has unstaged changes. Please stage or remove the changes.`;
38-
const severity: Linter.Severity = 2;
39-
const fatalError: Linter.LintMessage = {
40-
fatal,
41-
message,
42-
severity,
43-
column: 0,
44-
line: 0,
45-
ruleId: null,
46-
};
47-
return [fatalError];
48-
}
30+
const getPostProcessor =
31+
(staged = false) =>
32+
(
33+
messages: Linter.LintMessage[][],
34+
filename: string
35+
): Linter.LintMessage[] => {
36+
if (staged && !hasCleanIndex(filename)) {
37+
const fatal = true;
38+
const message = `${filename} has unstaged changes. Please stage or remove the changes.`;
39+
const severity: Linter.Severity = 2;
40+
const fatalError: Linter.LintMessage = {
41+
fatal,
42+
message,
43+
severity,
44+
column: 0,
45+
line: 0,
46+
ruleId: null,
47+
};
48+
return [fatalError];
49+
}
4950

50-
return messages
51-
.map((message) => {
52-
const filteredMessage = message.filter(({ fatal, line }) => {
53-
if (fatal === true) {
54-
return true;
55-
}
51+
return messages
52+
.map((message) => {
53+
const filteredMessage = message.filter(({ fatal, line }) => {
54+
if (fatal === true) {
55+
return true;
56+
}
5657

57-
const isLineWithinSomeRange = getRangesForDiff(
58-
getDiffForFile(filename, staged)
59-
).some(isLineWithinRange(line));
58+
const isLineWithinSomeRange = getRangesForDiff(
59+
getDiffForFile(filename, staged)
60+
).some(isLineWithinRange(line));
6061

61-
return isLineWithinSomeRange;
62-
});
62+
return isLineWithinSomeRange;
63+
});
6364

64-
return filteredMessage;
65-
})
66-
.reduce((a, b) => a.concat(b), []);
67-
};
65+
return filteredMessage;
66+
})
67+
.reduce((a, b) => a.concat(b), []);
68+
};
6869

6970
const getProcessors = (staged = false) => ({
7071
preprocess: getPreProcessor(staged),

0 commit comments

Comments
 (0)