Skip to content

Commit 0d19e9c

Browse files
committed
style(prettier): prettify codebase
1 parent c9e591b commit 0d19e9c

File tree

8 files changed

+130
-137
lines changed

8 files changed

+130
-137
lines changed

.vscode/settings.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
"husky": "^0.14.1",
4444
"jest": "^21.2.1",
4545
"lint-staged": "^4.0.0",
46-
"prettier": "^1.7.0",
46+
"prettier": "^1.7.4",
4747
"semantic-release": "^6.3.6",
4848
"ts-jest": "^21.1.3",
4949
"tslint": "^5.4.2",
50-
"tslint-config-prettier": "^1.5.0",
50+
"tslint-config-prettier": "^1.6.0",
5151
"typedoc": "^0.7.1",
5252
"typescript": "^2.5.2",
5353
"validate-commit-msg": "^2.12.1"
@@ -68,6 +68,7 @@
6868
}
6969
},
7070
"lint-staged": {
71-
"*.ts": ["tslint --fix", "git add"]
71+
"*.ts": ["prettier --write", "tslint --fix", "git add"],
72+
"*.json": ["prettier --write", "git add"]
7273
}
7374
}

scripts/deploy-docs.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
'use strict'
1+
"use strict";
22

3-
const ghpages = require('gh-pages')
3+
const ghpages = require("gh-pages");
44

5-
const docsDir = 'docs'
5+
const docsDir = "docs";
66
const options = {
77
user: {
8-
name: 'Macklin Underdown',
9-
email: 'macklinu@users.noreply.github.com'
10-
},
11-
}
12-
const callback = (err) => {
8+
name: "Macklin Underdown",
9+
email: "macklinu@users.noreply.github.com"
10+
}
11+
};
12+
const callback = err => {
1313
if (err) {
14-
console.error(err)
14+
console.error(err);
1515
} else {
16-
console.log('🚀 Docs deployed to GitHub Pages')
16+
console.log("🚀 Docs deployed to GitHub Pages");
1717
}
18-
}
18+
};
1919

20-
ghpages.publish(docsDir, options, callback)
20+
ghpages.publish(docsDir, options, callback);

src/ambient.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
declare var danger: any
2-
declare function message(message: string): void
3-
declare function warn(message: string): void
1+
declare var danger: any;
2+
declare function message(message: string): void;
3+
declare function warn(message: string): void;

src/index.test.ts

Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,113 @@
1-
import jiraIssue from './'
1+
import jiraIssue from "./";
22

3-
declare const global: any
3+
declare const global: any;
44

5-
describe('jiraIssue()', () => {
5+
describe("jiraIssue()", () => {
66
beforeEach(() => {
7-
global.warn = jest.fn()
8-
global.message = jest.fn()
9-
})
7+
global.warn = jest.fn();
8+
global.message = jest.fn();
9+
});
1010
afterEach(() => {
11-
global.danger = undefined
12-
global.warn = undefined
13-
global.message = undefined
14-
})
15-
it('throws when supplied invalid configuration', () => {
16-
const anyJira = jiraIssue as any
17-
expect(() => anyJira()).toThrow()
18-
expect(() => jiraIssue({} as any)).toThrow()
19-
expect(() => jiraIssue({ key: 'ABC' } as any)).toThrow()
20-
expect(() => jiraIssue({ url: 'https://jira.net/browse' } as any)).toThrow()
21-
})
22-
it('warns when PR title is missing JIRA issue key', () => {
23-
global.danger = { github: { pr: { title: 'Change some things' } } }
11+
global.danger = undefined;
12+
global.warn = undefined;
13+
global.message = undefined;
14+
});
15+
it("throws when supplied invalid configuration", () => {
16+
const anyJira = jiraIssue as any;
17+
expect(() => anyJira()).toThrow();
18+
expect(() => jiraIssue({} as any)).toThrow();
19+
expect(() => jiraIssue({ key: "ABC" } as any)).toThrow();
20+
expect(() =>
21+
jiraIssue({ url: "https://jira.net/browse" } as any)
22+
).toThrow();
23+
});
24+
it("warns when PR title is missing JIRA issue key", () => {
25+
global.danger = { github: { pr: { title: "Change some things" } } };
2426
jiraIssue({
25-
key: 'ABC',
26-
url: 'https://jira.net/browse',
27-
})
27+
key: "ABC",
28+
url: "https://jira.net/browse"
29+
});
2830
expect(global.warn).toHaveBeenCalledWith(
29-
'Please add the JIRA issue key to the PR title (e.g. ABC-123)'
30-
)
31-
})
32-
it('adds the JIRA issue link to the messages table', () => {
31+
"Please add the JIRA issue key to the PR title (e.g. ABC-123)"
32+
);
33+
});
34+
it("adds the JIRA issue link to the messages table", () => {
3335
global.danger = {
34-
github: { pr: { title: '[ABC-808] Change some things' } },
35-
}
36+
github: { pr: { title: "[ABC-808] Change some things" } }
37+
};
3638
jiraIssue({
37-
key: 'ABC',
38-
url: 'https://jira.net/browse',
39-
})
39+
key: "ABC",
40+
url: "https://jira.net/browse"
41+
});
4042
expect(global.message).toHaveBeenCalledWith(
4143
':link: <a href="https://jira.net/browse/ABC-808">ABC-808</a>'
42-
)
43-
})
44-
it('properly concatenates URL parts (trailing slash in url)', () => {
44+
);
45+
});
46+
it("properly concatenates URL parts (trailing slash in url)", () => {
4547
global.danger = {
46-
github: { pr: { title: '[ABC-808] Change some things' } },
47-
}
48+
github: { pr: { title: "[ABC-808] Change some things" } }
49+
};
4850
jiraIssue({
49-
key: 'ABC',
50-
url: 'https://jira.net/browse/',
51-
})
51+
key: "ABC",
52+
url: "https://jira.net/browse/"
53+
});
5254
expect(global.message).toHaveBeenCalledWith(
5355
':link: <a href="https://jira.net/browse/ABC-808">ABC-808</a>'
54-
)
55-
})
56-
it('matches JIRA issue anywhere in title', () => {
57-
global.danger = { github: { pr: { title: 'My changes - ABC-123' } } }
56+
);
57+
});
58+
it("matches JIRA issue anywhere in title", () => {
59+
global.danger = { github: { pr: { title: "My changes - ABC-123" } } };
5860
jiraIssue({
59-
key: 'ABC',
60-
url: 'https://jira.net/browse',
61-
})
61+
key: "ABC",
62+
url: "https://jira.net/browse"
63+
});
6264
expect(global.message).toHaveBeenCalledWith(
6365
':link: <a href="https://jira.net/browse/ABC-123">ABC-123</a>'
64-
)
65-
})
66-
it('does not match lowercase JIRA key in PR title', () => {
66+
);
67+
});
68+
it("does not match lowercase JIRA key in PR title", () => {
6769
global.danger = {
68-
github: { pr: { title: '[abc-808] Change some things' } },
69-
}
70+
github: { pr: { title: "[abc-808] Change some things" } }
71+
};
7072
jiraIssue({
71-
key: 'ABC',
72-
url: 'https://jira.net/browse',
73-
})
74-
expect(global.warn).toHaveBeenCalled()
75-
})
76-
it('honors custom emoji configuration', () => {
77-
global.danger = { github: { pr: { title: '(ABC-123) Change stuff' } } }
73+
key: "ABC",
74+
url: "https://jira.net/browse"
75+
});
76+
expect(global.warn).toHaveBeenCalled();
77+
});
78+
it("honors custom emoji configuration", () => {
79+
global.danger = { github: { pr: { title: "(ABC-123) Change stuff" } } };
7880
jiraIssue({
79-
emoji: ':paperclip:',
80-
key: 'ABC',
81-
url: 'https://jira.net/browse',
82-
})
81+
emoji: ":paperclip:",
82+
key: "ABC",
83+
url: "https://jira.net/browse"
84+
});
8385
expect(global.message).toHaveBeenCalledWith(
8486
':paperclip: <a href="https://jira.net/browse/ABC-123">ABC-123</a>'
85-
)
86-
})
87-
it('supports multiple JIRA keys in PR title', () => {
87+
);
88+
});
89+
it("supports multiple JIRA keys in PR title", () => {
8890
global.danger = {
89-
github: { pr: { title: '[ABC-123][ABC-456] Change some things' } },
90-
}
91+
github: { pr: { title: "[ABC-123][ABC-456] Change some things" } }
92+
};
9193
jiraIssue({
92-
key: 'ABC',
93-
url: 'https://jira.net/browse',
94-
})
94+
key: "ABC",
95+
url: "https://jira.net/browse"
96+
});
9597
expect(global.message).toHaveBeenCalledWith(
9698
':link: <a href="https://jira.net/browse/ABC-123">ABC-123</a>, <a href="https://jira.net/browse/ABC-456">ABC-456</a>'
97-
)
98-
})
99-
it('supports multiple JIRA boards in PR title', () => {
99+
);
100+
});
101+
it("supports multiple JIRA boards in PR title", () => {
100102
global.danger = {
101-
github: { pr: { title: '[ABC-123][DEF-456] Change some things' } },
102-
}
103+
github: { pr: { title: "[ABC-123][DEF-456] Change some things" } }
104+
};
103105
jiraIssue({
104-
key: ['ABC', 'DEF'],
105-
url: 'https://jira.net/browse',
106-
})
106+
key: ["ABC", "DEF"],
107+
url: "https://jira.net/browse"
108+
});
107109
expect(global.message).toHaveBeenCalledWith(
108110
':link: <a href="https://jira.net/browse/ABC-123">ABC-123</a>, <a href="https://jira.net/browse/DEF-456">DEF-456</a>'
109-
)
110-
})
111-
})
111+
);
112+
});
113+
});

src/index.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
import { resolve } from 'url'
1+
import { resolve } from "url";
22

33
export interface Options {
44
/**
55
* The JIRA issue key(s) (e.g. the ABC in ABC-123).
66
* Supports multiple JIRA projects (e.g. `['ABC', 'DEF']`).
77
*/
8-
key: string | string[]
8+
key: string | string[];
99
/** The JIRA instance issue base URL (e.g. https://jira.atlassian.com/browse/). */
10-
url: string
10+
url: string;
1111
/**
1212
* The emoji to display with the JIRA issue link.
1313
* See the possible emoji values, listed as keys in the
1414
* [GitHub API `/emojis` response](https://api.github.com/emojis).
1515
* Defaults to `':link:'`.
1616
*/
17-
emoji?: string
17+
emoji?: string;
1818
}
1919

2020
const link = (href: string, text: string): string =>
21-
`<a href="${href}">${text}</a>`
21+
`<a href="${href}">${text}</a>`;
2222

2323
const ensureUrlEndsWithSlash = (url: string) => {
24-
if (!url.endsWith('/')) {
25-
return url.concat('/')
24+
if (!url.endsWith("/")) {
25+
return url.concat("/");
2626
}
27-
return url
28-
}
27+
return url;
28+
};
2929

3030
/**
3131
* A Danger plugin to add a JIRA issue link to the Danger pull request comment.
@@ -34,30 +34,30 @@ const ensureUrlEndsWithSlash = (url: string) => {
3434
* to include the JIRA issue identifier in the pull request title.
3535
*/
3636
export default function jiraIssue(options: Options) {
37-
const { key = '', url = '', emoji = ':link:' } = options || {}
37+
const { key = "", url = "", emoji = ":link:" } = options || {};
3838
if (!url) {
39-
throw Error(`'url' missing - must supply JIRA installation URL`)
39+
throw Error(`'url' missing - must supply JIRA installation URL`);
4040
}
4141
if (!key) {
42-
throw Error(`'key' missing - must supply JIRA issue key`)
42+
throw Error(`'key' missing - must supply JIRA issue key`);
4343
}
4444

4545
// Support multiple JIRA projects.
46-
const keys = Array.isArray(key) ? `(${key.join('|')})` : key
46+
const keys = Array.isArray(key) ? `(${key.join("|")})` : key;
4747

48-
const jiraKeyRegex = new RegExp(`(${keys}-[0-9]+)`, 'g')
49-
let match
50-
const jiraIssues = []
48+
const jiraKeyRegex = new RegExp(`(${keys}-[0-9]+)`, "g");
49+
let match;
50+
const jiraIssues = [];
5151
// tslint:disable-next-line:no-conditional-assignment
5252
while ((match = jiraKeyRegex.exec(danger.github.pr.title)) != null) {
53-
jiraIssues.push(match[0])
53+
jiraIssues.push(match[0]);
5454
}
5555
if (jiraIssues.length > 0) {
5656
const jiraUrls = jiraIssues
5757
.map(issue => link(resolve(ensureUrlEndsWithSlash(url), issue), issue))
58-
.join(', ')
59-
message(`${emoji} ${jiraUrls}`)
58+
.join(", ");
59+
message(`${emoji} ${jiraUrls}`);
6060
} else {
61-
warn(`Please add the JIRA issue key to the PR title (e.g. ${key}-123)`)
61+
warn(`Please add the JIRA issue key to the PR title (e.g. ${key}-123)`);
6262
}
6363
}

tsconfig.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
"target": "es5",
1919
"types": ["node"]
2020
},
21-
"include": [
22-
"src/**/*.ts"
23-
],
24-
"exclude": [
25-
"node_modules",
26-
"src/**/*.test.ts"
27-
]
21+
"include": ["src/**/*.ts"],
22+
"exclude": ["node_modules", "src/**/*.test.ts"]
2823
}

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,9 +3313,9 @@ preserve@^0.2.0:
33133313
version "0.2.0"
33143314
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
33153315

3316-
prettier@^1.7.0:
3317-
version "1.7.0"
3318-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.0.tgz#47481588f41f7c90f63938feb202ac82554e7150"
3316+
prettier@^1.7.4:
3317+
version "1.7.4"
3318+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.4.tgz#5e8624ae9363c80f95ec644584ecdf55d74f93fa"
33193319

33203320
pretty-format@^20.0.3:
33213321
version "20.0.3"
@@ -4193,9 +4193,9 @@ tslib@^1.7.1:
41934193
version "1.7.1"
41944194
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec"
41954195

4196-
tslint-config-prettier@^1.5.0:
4197-
version "1.5.0"
4198-
resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.5.0.tgz#76645425edcc34d9b6835ba58266eaf90fdbfeda"
4196+
tslint-config-prettier@^1.6.0:
4197+
version "1.6.0"
4198+
resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.6.0.tgz#fec1ee8fb07e8f033c63fed6b135af997f31962a"
41994199

42004200
tslint@^5.4.2:
42014201
version "5.4.2"

0 commit comments

Comments
 (0)