@electron/lint-roller 1.12.1 → 2.0.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.
@@ -0,0 +1,46 @@
1
+ import { addError, filterTokens } from 'markdownlint/helpers';
2
+
3
+ import { fromMarkdown } from 'mdast-util-from-markdown';
4
+ import { visit } from 'unist-util-visit';
5
+
6
+ export const names = ['EMD003', 'no-curly-braces'];
7
+ export const description = 'No unescaped opening curly braces in text (does not play nice with MDX)';
8
+ export const tags = ['braces'];
9
+
10
+ const UNESCAPED_REGEX = /(?<!\\){/g;
11
+
12
+ function EMD003(params, onError) {
13
+ filterTokens(params, 'inline', (token) => {
14
+ for (const childToken of token.children) {
15
+ // childToken.line has the raw content, but may also contain
16
+ // more content than just childToken.content. Since we need
17
+ // the raw content to detect escaped curly braces, parse
18
+ // the raw content of any match a second time to avoid any
19
+ // false positives.
20
+ if (
21
+ childToken.type === 'text' &&
22
+ childToken.markup !== '&#123;' &&
23
+ childToken.content.includes('{') &&
24
+ childToken.line.match(UNESCAPED_REGEX) !== null
25
+ ) {
26
+ // The AST produced by mdast is easier to work with here
27
+ // since it gives position data within the line
28
+ const tree = fromMarkdown(childToken.line);
29
+
30
+ visit(
31
+ tree,
32
+ (node) => node.type === 'text',
33
+ (node) => {
34
+ const rawContent = childToken.line.slice(node.position.start.offset, node.position.end.offset);
35
+
36
+ if (rawContent.match(UNESCAPED_REGEX) !== null) {
37
+ addError(onError, token.lineNumber, 'Unescaped opening curly brace');
38
+ }
39
+ },
40
+ );
41
+ }
42
+ }
43
+ });
44
+ };
45
+
46
+ export { EMD003 as function };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@electron/lint-roller",
3
- "version": "1.12.1",
3
+ "version": "2.0.0",
4
4
  "description": "Markdown linting helpers for Electron org repos",
5
5
  "engines": {
6
- "node": ">=14.0.0"
6
+ "node": ">=18.0.0"
7
7
  },
8
8
  "bin": {
9
9
  "electron-markdownlint": "./dist/bin/markdownlint-cli-wrapper.js",
10
- "electron-lint-markdown-links": "./dist/bin/lint-markdown-links.js",
11
- "electron-lint-markdown-standard": "./dist/bin/lint-markdown-standard.js",
12
- "electron-lint-markdown-ts-check": "./dist/bin/lint-markdown-ts-check.js"
10
+ "lint-roller-markdown-links": "./dist/bin/lint-markdown-links.js",
11
+ "lint-roller-markdown-standard": "./dist/bin/lint-markdown-standard.js",
12
+ "lint-roller-markdown-ts-check": "./dist/bin/lint-markdown-ts-check.js"
13
13
  },
14
14
  "files": [
15
15
  "configs",
@@ -21,7 +21,9 @@
21
21
  "lib": "lib"
22
22
  },
23
23
  "scripts": {
24
- "build": "tsc && esbuild --platform=node --target=node14 --format=cjs --bundle --outfile=markdownlint-rules/emd002.js markdownlint-rules/emd002.mjs",
24
+ "build": "tsc && yarn run build:emd002 && yarn run build:emd003",
25
+ "build:emd002": "esbuild --platform=node --target=node18 --format=cjs --bundle --outfile=markdownlint-rules/emd002.js markdownlint-rules/emd002.mjs",
26
+ "build:emd003": "esbuild --platform=node --target=node18 --format=cjs --bundle --outfile=markdownlint-rules/emd003.js markdownlint-rules/emd003.mjs",
25
27
  "prepublishOnly": "yarn run build",
26
28
  "lint:eslint": "eslint \"{bin,lib,markdownlint-rules,tests}/**/*.{js,ts}\"",
27
29
  "lint:eslint:fix": "eslint --fix \"{bin,lib,markdownlint-rules,tests}/**/*.{js,ts}\"",
@@ -50,25 +52,23 @@
50
52
  "@types/markdown-it": "^13.0.6",
51
53
  "@types/minimist": "^1.2.5",
52
54
  "@types/node": "20.1.2",
53
- "@types/node-fetch": "^2.6.9",
54
- "esbuild": "^0.20.1",
55
+ "esbuild": "^0.21.0",
55
56
  "eslint": "^8.54.0",
56
- "eslint-config-prettier": "^9.0.0",
57
+ "eslint-config-prettier": "^9.1.0",
57
58
  "eslint-plugin-node": "^11.1.0",
58
59
  "jest": "^29.7.0",
59
- "prettier": "^3.1.0",
60
+ "prettier": "^3.2.5",
60
61
  "ts-jest": "^29.1.1",
61
- "typescript": "^5.2.2"
62
+ "typescript": "^5.4.5"
62
63
  },
63
64
  "dependencies": {
64
65
  "@dsanders11/vscode-markdown-languageservice": "^0.3.0",
65
66
  "balanced-match": "^2.0.0",
66
67
  "glob": "^8.1.0",
67
68
  "markdown-it": "^13.0.1",
68
- "markdownlint-cli": "^0.33.0",
69
+ "markdownlint-cli": "^0.40.0",
69
70
  "mdast-util-from-markdown": "^1.3.0",
70
71
  "minimist": "^1.2.8",
71
- "node-fetch": "^2.6.9",
72
72
  "rimraf": "^4.4.1",
73
73
  "standard": "^17.0.0",
74
74
  "unist-util-visit": "^4.1.2",
@@ -83,5 +83,8 @@
83
83
  "typescript": {
84
84
  "optional": true
85
85
  }
86
+ },
87
+ "resolutions": {
88
+ "jackspeak": "2.1.1"
86
89
  }
87
90
  }
@@ -1,26 +0,0 @@
1
- const { addError, getLineMetadata, getReferenceLinkImageData } = require('markdownlint/helpers');
2
-
3
- // These are used by GitHub's "alert" extension to Markdown
4
- // https://github.com/orgs/community/discussions/16925
5
- const ALERT_KEYWORDS = ['!note', '!tip', '!important', '!warning', '!caution'];
6
-
7
- module.exports = {
8
- names: ['EMD001', 'no-shortcut-reference-links'],
9
- description: 'Disallow shortcut reference links (those with no link label)',
10
- tags: ['images', 'links'],
11
- function: function EMD001(params, onError) {
12
- const lineMetadata = getLineMetadata(params);
13
- const { shortcuts } = getReferenceLinkImageData(lineMetadata);
14
- for (const [shortcut, occurrences] of shortcuts) {
15
- for (const [lineNumber] of occurrences) {
16
- if (!ALERT_KEYWORDS.includes(shortcut)) {
17
- addError(
18
- onError,
19
- lineNumber + 1, // human-friendly line numbers (1-based)
20
- `Disallowed shortcut reference link: "${shortcut}"`,
21
- );
22
- }
23
- }
24
- }
25
- },
26
- };