Skip to content

Commit c5d7531

Browse files
authored
Update config files to use plain JS instead of JSON (#149)
1 parent 6a47732 commit c5d7531

File tree

6 files changed

+27
-35
lines changed

6 files changed

+27
-35
lines changed

index.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import { readFile } from "fs/promises";
21
import _ from "lodash-es";
32
import { githubMarkdownLint } from "./src/rules/index.js";
43

5-
const offByDefault = ["no-empty-alt-text"];
4+
import accessibilityRules from "./style/accessibility.js";
5+
import baseRules from "./style/base.js";
66

7-
export async function init(consumerConfig) {
8-
// left overwrites right
9-
const accessibilityRules = JSON.parse(
10-
await readFile(new URL("./style/accessibility.json", import.meta.url)),
11-
);
7+
const offByDefault = ["no-empty-alt-text"];
128

13-
const base = JSON.parse(
14-
await readFile(new URL("./style/base.json", import.meta.url)),
15-
);
9+
export function init(consumerConfig) {
10+
const base = { ...baseRules };
1611

1712
for (const rule of githubMarkdownLint) {
1813
const ruleName = rule.names[1];

style/accessibility.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default {
2+
"no-alt-text": true,
3+
"no-default-alt-text": true,
4+
"no-duplicate-heading": true,
5+
"no-emphasis-as-heading": true,
6+
"no-generic-link-text": true,
7+
"heading-increment": true,
8+
"no-space-in-links": false,
9+
"ol-prefix": "ordered",
10+
"single-h1": true,
11+
"ul-style": {
12+
style: "asterisk",
13+
},
14+
};

style/accessibility.json

-14
This file was deleted.

style/base.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default {
2+
default: true,
3+
"no-inline-html": false,
4+
"no-bare-urls": false,
5+
"no-blanks-blockquote": false,
6+
"fenced-code-language": true,
7+
};

style/base.json

-7
This file was deleted.

test/accessibility-rules.test.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import { readFile } from "fs/promises";
21
import { lint } from "markdownlint/async";
32
import githubMarkdownLint from "../index.js";
3+
import accessibilityRules from "../style/accessibility.js";
44

55
const exampleFileName = "./test/example.md";
66

77
describe("when A11y rules applied", () => {
88
test("fails expected rules", async () => {
9-
const accessibilityRules = JSON.parse(
10-
await readFile(new URL("../style/accessibility.json", import.meta.url)),
11-
);
129
const options = {
1310
config: {
1411
default: false,

0 commit comments

Comments
 (0)