Skip to content

Commit 5fd2546

Browse files
authored
Run format check in CI (#355)
1 parent 77c3599 commit 5fd2546

File tree

24 files changed

+168
-107
lines changed

24 files changed

+168
-107
lines changed

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,29 @@ jobs:
7171

7272
- name: Run Lint
7373
run: pnpm lint
74+
id: lint
75+
continue-on-error: true
76+
77+
- name: Run Format
78+
run: pnpm format:check
79+
id: format
80+
continue-on-error: true
81+
82+
- name: Check Results
83+
run: |
84+
declare -A OUTCOMES=(
85+
[lint]="${{ steps.lint.outcome }}"
86+
[format]="${{ steps.format.outcome }}"
87+
)
88+
STATUS=0
89+
for STEP in "${!OUTCOMES[@]}"; do
90+
OUTCOME="${OUTCOMES[$STEP]}"
91+
echo "$STEP: $OUTCOME"
92+
if [ "$OUTCOME" != "success" ]; then
93+
STATUS=1
94+
fi
95+
done
96+
exit $STATUS
7497
7598
e2e:
7699
name: E2E

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
packages/*/dist
22
packages/degenerator/test/*.js
3+
*.md
4+
*.pac
5+
pnpm-lock.yaml

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"singleQuote": true
2+
"singleQuote": true
33
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"lint": "turbo run lint",
88
"test": "turbo run test",
99
"test-e2e": "turbo run test-e2e",
10-
"format": "prettier --write \"**/*.{ts,js,mjs}\"",
10+
"format": "prettier --write .",
11+
"format:check": "prettier --check .",
1112
"ci:version": "changeset version && pnpm install --no-frozen-lockfile",
1213
"ci:publish": "pnpm publish -r && changeset tag"
1314
},

packages/agent-base/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "tsconfig/base.json",
33
"compilerOptions": {
4-
"outDir": "dist",
4+
"outDir": "dist"
55
},
66
"include": ["src"],
77
"exclude": ["node_modules"]

packages/data-uri-to-buffer/src/common.ts

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,55 +15,59 @@ export interface IBufferConversions {
1515
*
1616
* @param {String} uri Data URI to turn into a Buffer instance
1717
*/
18-
export const makeDataUriToBuffer = (convert: IBufferConversions) => (uri: string | URL): ParsedDataURI => {
19-
uri = String(uri);
18+
export const makeDataUriToBuffer =
19+
(convert: IBufferConversions) =>
20+
(uri: string | URL): ParsedDataURI => {
21+
uri = String(uri);
2022

21-
if (!/^data:/i.test(uri)) {
22-
throw new TypeError(
23-
'`uri` does not appear to be a Data URI (must begin with "data:")'
24-
);
25-
}
23+
if (!/^data:/i.test(uri)) {
24+
throw new TypeError(
25+
'`uri` does not appear to be a Data URI (must begin with "data:")'
26+
);
27+
}
2628

27-
// strip newlines
28-
uri = uri.replace(/\r?\n/g, '');
29+
// strip newlines
30+
uri = uri.replace(/\r?\n/g, '');
2931

30-
// split the URI up into the "metadata" and the "data" portions
31-
const firstComma = uri.indexOf(',');
32-
if (firstComma === -1 || firstComma <= 4) {
33-
throw new TypeError('malformed data: URI');
34-
}
32+
// split the URI up into the "metadata" and the "data" portions
33+
const firstComma = uri.indexOf(',');
34+
if (firstComma === -1 || firstComma <= 4) {
35+
throw new TypeError('malformed data: URI');
36+
}
3537

36-
// remove the "data:" scheme and parse the metadata
37-
const meta = uri.substring(5, firstComma).split(';');
38+
// remove the "data:" scheme and parse the metadata
39+
const meta = uri.substring(5, firstComma).split(';');
3840

39-
let charset = '';
40-
let base64 = false;
41-
const type = meta[0] || 'text/plain';
42-
let typeFull = type;
43-
for (let i = 1; i < meta.length; i++) {
44-
if (meta[i] === 'base64') {
45-
base64 = true;
46-
} else if (meta[i]) {
47-
typeFull += `;${meta[i]}`;
48-
if (meta[i].indexOf('charset=') === 0) {
49-
charset = meta[i].substring(8);
41+
let charset = '';
42+
let base64 = false;
43+
const type = meta[0] || 'text/plain';
44+
let typeFull = type;
45+
for (let i = 1; i < meta.length; i++) {
46+
if (meta[i] === 'base64') {
47+
base64 = true;
48+
} else if (meta[i]) {
49+
typeFull += `;${meta[i]}`;
50+
if (meta[i].indexOf('charset=') === 0) {
51+
charset = meta[i].substring(8);
52+
}
5053
}
5154
}
52-
}
53-
// defaults to US-ASCII only if type is not provided
54-
if (!meta[0] && !charset.length) {
55-
typeFull += ';charset=US-ASCII';
56-
charset = 'US-ASCII';
57-
}
55+
// defaults to US-ASCII only if type is not provided
56+
if (!meta[0] && !charset.length) {
57+
typeFull += ';charset=US-ASCII';
58+
charset = 'US-ASCII';
59+
}
5860

59-
// get the encoded data portion and decode URI-encoded chars
60-
const data = unescape(uri.substring(firstComma + 1));
61-
const buffer = base64 ? convert.base64ToArrayBuffer(data) : convert.stringToBuffer(data);
61+
// get the encoded data portion and decode URI-encoded chars
62+
const data = unescape(uri.substring(firstComma + 1));
63+
const buffer = base64
64+
? convert.base64ToArrayBuffer(data)
65+
: convert.stringToBuffer(data);
6266

63-
return {
64-
type,
65-
typeFull,
66-
charset,
67-
buffer,
67+
return {
68+
type,
69+
typeFull,
70+
charset,
71+
buffer,
72+
};
6873
};
69-
}

packages/data-uri-to-buffer/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { makeDataUriToBuffer } from './common';
22

3-
export type { ParsedDataURI } from './common';
3+
export type { ParsedDataURI } from './common';
44

55
function base64ToArrayBuffer(base64: string) {
66
const chars =
@@ -55,4 +55,7 @@ function stringToBuffer(str: string): ArrayBuffer {
5555
*
5656
* @param {String} uri Data URI to turn into a Buffer instance
5757
*/
58-
export const dataUriToBuffer = makeDataUriToBuffer({ stringToBuffer, base64ToArrayBuffer });
58+
export const dataUriToBuffer = makeDataUriToBuffer({
59+
stringToBuffer,
60+
base64ToArrayBuffer,
61+
});

packages/data-uri-to-buffer/src/node.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { makeDataUriToBuffer } from './common';
22

3-
export type { ParsedDataURI } from './common';
3+
export type { ParsedDataURI } from './common';
44

55
function nodeBuffertoArrayBuffer(nodeBuf: Buffer) {
66
if (nodeBuf.byteLength === nodeBuf.buffer.byteLength) {
@@ -25,4 +25,7 @@ function stringToBuffer(str: string): ArrayBuffer {
2525
*
2626
* @param {String} uri Data URI to turn into a Buffer instance
2727
*/
28-
export const dataUriToBuffer = makeDataUriToBuffer({ stringToBuffer, base64ToArrayBuffer });
28+
export const dataUriToBuffer = makeDataUriToBuffer({
29+
stringToBuffer,
30+
base64ToArrayBuffer,
31+
});

packages/degenerator/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "tsconfig/base.json",
33
"compilerOptions": {
4-
"outDir": "dist",
4+
"outDir": "dist"
55
},
66
"include": ["src"],
77
"exclude": ["node_modules"]

packages/get-uri/tsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
"outDir": "dist",
99
"sourceMap": true,
1010
"declaration": true,
11-
"typeRoots": [
12-
"./@types",
13-
"./node_modules/@types"
14-
]
11+
"typeRoots": ["./@types", "./node_modules/@types"]
1512
},
1613
"include": ["src/**/*"],
1714
"exclude": ["node_modules"]

0 commit comments

Comments
 (0)