Skip to content

Commit 3ddfc9c

Browse files
chore(deps): bump prettier from 2.6.2 to 3.0.3 (microformats#237)
* chore(deps): bump prettier from 2.6.2 to 3.0.3 Bumps [prettier](https://github.com/prettier/prettier) from 2.6.2 to 3.0.3. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](prettier/prettier@2.6.2...3.0.3) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * run prettier --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: aimee-gm <[email protected]>
1 parent df6a91b commit 3ddfc9c

33 files changed

+113
-113
lines changed

demo/index.tpl.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<title>{{ name }} demo</title>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"parcel-bundler": "^1.12.5",
6969
"posthtml-cli": "^0.10.0",
7070
"posthtml-expressions": "^1.9.0",
71-
"prettier": "^2.0.5",
71+
"prettier": "^3.0.3",
7272
"rollup": "^3.25.0",
7373
"rollup-plugin-dts": "^6.0.2",
7474
"source-map-support": "^0.5.19",

src/backcompat/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const convertV1RootClassNames = (node: Element): string[] => {
5656

5757
export const hasBackcompatMicroformatProperty = (
5858
node: Element,
59-
roots: BackcompatRoot[]
59+
roots: BackcompatRoot[],
6060
): boolean =>
6161
roots.some((root) => {
6262
const { properties, rels } = backcompat[root];
@@ -68,7 +68,7 @@ export const hasBackcompatMicroformatProperty = (
6868

6969
export const convertV1PropertyClassNames = (
7070
node: Element,
71-
roots: BackcompatRoot[]
71+
roots: BackcompatRoot[],
7272
): string[] => [
7373
...new Set(
7474
roots
@@ -77,7 +77,7 @@ export const convertV1PropertyClassNames = (
7777

7878
const classes = getClassNameIntersect(
7979
node,
80-
Object.keys(properties)
80+
Object.keys(properties),
8181
).map((cl) => properties[cl]);
8282

8383
const relClasses =
@@ -87,7 +87,7 @@ export const convertV1PropertyClassNames = (
8787

8888
return [...classes, ...relClasses];
8989
})
90-
.reduce(flatten)
90+
.reduce(flatten),
9191
),
9292
];
9393

src/helpers/attributes.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,57 @@ import { Attribute, Element } from "parse5";
22

33
export const getAttribute = (
44
node: Element,
5-
name: string
5+
name: string,
66
): Attribute | undefined => node.attrs.find((attr) => attr.name === name);
77

88
export const getAttributeValue = (
99
node: Element,
10-
name: string
10+
name: string,
1111
): string | undefined => getAttribute(node, name)?.value;
1212

1313
export const getClassNames = (
1414
node: Element,
15-
matcher?: RegExp | string
15+
matcher?: RegExp | string,
1616
): string[] => {
1717
const classNames = getAttributeValue(node, "class")?.split(" ") || [];
1818

1919
return matcher
2020
? classNames.filter((name) =>
2121
typeof matcher === "string"
2222
? name.startsWith(matcher)
23-
: name.match(matcher)
23+
: name.match(matcher),
2424
)
2525
: classNames;
2626
};
2727

2828
export const getClassNameIntersect = <T extends string>(
2929
node: Element,
30-
toCompare: T[]
30+
toCompare: T[],
3131
): T[] =>
3232
getClassNames(node).filter((name: string): name is T =>
33-
toCompare.includes(name as T)
33+
toCompare.includes(name as T),
3434
);
3535

3636
export const hasClassName = (node: Element, className: string): boolean =>
3737
getClassNames(node).some((name) => name === className);
3838

3939
export const hasClassNameIntersect = (
4040
node: Element,
41-
toCompare: string[]
41+
toCompare: string[],
4242
): boolean => getClassNames(node).some((name) => toCompare.includes(name));
4343

4444
export const getAttributeIfTag = (
4545
node: Element,
4646
tagNames: string[],
47-
attr: string
47+
attr: string,
4848
): string | undefined =>
4949
tagNames.includes(node.tagName) ? getAttributeValue(node, attr) : undefined;
5050

5151
export const hasRelIntersect = (node: Element, toCompare: string[]): boolean =>
5252
Boolean(
5353
getAttributeValue(node, "rel")
5454
?.split(" ")
55-
.some((name) => toCompare.includes(name))
55+
.some((name) => toCompare.includes(name)),
5656
);
5757

5858
export const getRelIntersect = (node: Element, toCompare: string[]): string[] =>

src/helpers/documentSetup.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const findBase = (node: Element | Document): string | undefined => {
3939
const handleNode = (
4040
node: Element | Document,
4141
result: DocumentSetupResult,
42-
options: ParserOptions
42+
options: ParserOptions,
4343
): void => {
4444
for (const i in node.childNodes) {
4545
const child = node.childNodes[i];
@@ -110,7 +110,7 @@ const handleNode = (
110110

111111
export const documentSetup = (
112112
node: Document,
113-
options: ParserOptions
113+
options: ParserOptions,
114114
): DocumentSetupResult => {
115115
const result = {
116116
idRefs: {},

src/helpers/experimental.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ExperimentalName, ParserOptions } from "../types";
22

33
export const isEnabled = (
44
options: ParserOptions,
5-
flag: ExperimentalName
5+
flag: ExperimentalName,
66
): boolean => {
77
if (!options || !options.experimental) {
88
return false;

src/helpers/findChildren.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const getElementChildren = (node: Element | Document): Element[] =>
1818
const reducer = (
1919
microformats: Element[],
2020
node: Element,
21-
options: ReducerOptions
21+
options: ReducerOptions,
2222
): Element[] => {
2323
const { matcher, roots } = options;
2424
const match = matcher(node, roots) && node;
@@ -34,15 +34,15 @@ const reducer = (
3434

3535
const childMicroformats = getElementChildren(node).reduce<Element[]>(
3636
(prev, curr) => reducer(prev, curr, options),
37-
match ? [match] : []
37+
match ? [match] : [],
3838
);
3939

4040
return [...microformats, ...childMicroformats];
4141
};
4242

4343
export const findChildren = (
4444
parent: Element | Document,
45-
matcher: Matcher
45+
matcher: Matcher,
4646
): Element[] => {
4747
const findOptions = {
4848
roots: isElement(parent) ? getBackcompatRootClassNames(parent) : [],
@@ -52,6 +52,6 @@ export const findChildren = (
5252

5353
return getElementChildren(parent).reduce<Element[]>(
5454
(prev, curr) => reducer(prev, curr, findOptions),
55-
[]
55+
[],
5656
);
5757
};

src/helpers/images.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Image, ParsingOptions } from "../types";
55

66
export const parseImage = (
77
node: Element,
8-
{ inherited }: Partial<ParsingOptions> = {}
8+
{ inherited }: Partial<ParsingOptions> = {},
99
): Image | string | undefined => {
1010
if (node.tagName !== "img") {
1111
return;

src/helpers/includes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ const applyIncludes = (node: Element, options: ParsingOptions): void => {
2222
(child) =>
2323
isElement(child) &&
2424
!isMicroformatRoot(child) &&
25-
applyIncludes(child, options)
25+
applyIncludes(child, options),
2626
);
2727
};
2828

2929
export const applyIncludesToRoot = (
3030
node: Element,
31-
options: ParsingOptions
31+
options: ParsingOptions,
3232
): void => {
3333
if (isMicroformatV2Root(node)) {
3434
return;

src/helpers/metaformats.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const initializeMetaContentCollection = (): MetaContentCollection => {
8989
.map((existingValue) =>
9090
typeof existingValue === "string"
9191
? existingValue
92-
: existingValue.value
92+
: existingValue.value,
9393
)
9494
.some((existingValue) => value === existingValue);
9595

@@ -160,7 +160,7 @@ const collectMetaTags = (head: Element): MetaContentCollection => {
160160
*/
161161
const combineRoot = (
162162
metaTags: MetaContentCollection,
163-
options: ParsingOptions
163+
options: ParsingOptions,
164164
): MicroformatRoot[] => {
165165
const item: MicroformatRoot = { properties: {} };
166166

@@ -175,7 +175,7 @@ const combineRoot = (
175175
*/
176176
const setMicroformatProp = (
177177
property: string,
178-
value: MetaTagContent[] = []
178+
value: MetaTagContent[] = [],
179179
) => {
180180
const filteredValue = value.filter(Boolean);
181181
if (filteredValue.length) {
@@ -196,18 +196,18 @@ const combineRoot = (
196196

197197
setMicroformatProp(
198198
"name",
199-
metaTags.get(["og:title", "twitter:title", TITLE_TAG_KEY])
199+
metaTags.get(["og:title", "twitter:title", TITLE_TAG_KEY]),
200200
);
201201
setMicroformatProp(
202202
"summary",
203-
metaTags.get(["og:description", "twitter:description", "description"])
203+
metaTags.get(["og:description", "twitter:description", "description"]),
204204
);
205205
setMicroformatProp("featured", metaTags.get(["og:image", "twitter:image"]));
206206
setMicroformatProp("video", metaTags.get(["og:video", "twitter:video"]));
207207
setMicroformatProp("audio", metaTags.get(["og:audio", "twitter:audio"]));
208208
setMicroformatProp(
209209
"published",
210-
metaTags.get(["article:published_time", "date"])
210+
metaTags.get(["article:published_time", "date"]),
211211
);
212212
setMicroformatProp("updated", metaTags.get(["article:modified_time"]));
213213
setMicroformatProp("author", metaTags.get(["article:author", "author"]));
@@ -216,7 +216,7 @@ const combineRoot = (
216216
// Publication properties useful for h-cite
217217
setMicroformatProp(
218218
"publication",
219-
metaTags.get(["og:site_name", "publisher"])
219+
metaTags.get(["og:site_name", "publisher"]),
220220
);
221221

222222
if (impliedRootClass === "h-card") {
@@ -233,7 +233,7 @@ const combineRoot = (
233233

234234
export const parseMetaformats = (
235235
doc: Document,
236-
options: ParsingOptions
236+
options: ParsingOptions,
237237
): MicroformatRoot[] => {
238238
// Per validation, html element will always be found
239239
const html = doc.childNodes.find(isTag("html"));

src/helpers/nodeMatchers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ export const isMicroformatRoot = (node: Element): boolean =>
3838

3939
export const isMicroformatV1Property = (
4040
node: Element,
41-
roots: BackcompatRoot[]
41+
roots: BackcompatRoot[],
4242
): boolean => hasBackcompatMicroformatProperty(node, roots);
4343

4444
export const isMicroformatV2Property = (node: Element): boolean =>
4545
getClassNames(node, propClassRegex).length > 0;
4646

4747
export const isMicroformatChild = (
4848
node: Element,
49-
roots: BackcompatRoot[]
49+
roots: BackcompatRoot[],
5050
): boolean =>
5151
!isMicroformatV2Property(node) &&
5252
!isMicroformatV1Property(node, roots) &&
5353
isMicroformatRoot(node);
5454

5555
export const isBase = (node: Element): boolean =>
5656
Boolean(
57-
isElement(node) && node.tagName === "base" && getAttribute(node, "href")
57+
isElement(node) && node.tagName === "base" && getAttribute(node, "href"),
5858
);
5959

6060
export const isValueClass = (node: Element): boolean =>
@@ -64,5 +64,5 @@ export const isRel = (node: Element): boolean =>
6464
Boolean(
6565
isElement(node) &&
6666
node.attrs.some((attr) => attr.name === "rel") &&
67-
node.attrs.some((attr) => attr.name === "href")
67+
node.attrs.some((attr) => attr.name === "href"),
6868
);

src/helpers/textContent.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const textContent = (node: Element, options: ParserOptions): string => {
100100

101101
export const impliedTextContent = (
102102
node: Element,
103-
options: ParserOptions
103+
options: ParserOptions,
104104
): string => {
105105
if (isEnabled(options, "textContent")) {
106106
return experimentalTextContent(node);
@@ -111,7 +111,7 @@ export const impliedTextContent = (
111111

112112
export const relTextContent = (
113113
node: Element,
114-
options: ParserOptions
114+
options: ParserOptions,
115115
): string => {
116116
if (isEnabled(options, "textContent")) {
117117
return experimentalTextContent(node);

src/helpers/valueClassPattern.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const handleDate = (dateStrings: string[]): string | undefined =>
2525
dateStrings
2626
.sort((a) =>
2727
// Sort the date elements to move date components to the start
28-
a.match(/^[0-9]{4}/) ? -1 : 1
28+
a.match(/^[0-9]{4}/) ? -1 : 1,
2929
)
3030
.join(" ")
3131
.trim()
3232
.replace(
3333
// remove ":" from timezones
3434
/((\+|-)[0-2][0-9]):([0-5][0-9])$/,
35-
(s) => s.replace(":", "")
35+
(s) => s.replace(":", ""),
3636
)
3737
.replace(
3838
// handle am and pm times
@@ -49,13 +49,13 @@ const handleDate = (dateStrings: string[]): string | undefined =>
4949

5050
// reconstruct, and add mins if any are missing
5151
return `${newHour}${min ? min : ":00"}${sec || ""}`;
52-
}
52+
},
5353
)
5454
.toUpperCase();
5555

5656
export const valueClassPattern = (
5757
node: Element,
58-
options: ParsingOptions & Partial<Options>
58+
options: ParsingOptions & Partial<Options>,
5959
): string | undefined => {
6060
const values = findChildren(node, isValueClass);
6161

@@ -66,7 +66,7 @@ export const valueClassPattern = (
6666
if (options.datetime) {
6767
const date = values.map(
6868
(node) =>
69-
datetimeProp(node) ?? valueTitle(node) ?? textContent(node, options)
69+
datetimeProp(node) ?? valueTitle(node) ?? textContent(node, options),
7070
);
7171
return handleDate(date);
7272
}

src/implied/name.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const parseGrandchild = (node: Element): string | undefined => {
2222
export const impliedName = (
2323
node: Element,
2424
children: Element[],
25-
options: ParsingOptions
25+
options: ParsingOptions,
2626
): string | undefined => {
2727
if (children.some((child) => getClassNames(child, /^(p|e|h)-/).length)) {
2828
return;

src/implied/photo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const parseGrandchild = (node: Element): string | Image | undefined => {
3838

3939
export const impliedPhoto = (
4040
node: Element,
41-
children: Element[]
41+
children: Element[],
4242
): Image | string | undefined => {
4343
if (children.some((child) => getClassNames(child, "u-").length)) {
4444
return;

src/implied/url.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const parseGrandchild = (node: Element): string | undefined => {
2727

2828
export const impliedUrl = (
2929
node: Element,
30-
children: Element[]
30+
children: Element[],
3131
): string | undefined => {
3232
if (children.some((child) => getClassNames(child, "u-").length)) {
3333
return;

0 commit comments

Comments
 (0)