Skip to content

Commit ecc9e76

Browse files
committed
Lint
1 parent 4f1ac5a commit ecc9e76

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/processors.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ describe("fatal error-message", () => {
8484
it("getUnstagedChangesError", async () => {
8585
const { getUnstagedChangesError } = await import("./processors");
8686

87-
const result = getUnstagedChangesError("mock filename.ts")[0];
88-
expect(result?.fatal).toBe(true);
89-
expect(result?.message).toMatchInlineSnapshot(
90-
`"mock filename.ts has unstaged changes. Please stage or remove the changes."`
87+
const [result] = getUnstagedChangesError("mock filename.ts");
88+
expect(result.fatal).toBe(true);
89+
expect(result.message).toMatchInlineSnapshot(
90+
'"mock filename.ts has unstaged changes. Please stage or remove the changes."'
9191
);
9292
});
9393
});

src/processors.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,24 @@ const STAGED = true;
1717
* them from being processed in the first place, as a performance optimization.
1818
* This is increasingly useful the more files there are in the repository.
1919
*/
20-
const getPreProcessor = (
21-
untrackedFileList: string[],
22-
diffFileList: string[]
23-
) => {
24-
return (text: string, filename: string) => {
20+
const getPreProcessor =
21+
(untrackedFileList: string[], diffFileList: string[]) =>
22+
(text: string, filename: string) => {
2523
const shouldBeProcessed =
2624
process.env.VSCODE_CLI !== undefined ||
2725
diffFileList.includes(filename) ||
2826
untrackedFileList.includes(filename);
29-
// console.error({
30-
// untrackedFileList,
31-
// diffFileList,
32-
// text,
33-
// filename,
34-
// shouldBeProcessed,
35-
// });
3627

3728
return shouldBeProcessed ? [text] : [];
3829
};
39-
};
4030

4131
const isLineWithinRange = (line: number) => (range: Range) =>
4232
range.isWithinRange(line);
4333

4434
/**
4535
* @internal
4636
*/
47-
function getUnstagedChangesError(filename: string) {
37+
function getUnstagedChangesError(filename: string): [Linter.LintMessage] {
4838
// When we only want to diff staged files, but the file is partially
4939
// staged, the ranges of the staged diff might not match the ranges of the
5040
// unstaged diff and could cause a conflict, so we return a fatal
@@ -65,8 +55,9 @@ function getUnstagedChangesError(filename: string) {
6555
return [fatalError];
6656
}
6757

68-
const getPostProcessor = (untrackedFileList: string[], staged = false) => {
69-
return (
58+
const getPostProcessor =
59+
(untrackedFileList: string[], staged = false) =>
60+
(
7061
messages: Linter.LintMessage[][],
7162
filename: string
7263
): Linter.LintMessage[] => {
@@ -103,7 +94,6 @@ const getPostProcessor = (untrackedFileList: string[], staged = false) => {
10394
return filteredMessage;
10495
});
10596
};
106-
};
10797

10898
const getProcessors = (staged = false): Required<Linter.Processor> => {
10999
const untrackedFileList = getUntrackedFileList(staged);

0 commit comments

Comments
 (0)