Skip to content

Commit 53af44d

Browse files
committed
Debug filepaths
1 parent 42708f7 commit 53af44d

File tree

2 files changed

+53
-26
lines changed

2 files changed

+53
-26
lines changed

src/git.ts

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const getCachedDiff = (filePath: string, staged: boolean) =>
1616

1717
const diffCache = new Map<string, string>();
1818
const getDiffForFile = (filePath: string, staged = false): string => {
19+
// console.log("getDiffForFile")
1920
let diff = getCachedDiff(filePath, staged);
2021
if (diff === undefined) {
2122
const command = [
@@ -41,6 +42,7 @@ const getDiffForFile = (filePath: string, staged = false): string => {
4142

4243
let diffFileListCache: string[];
4344
const getDiffFileList = (staged = false): string[] => {
45+
// console.log("getDiffFileList")
4446
if (diffFileListCache === undefined) {
4547
const command = [
4648
"git",
@@ -65,16 +67,18 @@ const getDiffFileList = (staged = false): string[] => {
6567

6668
let gitFileListCache: string[];
6769
const getGitFileList = (): string[] => {
70+
// console.log("getGitFileList")
6871
if (gitFileListCache === undefined) {
6972
const command = ["git", "ls-files"].filter(Boolean).join(" ");
7073

7174
gitFileListCache = child_process
72-
.execSync(command)
73-
.toString()
74-
.trim()
75-
.split("\n")
76-
.map((filePath) => path.resolve(filePath));
75+
.execSync(command)
76+
.toString()
77+
.trim()
78+
.split("\n")
79+
.map((filePath) => path.resolve(filePath));
7780
}
81+
// console.log({gitFileListCache},gitFileListCache.join("\n"))
7882
return gitFileListCache;
7983
};
8084

@@ -91,7 +95,35 @@ const getIgnorePatterns = (staged = false): string[] => {
9195
path.join("/", path.relative(process.cwd(), x))
9296
);
9397

94-
console.log({ willBeChecked });
98+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
99+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
100+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
101+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
102+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
103+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
104+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
105+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
106+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
107+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
108+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
109+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
110+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
111+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
112+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
113+
console.log("😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀");
114+
console.log("will be checked" + willBeChecked.join("\n"));
115+
console.log("------------------");
116+
console.log("------------------");
117+
console.log("------------------");
118+
console.log("------------------");
119+
console.log("------------------");
120+
console.log("------------------");
121+
console.log("------------------");
122+
console.log("------------------");
123+
console.log("------------------");
124+
console.log("------------------");
125+
console.log("------------------");
126+
console.log("will be ignored" + newList.join("\n"));
95127
return result;
96128
};
97129

@@ -140,7 +172,6 @@ const getRangesForDiff = (diff: string): Range[] => {
140172

141173
export {
142174
getDiffForFile,
143-
getGitFileList,
144175
getIgnorePatterns,
145176
getRangesForDiff,
146177
getDiffFileList,

src/processors.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
import type { Linter } from "eslint";
2-
import { getDiffFileList, getDiffForFile, getIgnorePatterns, getRangesForDiff, Range } from "./git";
3-
2+
import {
3+
getDiffFileList,
4+
getDiffForFile,
5+
getIgnorePatterns,
6+
getRangesForDiff,
7+
Range,
8+
} from "./git";
49

510
const STAGED = true;
611

712
const isLineWithinRange = (line: number) => (range: Range) =>
813
range.isWithinRange(line);
914

10-
11-
1215
const diff = {
1316
postprocess: (
1417
messages: Linter.LintMessage[][],
1518
filename: string
1619
): Linter.LintMessage[] => {
1720
if (!getDiffFileList().includes(filename)) {
18-
console.log(
19-
"🧠 skipping " +
20-
JSON.stringify(filename) +
21-
" because it's not in the diff list"
22-
);
21+
// console.log( "🧠 skipping " + JSON.stringify(filename) + " because it's not in the diff list" );
2322
return [];
2423
}
2524
const result = messages
2625
.map((message) => {
27-
console.log("diff/diff", message, JSON.stringify(filename));
26+
// console.log("diff/diff", message, JSON.stringify(filename));
2827
return message.filter(({ fatal, line }) => {
2928
if (fatal) {
30-
console.log("❌ fatal error in " + JSON.stringify(filename));
29+
// console.log("❌ fatal error in " + JSON.stringify(filename));
3130
return fatal;
3231
}
3332

@@ -36,11 +35,7 @@ const diff = {
3635
isLineWithinRange(line)
3736
)
3837
) {
39-
console.log(
40-
"🔵 skipping " +
41-
JSON.stringify(filename) +
42-
" because it's not in the diff list"
43-
);
38+
// console.log( "🔵 skipping " + JSON.stringify(filename) + " because it's not in the diff list" );
4439
}
4540

4641
return (
@@ -52,7 +47,7 @@ const diff = {
5247
});
5348
})
5449
.reduce((a, b) => a.concat(b), []);
55-
console.log("diff kjrngkjsngksnj", { result, filename, messages });
50+
// console.log("diff kjrngkjsngksnj", { result, filename, messages });
5651
return result;
5752
},
5853

@@ -67,15 +62,15 @@ const diffConfig = {
6762
processor: "diff/diff",
6863
},
6964
],
70-
ignorePatterns: getIgnorePatterns()
65+
ignorePatterns: getIgnorePatterns(),
7166
};
7267

7368
const staged = {
7469
preprocess: (
7570
text: string,
7671
filename: string
7772
): ({ text: string; filename: string } & Record<any, any>)[] => {
78-
console.log({ text: text, filename: filename, lol: "zooooooooooomg" });
73+
// console.log({ text: text, filename: filename, lol: "zooooooooooomg" });
7974
return getDiffFileList(STAGED).includes(filename)
8075
? [{ text, filename }]
8176
: [];
@@ -106,6 +101,7 @@ const stagedConfig = {
106101
processor: "diff/staged",
107102
},
108103
],
104+
ignorePatterns: getIgnorePatterns(STAGED),
109105
};
110106

111107
export { diff, diffConfig, staged, stagedConfig };

0 commit comments

Comments
 (0)