diff --git a/index.js b/index.js index 8983146..a47964e 100644 --- a/index.js +++ b/index.js @@ -1,18 +1,13 @@ -import { readFile } from "fs/promises"; import _ from "lodash-es"; import { githubMarkdownLint } from "./src/rules/index.js"; -const offByDefault = ["no-empty-alt-text"]; +import accessibilityRules from "./style/accessibility.js"; +import baseRules from "./style/base.js"; -export async function init(consumerConfig) { - // left overwrites right - const accessibilityRules = JSON.parse( - await readFile(new URL("./style/accessibility.json", import.meta.url)), - ); +const offByDefault = ["no-empty-alt-text"]; - const base = JSON.parse( - await readFile(new URL("./style/base.json", import.meta.url)), - ); +export function init(consumerConfig) { + const base = { ...baseRules }; for (const rule of githubMarkdownLint) { const ruleName = rule.names[1]; diff --git a/style/accessibility.js b/style/accessibility.js new file mode 100644 index 0000000..5c0cee2 --- /dev/null +++ b/style/accessibility.js @@ -0,0 +1,14 @@ +export default { + "no-alt-text": true, + "no-default-alt-text": true, + "no-duplicate-heading": true, + "no-emphasis-as-heading": true, + "no-generic-link-text": true, + "heading-increment": true, + "no-space-in-links": false, + "ol-prefix": "ordered", + "single-h1": true, + "ul-style": { + style: "asterisk", + }, +}; diff --git a/style/accessibility.json b/style/accessibility.json deleted file mode 100644 index a8736c4..0000000 --- a/style/accessibility.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "no-alt-text": true, - "no-default-alt-text": true, - "no-duplicate-heading": true, - "no-emphasis-as-heading": true, - "no-generic-link-text": true, - "heading-increment": true, - "no-space-in-links": false, - "ol-prefix": "ordered", - "single-h1": true, - "ul-style": { - "style": "asterisk" - } -} diff --git a/style/base.js b/style/base.js new file mode 100644 index 0000000..fd2886d --- /dev/null +++ b/style/base.js @@ -0,0 +1,7 @@ +export default { + default: true, + "no-inline-html": false, + "no-bare-urls": false, + "no-blanks-blockquote": false, + "fenced-code-language": true, +}; diff --git a/style/base.json b/style/base.json deleted file mode 100644 index b323b64..0000000 --- a/style/base.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "default": true, - "no-inline-html": false, - "no-bare-urls": false, - "no-blanks-blockquote": false, - "fenced-code-language": true -} diff --git a/test/accessibility-rules.test.js b/test/accessibility-rules.test.js index 8fc6548..14e5eb7 100644 --- a/test/accessibility-rules.test.js +++ b/test/accessibility-rules.test.js @@ -1,14 +1,11 @@ -import { readFile } from "fs/promises"; import { lint } from "markdownlint/async"; import githubMarkdownLint from "../index.js"; +import accessibilityRules from "../style/accessibility.js"; const exampleFileName = "./test/example.md"; describe("when A11y rules applied", () => { test("fails expected rules", async () => { - const accessibilityRules = JSON.parse( - await readFile(new URL("../style/accessibility.json", import.meta.url)), - ); const options = { config: { default: false,