Skip to content

Commit

Permalink
Fix Prettier check
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Nov 9, 2023
1 parent 25de946 commit d0947a3
Show file tree
Hide file tree
Showing 31 changed files with 51 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
with:
node-version: 20
- run: npm ci
- run: npx prettier .
- run: npx prettier --check .

remark:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/code.lang-mermaid/img-png.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<head></head>
<body>
<p>
A `code` element with class "language-mermaid" should be replaced with the
rendered diagram.
A `code` element with class "language-mermaid" should be replaced with the rendered diagram.
</p>
<img
alt=""
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/code.lang-mermaid/img-svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<head></head>
<body>
<p>
A `code` element with class "language-mermaid" should be replaced with the
rendered diagram.
A `code` element with class "language-mermaid" should be replaced with the rendered diagram.
</p>
<img
alt=""
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/code.lang-mermaid/inline-svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<head></head>
<body>
<p>
A `code` element with class "language-mermaid" should be replaced with the
rendered diagram.
A `code` element with class "language-mermaid" should be replaced with the rendered diagram.
</p>
<svg
aria-roledescription="flowchart-v2"
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/code.lang-mermaid/pre-mermaid.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<head></head>
<body>
<p>
A `code` element with class "language-mermaid" should be replaced with the
rendered diagram.
A `code` element with class "language-mermaid" should be replaced with the rendered diagram.
</p>
<pre class="mermaid">graph TD; A;</pre>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
id="mermaid-0"
>
<title id="chart-title-mermaid-0">Big Decisions</title>
<desc id="chart-desc-mermaid-0">
Bob's Burgers process for making big decisions
</desc>
<desc id="chart-desc-mermaid-0">Bob's Burgers process for making big decisions</desc>
<style>
#mermaid-0 {
font-family: arial, sans-serif;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram. The `code` element may have children.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram. The `code` element may have children.
</p>

<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram. The `code` element may have children.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram. The `code` element may have children.
</p>

<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram. The `code` element may have children.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram. The `code` element may have children.
</p>

<svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram. The `code` element may have children.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram. The `code` element may have children.
</p>

<pre class="mermaid">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<html>
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" has siblings, it should
be ignored
</p>
<p>If a `code` element with class "language-mermaid" has siblings, it should be ignored</p>
<pre> <code class="language-mermaid">
graph TD;
A-->B;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<html>
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" has siblings, it should
be ignored
</p>
<p>If a `code` element with class "language-mermaid" has siblings, it should be ignored</p>
<pre> <code class="language-mermaid">
graph TD;
A-->B;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<html>
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" has siblings, it should
be ignored
</p>
<p>If a `code` element with class "language-mermaid" has siblings, it should be ignored</p>
<pre> <code class="language-mermaid">
graph TD;
A-->B;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<html>
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" has siblings, it should
be ignored
</p>
<p>If a `code` element with class "language-mermaid" has siblings, it should be ignored</p>
<pre> <code class="language-mermaid">
graph TD;
A-->B;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<html>
<head></head>
<body>
<p>
If a code element with class "language-mermaid" has siblings, it should be
ignored
</p>
<p>If a code element with class "language-mermaid" has siblings, it should be ignored</p>
<pre> This diagram is ignored.
<code class="language-mermaid">
graph TD;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<html>
<head></head>
<body>
<p>
If a code element with class "language-mermaid" has siblings, it should be
ignored
</p>
<p>If a code element with class "language-mermaid" has siblings, it should be ignored</p>
<pre> This diagram is ignored.
<code class="language-mermaid">
graph TD;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<html>
<head></head>
<body>
<p>
If a code element with class "language-mermaid" has siblings, it should be
ignored
</p>
<p>If a code element with class "language-mermaid" has siblings, it should be ignored</p>
<pre> This diagram is ignored.
<code class="language-mermaid">
graph TD;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<html>
<head></head>
<body>
<p>
If a code element with class "language-mermaid" has siblings, it should be
ignored
</p>
<p>If a code element with class "language-mermaid" has siblings, it should be ignored</p>
<pre> This diagram is ignored.
<code class="language-mermaid">
graph TD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram. Whitespace siblings are allowed.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram. Whitespace siblings are allowed.
</p>
<img
alt=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram. Whitespace siblings are allowed.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram. Whitespace siblings are allowed.
</p>
<img
alt=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram. Whitespace siblings are allowed.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram. Whitespace siblings are allowed.
</p>
<svg
aria-roledescription="flowchart-v2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram. Whitespace siblings are allowed.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram. Whitespace siblings are allowed.
</p>
<pre class="mermaid">
graph TD;
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/pre code.language-mermaid/img-png.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram.
</p>
<img
alt=""
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/pre code.language-mermaid/img-svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram.
</p>
<img
alt=""
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/pre code.language-mermaid/inline-svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram.
</p>
<svg
aria-roledescription="flowchart-v2"
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/pre code.language-mermaid/pre-mermaid.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<head></head>
<body>
<p>
If a `code` element with class "language-mermaid" is wrapped inside a
`pre`, the entire `pre` element should be replaced with the rendered
diagram.
If a `code` element with class "language-mermaid" is wrapped inside a `pre`, the entire `pre`
element should be replaced with the rendered diagram.
</p>
<pre class="mermaid">
graph TD;
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/pre.mermaid/img-png.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<head></head>
<body>
<p>
A `pre` element without class "mermaid" should be ignored by the
"pre-mermaid" stategy, but rendered by others.
A `pre` element without class "mermaid" should be ignored by the "pre-mermaid" stategy, but
rendered by others.
</p>
<img
alt=""
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/pre.mermaid/img-svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<head></head>
<body>
<p>
A `pre` element without class "mermaid" should be ignored by the
"pre-mermaid" stategy, but rendered by others.
A `pre` element without class "mermaid" should be ignored by the "pre-mermaid" stategy, but
rendered by others.
</p>
<img
alt=""
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/pre.mermaid/inline-svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<head></head>
<body>
<p>
A `pre` element without class "mermaid" should be ignored by the
"pre-mermaid" stategy, but rendered by others.
A `pre` element without class "mermaid" should be ignored by the "pre-mermaid" stategy, but
rendered by others.
</p>
<svg
aria-roledescription="flowchart-v2"
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/pre.mermaid/pre-mermaid.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<head></head>
<body>
<p>
A `pre` element without class "mermaid" should be ignored by the
"pre-mermaid" stategy, but rendered by others.
A `pre` element without class "mermaid" should be ignored by the "pre-mermaid" stategy, but
rendered by others.
</p>
<pre class="mermaid">
graph TD;
Expand Down
6 changes: 5 additions & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict'
import { readdir, readFile, writeFile } from 'node:fs/promises'
import { describe, test } from 'node:test'
import { fileURLToPath } from 'node:url'

import { type Element, type Root } from 'hast'
import prettier from 'prettier'
Expand Down Expand Up @@ -35,7 +36,10 @@ async function readFixture(name: string, expectedName: string): Promise<FixtureT
return {
input,
async validate(actual, verify = true) {
const normalized = await prettier.format(String(actual), { parser: 'html' })
const config = await prettier.resolveConfig(fileURLToPath(expectedPath), {
editorconfig: true
})
const normalized = await prettier.format(String(actual), { ...config, parser: 'html' })
if (process.argv.includes('update') || !expected) {
await writeFile(expectedPath, normalized)
}
Expand Down

0 comments on commit d0947a3

Please sign in to comment.