Skip to content

Commit 0eecf8a

Browse files
committed
chore: Update prettier config and reformat files
1 parent 73a062c commit 0eecf8a

8 files changed

+33
-20
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
sourceType: "module",
1313
},
1414
rules: {
15-
"prettier/prettier": ["error", { printWidth: 200 }],
15+
"no-var": "error",
1616
"prefer-const": "error",
1717
eqeqeq: "error",
1818
"no-useless-return": "error",

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 140,
3+
"htmlWhitespaceSensitivity": "strict",
4+
"arrowParens": "avoid",
5+
"bracketSameLine": true,
6+
"trailingComma": "es5"
7+
}

src/defaultConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const DEFAULT_CONFIG = {
1818
renderTypeSection: function (label, commits) {
1919
let text = `\n## ${label}\n`;
2020

21-
commits.forEach((commit) => {
21+
commits.forEach(commit => {
2222
const scope = commit.scope ? `**${commit.scope}:** ` : "";
2323
text += `- ${scope}${commit.subject}\n`;
2424
});
@@ -29,7 +29,7 @@ const DEFAULT_CONFIG = {
2929
renderNotes: function (notes) {
3030
let text = `\n## BREAKING CHANGES\n`;
3131

32-
notes.forEach((note) => {
32+
notes.forEach(note => {
3333
text += `- due to [${note.commit.sha.substr(0, 6)}](${note.commit.url}): ${note.commit.subject}\n\n`;
3434
text += `${note.text}\n\n`;
3535
});

src/generateChangelog.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@ function generateChangelog(releaseName, commitObjects, config) {
66
let changes = "";
77

88
commitsByType
9-
.filter((obj) => {
9+
.filter(obj => {
1010
return !config.excludeTypes.includes(obj.type);
1111
})
12-
.forEach((obj) => {
12+
.forEach(obj => {
1313
const niceType = translateType(obj.type, config.types);
1414
changes += config.renderTypeSection(niceType, obj.commits);
1515
});
1616

1717
// Find all the notes of all the commits of all the types
1818
const notes = commitsByType
19-
.flatMap((obj) => {
19+
.flatMap(obj => {
2020
return obj.commits
21-
.map((commit) => {
21+
.map(commit => {
2222
if (commit.notes && commit.notes.length) {
23-
return commit.notes.map((note) => {
23+
return commit.notes.map(note => {
2424
const noteObj = note;
2525
noteObj.commit = commit;
2626
return noteObj;
2727
});
2828
}
2929
})
30-
.filter((o) => o);
30+
.filter(o => o);
3131
})
32-
.flatMap((o) => o);
32+
.flatMap(o => o);
3333

3434
if (notes.length) {
3535
changes += config.renderNotes(notes);

src/groupByType.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function groupByType(commits, typeConfig) {
22
// First, group all the commits by their types.
33
// We end up with a dictionary where the key is the type, and the values is an array of commits.
44
const byType = {};
5-
commits.forEach((commit) => {
5+
commits.forEach(commit => {
66
if (!byType[commit.type]) {
77
byType[commit.type] = [];
88
}
@@ -12,7 +12,7 @@ function groupByType(commits, typeConfig) {
1212
// Turn that dictionary into an array of objects,
1313
// where the key is the type, and the values is an array of commits.
1414
const byTypeArray = [];
15-
Object.keys(byType).forEach((key) => {
15+
Object.keys(byType).forEach(key => {
1616
byTypeArray.push({
1717
type: key,
1818
commits: byType[key],
@@ -21,9 +21,9 @@ function groupByType(commits, typeConfig) {
2121

2222
// And now we sort that array using the TYPES object.
2323
byTypeArray.sort((a, b) => {
24-
let aOrder = typeConfig.findIndex((t) => t.types.includes(a.type));
24+
let aOrder = typeConfig.findIndex(t => t.types.includes(a.type));
2525
if (aOrder === -1) aOrder = 999;
26-
let bOrder = typeConfig.findIndex((t) => t.types.includes(b.type));
26+
let bOrder = typeConfig.findIndex(t => t.types.includes(b.type));
2727
if (bOrder === -1) bOrder = 999;
2828
return aOrder - bOrder;
2929
});

src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async function run() {
4444
const tags = await octokit.paginate("GET /repos/{owner}/{repo}/tags", { owner, repo });
4545

4646
const validSortedTags = tags
47-
.filter((t) => validate(t.name))
47+
.filter(t => validate(t.name))
4848
.sort((a, b) => {
4949
return compareVersions(a.name, b.name);
5050
})
@@ -94,14 +94,14 @@ async function run() {
9494
// Parse every commit, getting the type, turning PR numbers into links, etc
9595
const commitObjects = await Promise.all(
9696
result.data.commits
97-
.map(async (commit) => {
97+
.map(async commit => {
9898
const commitObj = await parseCommitMessage(commit.commit.message, `https://github.com/${owner}/${repo}`, fetchUserFunc);
9999
commitObj.sha = commit.sha;
100100
commitObj.url = commit.html_url;
101101
commitObj.author = commit.author;
102102
return commitObj;
103103
})
104-
.filter((m) => m !== false)
104+
.filter(m => m !== false)
105105
);
106106

107107
// And generate the changelog

src/translateType.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function translateType(type, typeConfig) {
2-
const foundType = typeConfig.find((t) => t.types.includes(type));
2+
const foundType = typeConfig.find(t => t.types.includes(type));
33
if (foundType) {
44
return foundType.label;
55
}

test/parseCommitMessage.spec.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ describe("parseCommitMessage", () => {
2929
it("should parse basic feat with a PR number", async () => {
3030
const result = await parseCommitMessage("feat: This is a feature [#1]", "https://github.com/loopwerk/tag-changelog", fetchUserFunc);
3131

32-
assert.strictEqual(result.subject, "This is a feature [[#1](https://github.com/loopwerk/tag-changelog/pull/1) by [kevinrenskers](https://github.com/kevinrenskers)]");
32+
assert.strictEqual(
33+
result.subject,
34+
"This is a feature [[#1](https://github.com/loopwerk/tag-changelog/pull/1) by [kevinrenskers](https://github.com/kevinrenskers)]"
35+
);
3336
assert.strictEqual(result.type, "feat");
3437
});
3538

@@ -65,7 +68,10 @@ describe("parseCommitMessage", () => {
6568
it("should parse a missing type with a PR number", async () => {
6669
const result = await parseCommitMessage("This is a commit [#1]", "https://github.com/loopwerk/tag-changelog", fetchUserFunc);
6770

68-
assert.strictEqual(result.subject, "This is a commit [[#1](https://github.com/loopwerk/tag-changelog/pull/1) by [kevinrenskers](https://github.com/kevinrenskers)]");
71+
assert.strictEqual(
72+
result.subject,
73+
"This is a commit [[#1](https://github.com/loopwerk/tag-changelog/pull/1) by [kevinrenskers](https://github.com/kevinrenskers)]"
74+
);
6975
assert.strictEqual(result.type, "other");
7076
});
7177

0 commit comments

Comments
 (0)