Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 671c049

Browse files
committedJan 17, 2025·
Fix missing trailing .js and following tests
1 parent 84aebbc commit 671c049

6 files changed

+25
-24
lines changed
 

‎.markdownlint-cli2.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const configOptions = await init({
88
"no-emphasis-as-heading": true,
99
"first-line-heading": true,
1010
});
11-
console.log(configOptions);
1211
const options = {
1312
config: configOptions,
1413
customRules: ["./index.js"],

‎index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import { readFile } from "fs/promises";
22
import _ from "lodash-es";
3-
// import githubMarkdownLint from "./src/rules/index.js";
3+
import { githubMarkdownLint } from "./src/rules/index.js";
44

55
const offByDefault = ["no-empty-alt-text"];
6-
// const foo = [altTextRule, noGenericLinkTextRule, noEmptyStringAltRule];
7-
// for (const rule of foo) {
8-
// const ruleName = rule.names[1];
9-
// base[ruleName] = offByDefault.includes(ruleName) ? false : true;
10-
// }
116

127
export async function init(consumerConfig) {
138
// left overwrites right
149
const accessibilityRules = JSON.parse(
15-
await readFile(new URL("./style/accessibility.json", import.meta.url))
10+
await readFile(new URL("./style/accessibility.json", import.meta.url)),
1611
);
1712

1813
const base = JSON.parse(
19-
await readFile(new URL("./style/base.json", import.meta.url))
14+
await readFile(new URL("./style/base.json", import.meta.url)),
2015
);
2116

17+
for (const rule of githubMarkdownLint) {
18+
const ruleName = rule.names[1];
19+
base[ruleName] = offByDefault.includes(ruleName) ? false : true;
20+
}
21+
2222
return _.defaultsDeep(consumerConfig, accessibilityRules, base);
2323
}
2424

25-
// export { default } from "./rules";
25+
export default githubMarkdownLint;

‎src/rules/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ import { noEmptyStringAltRule } from "./no-empty-alt-text.js";
22
import { noGenericLinkTextRule } from "./no-generic-link-text.js";
33
import { altTextRule } from "./no-default-alt-text.js";
44

5-
export default { noEmptyStringAltRule, noGenericLinkTextRule, altTextRule };
5+
// export default { noEmptyStringAltRule, noGenericLinkTextRule, altTextRule };
6+
7+
export const githubMarkdownLint = [
8+
altTextRule,
9+
noGenericLinkTextRule,
10+
noEmptyStringAltRule,
11+
];

‎src/rules/no-generic-link-text.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { stripAndDowncaseText } from "../helpers/strip-and-downcase-text";
1+
import { stripAndDowncaseText } from "../helpers/strip-and-downcase-text.js";
22

33
const bannedLinkText = [
44
"read more",

‎test/accessibility-rules.test.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { lint } from "markdownlint/async";
2-
// import * as accessibilityRulesConfig from "../style/accessibility.json";
32
import { githubMarkdownLint } from "../src/rules";
43

54
const exampleFileName = "./test/example.md";
@@ -28,8 +27,6 @@ const options = {
2827
customRules: githubMarkdownLint,
2928
};
3029

31-
console.log(options);
32-
3330
describe("when A11y rules applied", () => {
3431
test("fails expected rules", async () => {
3532
const result = await new Promise((resolve, reject) => {

‎test/usage.test.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ describe("usage", () => {
55
describe("default export", () => {
66
test("custom rules on default export", () => {
77
const rules = githubMarkdownLint;
8-
console.log(rules);
98
expect(rules).toHaveLength(3);
109

1110
expect(rules[0].names).toEqual(["GH001", "no-default-alt-text"]);
@@ -14,8 +13,8 @@ describe("usage", () => {
1413
});
1514
});
1615
describe("init method", () => {
17-
test("default options returned with no arguments provided", () => {
18-
const options = init();
16+
test("default options returned with no arguments provided", async () => {
17+
const options = await init();
1918
expect(options).toEqual({
2019
"no-duplicate-heading": true,
2120
"ol-prefix": "ordered",
@@ -38,8 +37,8 @@ describe("usage", () => {
3837
});
3938
});
4039

41-
test("arguments override default configuration", () => {
42-
const defaultOptions = init();
40+
test("arguments override default configuration", async () => {
41+
const defaultOptions = await init();
4342

4443
const toTestOptions = Object.keys(defaultOptions).slice(0, 3);
4544

@@ -54,20 +53,20 @@ describe("usage", () => {
5453
expect(originalConfig).not.toEqual(consumerConfig);
5554

5655
// do config step
57-
const options = init(consumerConfig);
56+
const options = await init(consumerConfig);
5857

5958
// confirm config is set by consumer
6059
expect(options).toHaveProperty(
6160
toTestOptions[0],
62-
consumerConfig[toTestOptions[0]]
61+
consumerConfig[toTestOptions[0]],
6362
);
6463
expect(options).toHaveProperty(
6564
toTestOptions[1],
66-
consumerConfig[toTestOptions[1]]
65+
consumerConfig[toTestOptions[1]],
6766
);
6867
expect(options).toHaveProperty(
6968
toTestOptions[2],
70-
consumerConfig[toTestOptions[2]]
69+
consumerConfig[toTestOptions[2]],
7170
);
7271
});
7372
});

0 commit comments

Comments
 (0)
Please sign in to comment.