Skip to content

Commit

Permalink
Update lint.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonMontealegre committed Feb 6, 2024
1 parent 98ad46a commit 5fdec4b
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions scripts/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,21 @@ import yargs from "yargs";
extensions: [".ts", ".tsx"],
});

const files: string[] = [];
if (!all) {
const files = (() => {
if (all)
return ["scripts/", "src/"];
const git = simpleGit();
// Get diff for all files that are staged (or something)
const diff = await git.diff(["--name-only", "origin/master...", "--"]);
diff.split("\n").filter((file) => (file.endsWith(".ts") || file.endsWith(".tsx"))).forEach((file) => {
if (file.endsWith(".ts") || file.endsWith(".tsx"))
files.push(file);
});
// Get status for all unstaged files (or something)
const status = await git.status(["--short"]);
status.files.forEach((summary) => {
const file = summary.path;
if (file.endsWith(".ts") || file.endsWith(".tsx"))
files.push(file);
});
} else {
files.push("scripts/", "src/");
}
return [
...new Set([
...diff.split("\n"),
...status.files
].filter((file) => (file.endsWith(".ts") || file.endsWith(".tsx")))
)];
})();

const results = await eslint.lintFiles(files);
if (fix)
Expand Down

0 comments on commit 5fdec4b

Please sign in to comment.