@storm-software/markdownlint 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -16
- package/LICENSE +201 -0
- package/README.md +7 -3
- package/index.js +5729 -0
- package/package.json +19 -19
- package/.eslintrc.json +0 -37
- package/jest.config.ts +0 -3
- package/project.json +0 -57
- package/src/index.ts +0 -28
- package/src/rules/index.ts +0 -5
- package/src/rules/no-default-alt-text.ts +0 -69
- package/src/rules/no-empty-alt-text.ts +0 -48
- package/src/rules/no-generic-link-text.ts +0 -62
- package/src/style/accessibility.json +0 -14
- package/src/style/base.json +0 -12
- package/tsconfig.json +0 -11
- package/tsconfig.spec.json +0 -13
package/package.json
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storm-software/markdownlint",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"type": "commonjs",
|
|
5
5
|
"description": "⚡An opinionated collection of markdownlint rules used by Storm Software.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "github",
|
|
8
|
+
"url": "https://github.com/storm-software/storm-ops.git",
|
|
9
|
+
"directory": "packages/markdownlint"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://stormsoftware.com",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/storm-software/storm-ops/issues",
|
|
14
|
+
"email": "support@stormsoftware.com"
|
|
15
|
+
},
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Storm Software",
|
|
18
|
+
"email": "contact@stormsoftware.com",
|
|
19
|
+
"url": "https://stormsoftware.com"
|
|
20
|
+
},
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"private": false,
|
|
6
23
|
"keywords": [
|
|
7
24
|
"storm",
|
|
8
25
|
"storm-ops",
|
|
@@ -15,23 +32,6 @@
|
|
|
15
32
|
"markdownlint-cli",
|
|
16
33
|
"markdownlint-cli2"
|
|
17
34
|
],
|
|
18
|
-
"homepage": "https://stormsoftware.com",
|
|
19
|
-
"bugs": {
|
|
20
|
-
"url": "https://github.com/storm-software/storm-ops/issues",
|
|
21
|
-
"email": "support@stormsoftware.com"
|
|
22
|
-
},
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "github",
|
|
25
|
-
"url": "https://github.com/storm-software/storm-ops.git",
|
|
26
|
-
"directory": "packages/markdownlint"
|
|
27
|
-
},
|
|
28
|
-
"license": "Apache-2.0",
|
|
29
|
-
"author": {
|
|
30
|
-
"name": "Storm Software",
|
|
31
|
-
"email": "contact@stormsoftware.com",
|
|
32
|
-
"url": "https://stormsoftware.com"
|
|
33
|
-
},
|
|
34
|
-
"type": "module",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"lodash": "4.17.21"
|
|
37
37
|
},
|
package/.eslintrc.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["../../.eslintrc.base.json"],
|
|
3
|
-
"ignorePatterns": ["!**/*", "node_modules/*"],
|
|
4
|
-
"overrides": [
|
|
5
|
-
{
|
|
6
|
-
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
-
"rules": {}
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"files": ["*.ts", "*.tsx"],
|
|
11
|
-
"rules": {}
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"files": ["*.js", "*.jsx"],
|
|
15
|
-
"rules": {}
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"files": ["*.json"],
|
|
19
|
-
"parser": "jsonc-eslint-parser",
|
|
20
|
-
"rules": {
|
|
21
|
-
"@nx/dependency-checks": [
|
|
22
|
-
"error",
|
|
23
|
-
{
|
|
24
|
-
"buildTargets": ["build"],
|
|
25
|
-
"ignoredFiles": [
|
|
26
|
-
"{projectRoot}/esbuild.config.{js,ts,mjs,mts}",
|
|
27
|
-
"{projectRoot}/jest.config.ts"
|
|
28
|
-
],
|
|
29
|
-
"checkMissingDependencies": true,
|
|
30
|
-
"checkObsoleteDependencies": true,
|
|
31
|
-
"checkVersionMismatches": false
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
}
|
package/jest.config.ts
DELETED
package/project.json
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "markdownlint",
|
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"projectType": "library",
|
|
5
|
-
"sourceRoot": "packages/markdownlint/src",
|
|
6
|
-
"targets": {
|
|
7
|
-
"build": {
|
|
8
|
-
"executor": "@nx/esbuild:esbuild",
|
|
9
|
-
"outputs": ["{options.outputPath}"],
|
|
10
|
-
"options": {
|
|
11
|
-
"outputPath": "dist/packages/markdownlint",
|
|
12
|
-
"tsConfig": "packages/markdownlint/tsconfig.json",
|
|
13
|
-
"project": "packages/markdownlint/package.json",
|
|
14
|
-
"main": "packages/markdownlint/src/index.ts",
|
|
15
|
-
"defaultConfiguration": "production",
|
|
16
|
-
"deleteOutputPath": true,
|
|
17
|
-
"sourcemap": false,
|
|
18
|
-
"minify": false,
|
|
19
|
-
"skipTypeCheck": true,
|
|
20
|
-
"platform": "node",
|
|
21
|
-
"format": ["cjs"],
|
|
22
|
-
"esbuildOptions": {
|
|
23
|
-
"outExtension": {
|
|
24
|
-
".js": ".js"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"assets": [
|
|
28
|
-
{
|
|
29
|
-
"input": "packages/markdownlint",
|
|
30
|
-
"glob": "README.md",
|
|
31
|
-
"output": "."
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"input": "packages/markdownlint",
|
|
35
|
-
"glob": "CHANGELOG.md",
|
|
36
|
-
"output": "."
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"input": "",
|
|
40
|
-
"glob": "LICENSE",
|
|
41
|
-
"output": "."
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
"configurations": {
|
|
46
|
-
"production": {
|
|
47
|
-
"debug": false,
|
|
48
|
-
"verbose": false
|
|
49
|
-
},
|
|
50
|
-
"development": {
|
|
51
|
-
"debug": true,
|
|
52
|
-
"verbose": true
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The markdownlint library used by Storm Software for building TypeScript applications.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* An opinionated collection of markdownlint rules used by Storm Software.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import _ from "lodash";
|
|
11
|
-
import accessibilityRules from "./style/accessibility.json";
|
|
12
|
-
import base from "./style/base.json";
|
|
13
|
-
import { rules } from "./rules";
|
|
14
|
-
|
|
15
|
-
const offByDefault = ["no-empty-alt-text"];
|
|
16
|
-
|
|
17
|
-
for (const rule of rules) {
|
|
18
|
-
const ruleName = rule.names[1];
|
|
19
|
-
if (ruleName) {
|
|
20
|
-
base[ruleName] = offByDefault.includes(ruleName) ? false : true;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const init = function init(defaultConfig) {
|
|
25
|
-
return _.defaultsDeep(defaultConfig, accessibilityRules, base);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default [...rules];
|
package/src/rules/index.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Examples:
|
|
3
|
-
* * "Screen Shot 2020-10-20 at 2 52 27 PM"
|
|
4
|
-
* * "Screenshot 2020-10-20 at 2 52 27 PM"
|
|
5
|
-
* * "Clean Shot 2020-10-20 @45x"
|
|
6
|
-
* * "Screencast from 23 02 2024 19 15 19]"
|
|
7
|
-
*/
|
|
8
|
-
const defaultScreenshotRegex =
|
|
9
|
-
"(?:screen|clean) ?(?:shot|cast) \\d{4}-\\d{2}-\\d{2}[^'\"\\]]*";
|
|
10
|
-
|
|
11
|
-
const imageRegex = "image";
|
|
12
|
-
const combinedRegex = `(${[defaultScreenshotRegex, imageRegex].join("|")})`;
|
|
13
|
-
|
|
14
|
-
const markdownAltRegex = new RegExp(`!\\[${combinedRegex}\\]\\(.*\\)`, "gid");
|
|
15
|
-
const htmlAltRegex = new RegExp(`alt=["']${combinedRegex}["']`, "gid");
|
|
16
|
-
|
|
17
|
-
export default {
|
|
18
|
-
names: ["SS001", "no-default-alt-text"],
|
|
19
|
-
description: "Images should have meaningful alternative text (alt text)",
|
|
20
|
-
information: new URL(
|
|
21
|
-
"https://github.com/github/markdownlint-github/blob/main/docs/rules/GH001-no-default-alt-text.md"
|
|
22
|
-
),
|
|
23
|
-
tags: ["accessibility", "images"],
|
|
24
|
-
function: function SS001(params, onError) {
|
|
25
|
-
const htmlTagsWithImages = params.parsers.markdownit.tokens.filter(
|
|
26
|
-
token => {
|
|
27
|
-
return (
|
|
28
|
-
(token.type === "html_block" && token.content.includes("<img")) ||
|
|
29
|
-
(token.type === "inline" &&
|
|
30
|
-
token.content.includes("<img") &&
|
|
31
|
-
token.children.some(child => child.type === "html_inline"))
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
const inlineImages = params.parsers.markdownit.tokens.filter(
|
|
36
|
-
token =>
|
|
37
|
-
token.type === "inline" &&
|
|
38
|
-
token.children.some(child => child.type === "image")
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
for (const token of [...htmlTagsWithImages, ...inlineImages]) {
|
|
42
|
-
const lineRange = token.map;
|
|
43
|
-
const lineNumber = token.lineNumber;
|
|
44
|
-
const lines = params.lines.slice(lineRange[0], lineRange[1]);
|
|
45
|
-
for (let i = 0; i < lines.length; i++) {
|
|
46
|
-
const line = lines[i];
|
|
47
|
-
let matches;
|
|
48
|
-
if (token.type === "inline") {
|
|
49
|
-
if (token.children.some(child => child.type === "html_inline")) {
|
|
50
|
-
matches = line.matchAll(htmlAltRegex);
|
|
51
|
-
} else {
|
|
52
|
-
matches = line.matchAll(markdownAltRegex);
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
matches = line.matchAll(htmlAltRegex);
|
|
56
|
-
}
|
|
57
|
-
for (const match of matches) {
|
|
58
|
-
const altText = match[1];
|
|
59
|
-
const [startIndex] = match.indices[1];
|
|
60
|
-
onError({
|
|
61
|
-
lineNumber: lineNumber + i,
|
|
62
|
-
range: [startIndex + 1, altText.length],
|
|
63
|
-
detail: `Flagged alt: ${altText}`
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
names: ["SS003", "no-empty-alt-text"],
|
|
3
|
-
description: "Please provide an alternative text for the image.",
|
|
4
|
-
information: new URL(
|
|
5
|
-
"https://github.com/github/markdownlint-github/blob/main/docs/rules/GH003-no-empty-alt-text.md"
|
|
6
|
-
),
|
|
7
|
-
tags: ["accessibility", "images"],
|
|
8
|
-
function: function SS003(params, onError) {
|
|
9
|
-
const htmlTagsWithImages = params.parsers.markdownit.tokens.filter(
|
|
10
|
-
token => {
|
|
11
|
-
return (
|
|
12
|
-
(token.type === "html_block" && token.content.includes("<img")) ||
|
|
13
|
-
(token.type === "inline" &&
|
|
14
|
-
token.content.includes("<img") &&
|
|
15
|
-
token.children.some(child => child.type === "html_inline"))
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const ImageRegex = new RegExp(/<img(.*?)>/, "gid");
|
|
21
|
-
const htmlEmptyAltRegex = new RegExp(/alt=['"]['"]/, "gid");
|
|
22
|
-
for (const token of htmlTagsWithImages) {
|
|
23
|
-
const lineRange = token.map;
|
|
24
|
-
const lineNumber = token.lineNumber;
|
|
25
|
-
const lines = params.lines.slice(lineRange[0], lineRange[1]);
|
|
26
|
-
|
|
27
|
-
for (const [i, line] of lines.entries()) {
|
|
28
|
-
const imageTags = line.matchAll(ImageRegex);
|
|
29
|
-
|
|
30
|
-
for (const imageTag of imageTags) {
|
|
31
|
-
const imageTagIndex = imageTag.indices[0][0];
|
|
32
|
-
|
|
33
|
-
const emptyAltMatches = [
|
|
34
|
-
...imageTag[0].matchAll(htmlEmptyAltRegex)
|
|
35
|
-
][0];
|
|
36
|
-
if (emptyAltMatches) {
|
|
37
|
-
const matchingContent = emptyAltMatches[0];
|
|
38
|
-
const startIndex = emptyAltMatches.indices[0][0];
|
|
39
|
-
onError({
|
|
40
|
-
lineNumber: lineNumber + i,
|
|
41
|
-
range: [imageTagIndex + startIndex + 1, matchingContent.length]
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
function stripAndDowncaseText(text) {
|
|
2
|
-
return text
|
|
3
|
-
.toLowerCase()
|
|
4
|
-
.replace(/[.,/#!$%^&*;:{}=\-_`~()]/g, "")
|
|
5
|
-
.replace(/\s+/g, " ")
|
|
6
|
-
.trim();
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const bannedLinkText = [
|
|
10
|
-
"read more",
|
|
11
|
-
"learn more",
|
|
12
|
-
"more",
|
|
13
|
-
"here",
|
|
14
|
-
"click here",
|
|
15
|
-
"link"
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
names: ["SS002", "no-generic-link-text"],
|
|
20
|
-
description:
|
|
21
|
-
"Avoid using generic link text like `Learn more` or `Click here`",
|
|
22
|
-
information: new URL(
|
|
23
|
-
"https://github.com/github/markdownlint-github/blob/main/docs/rules/GH002-no-generic-link-text.md"
|
|
24
|
-
),
|
|
25
|
-
tags: ["accessibility", "links"],
|
|
26
|
-
function: function SS002(params, onError) {
|
|
27
|
-
// markdown syntax
|
|
28
|
-
let bannedLinkTexts = bannedLinkText.concat(
|
|
29
|
-
params.config.additional_banned_texts || []
|
|
30
|
-
);
|
|
31
|
-
const exceptions = params.config.exceptions || [];
|
|
32
|
-
if (exceptions.length > 0) {
|
|
33
|
-
bannedLinkTexts = bannedLinkTexts.filter(
|
|
34
|
-
text => !exceptions.includes(text)
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
const inlineTokens = params.tokens.filter(t => t.type === "inline");
|
|
38
|
-
for (const token of inlineTokens) {
|
|
39
|
-
const { children } = token;
|
|
40
|
-
let inLink = false;
|
|
41
|
-
let linkText = "";
|
|
42
|
-
|
|
43
|
-
for (const child of children) {
|
|
44
|
-
const { content, type } = child;
|
|
45
|
-
if (type === "link_open") {
|
|
46
|
-
inLink = true;
|
|
47
|
-
linkText = "";
|
|
48
|
-
} else if (type === "link_close") {
|
|
49
|
-
inLink = false;
|
|
50
|
-
if (bannedLinkTexts.includes(stripAndDowncaseText(linkText))) {
|
|
51
|
-
onError({
|
|
52
|
-
lineNumber: child.lineNumber,
|
|
53
|
-
detail: `For link: ${linkText}`
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
} else if (inLink) {
|
|
57
|
-
linkText += content;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"no-alt-text": true,
|
|
3
|
-
"no-default-alt-text": true,
|
|
4
|
-
"no-duplicate-header": true,
|
|
5
|
-
"no-emphasis-as-header": 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
|
-
}
|
package/src/style/base.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"default": true,
|
|
3
|
-
"no-inline-html": false,
|
|
4
|
-
"no-bare-urls": false,
|
|
5
|
-
"no-alt-text": true,
|
|
6
|
-
"no-blanks-blockquote": false,
|
|
7
|
-
"fenced-code-language": true,
|
|
8
|
-
"heading-increment": true,
|
|
9
|
-
"single-h1": true,
|
|
10
|
-
"no-emphasis-as-header": true,
|
|
11
|
-
"first-line-heading": false
|
|
12
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"resolveJsonModule": true,
|
|
6
|
-
"noEmit": true
|
|
7
|
-
},
|
|
8
|
-
"files": [],
|
|
9
|
-
"include": ["src/**/*.ts", "src/**/*.js", "bin/**/*"],
|
|
10
|
-
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
11
|
-
}
|
package/tsconfig.spec.json
DELETED