Skip to content

Commit 38d1e72

Browse files
committed
refactor(eslint): enable more neostandard configs
1 parent e28b0d7 commit 38d1e72

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

eslint.config.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import { defineConfig, globalIgnores } from "eslint/config";
1+
import { defineConfig } from "eslint/config";
22
import neostandard from "neostandard";
33

44
export default defineConfig([
5-
globalIgnores(["dist"]),
6-
...neostandard(),
5+
...neostandard({
6+
ts: true,
7+
noJsx: true,
8+
semi: true,
9+
ignores: ["dist/**/*"]
10+
}),
711
{
812
rules: {
13+
"@stylistic/brace-style": "off",
914
"@stylistic/comma-dangle": ["error", "never"],
1015
"@stylistic/quotes": ["error", "double"],
11-
"@stylistic/semi": ["error", "always"],
1216
"@stylistic/space-before-function-paren": ["error", "never"]
1317
}
1418
}

src/output.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ function formatSingleBranch(
1010
for (const prefix of issueUrlPrefix) {
1111
const prefixRegex = new RegExp(`\\b${prefix}(\\d+)`, "i");
1212
const match = branch.match(prefixRegex);
13-
1413
if (!match) { continue; }
1514

16-
const [_fullToken, id] = match;
17-
const url = issueUrlFormat.replace("{{prefix}}", prefix).replace("{{id}}", id);
15+
const url = issueUrlFormat.replace("{{prefix}}", prefix).replace("{{id}}", match[1]);
1816
return `${branch} <${url}>`;
1917
}
2018
return branch;
@@ -40,7 +38,7 @@ export function outputMergedBranches(branches: string[], targetBranch: string, c
4038
return console.info(`No branches merged into '${targetBranch}'.`);
4139
}
4240

43-
console.info(`${pluralize(branches.length, ["branch", "branches"])} merged into '${targetBranch}':`)
41+
console.info(`${pluralize(branches.length, ["branch", "branches"])} merged into '${targetBranch}':`);
4442
console.info(formatTaskBranches(branches, config).join("\n"));
4543

4644
const remoteBranches = fetchRemoteBranches("origin");

src/repo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function getMergedBranches(targetBranch: string): string[] {
4141
const output = execSync(`git branch --merged ${targetBranch}`, { encoding: "utf-8" });
4242
return output.split("\n").reduce((acc: string[], line) => {
4343
// Ignore empty lines
44-
const branch = line.replace('*', '').trim();
44+
const branch = line.replace("*", "").trim();
4545
if (!branch) { return acc; }
4646
// Ignore branches on the base commit
4747
const branchCommit = execSync(`git rev-parse ${branch}`, { encoding: "utf-8" }).trim();
@@ -67,7 +67,7 @@ export function fetchRemoteBranches(remote = "origin"): string[] {
6767
export interface GitMergedConfig {
6868
issueUrlFormat?: string;
6969
issueUrlPrefix?: string[];
70-
};
70+
}
7171

7272
export function getConfig(): GitMergedConfig {
7373
try {

src/tests/output.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ describe("formatTaskBranches", () => {
1313
const branches = ["feat/TOKEN-800_new-feature", "fix/TOKEN-123_some-fix"];
1414
const result = formatTaskBranches(branches, DEFAULT_CONFIG);
1515
expect(result).toEqual([
16-
'feat/TOKEN-800_new-feature <https://test-instance.org/browse/TOKEN-800>',
17-
'fix/TOKEN-123_some-fix <https://test-instance.org/browse/TOKEN-123>'
16+
"feat/TOKEN-800_new-feature <https://test-instance.org/browse/TOKEN-800>",
17+
"fix/TOKEN-123_some-fix <https://test-instance.org/browse/TOKEN-123>"
1818
]);
1919
});
2020

@@ -81,7 +81,7 @@ describe("outputMergedBranches", () => {
8181
const branchOutput = [
8282
"feat/TOKEN-800_new-feature <https://test-instance.org/browse/TOKEN-800>",
8383
"fix/TOKEN-123_some-fix <https://test-instance.org/browse/TOKEN-123>"
84-
]
84+
];
8585
expect(infoSpy).toHaveBeenNthCalledWith(2, branchOutput.join("\n"));
8686

8787
const localDelete = `git branch --delete ${branches.join(" ")}`;
@@ -100,7 +100,7 @@ describe("outputMergedBranches", () => {
100100
const branchOutput = [
101101
"feat/TOKEN-800_new-feature <https://test-instance.org/browse/TOKEN-800>",
102102
"fix/TOKEN-123_some-fix <https://test-instance.org/browse/TOKEN-123>"
103-
]
103+
];
104104
expect(infoSpy).toHaveBeenNthCalledWith(2, branchOutput.join("\n"));
105105

106106
const localDelete = `git branch --delete ${branches.join(" ")}`;
@@ -126,7 +126,7 @@ describe("outputMergedBranches", () => {
126126
expect(infoSpy).toHaveBeenNthCalledWith(4, `locally:\n ${localDelete}`);
127127
expect(infoSpy).toHaveBeenCalledTimes(4);
128128
expect(warnSpy).not.toHaveBeenCalled();
129-
})
129+
});
130130

131131
it("should log a message when no branches are merged", () => {
132132
outputMergedBranches([], "master", DEFAULT_CONFIG);

src/validate.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export function isValidURL(url?: string): boolean {
2-
if (!url) return false;
1+
export function isValidURL(payload?: string): boolean {
2+
if (!payload) return false;
33
try {
4-
new URL(url);
5-
return true;
4+
const url = new URL(payload);
5+
return url.protocol === "http:" || url.protocol === "https:";
66
} catch {
77
return false;
88
}

0 commit comments

Comments
 (0)