@electron/lint-roller 2.0.0 → 2.2.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.
@@ -26,6 +26,7 @@
26
26
  "no-inline-html": false,
27
27
  "no-angle-brackets": false,
28
28
  "no-curly-braces": false,
29
+ "no-newline-in-links": false,
29
30
  "link-image-style": {
30
31
  "shortcut": false
31
32
  }
@@ -7,7 +7,7 @@ if (require.main === module) {
7
7
  const { status } = cp.spawnSync(process.execPath, [
8
8
  require.resolve('markdownlint-cli'),
9
9
  '-r',
10
- path.resolve(__dirname, '../../markdownlint-rules'),
10
+ path.resolve(__dirname, '../../markdownlint-rules/index.js'),
11
11
  ...process.argv.slice(2),
12
12
  ], { stdio: 'inherit' });
13
13
  if (status)
@@ -1 +1 @@
1
- {"version":3,"file":"markdownlint-cli-wrapper.js","sourceRoot":"","sources":["../../bin/markdownlint-cli-wrapper.ts"],"names":[],"mappings":";;;AAEA,yCAAyC;AACzC,kCAAkC;AAElC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS,CAC7B,OAAO,CAAC,QAAQ,EAChB;QACE,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC;QACnC,IAAI;QACJ,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,0BAA0B,CAAC;QACnD,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KACzB,EACD,EAAE,KAAK,EAAE,SAAS,EAAE,CACrB,CAAC;IACF,IAAI,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC"}
1
+ {"version":3,"file":"markdownlint-cli-wrapper.js","sourceRoot":"","sources":["../../bin/markdownlint-cli-wrapper.ts"],"names":[],"mappings":";;;AAEA,yCAAyC;AACzC,kCAAkC;AAElC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS,CAC7B,OAAO,CAAC,QAAQ,EAChB;QACE,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC;QACnC,IAAI;QACJ,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,mCAAmC,CAAC;QAC5D,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KACzB,EACD,EAAE,KAAK,EAAE,SAAS,EAAE,CACrB,CAAC;IACF,IAAI,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC"}
@@ -9874,9 +9874,19 @@ function EMD002(params, onError) {
9874
9874
  tree,
9875
9875
  (node2) => node2.type === "text",
9876
9876
  (node2) => {
9877
- const rawContent = childToken.line.slice(node2.position.start.offset, node2.position.end.offset);
9878
- if (rawContent.match(UNESCAPED_REGEX) !== null) {
9879
- (0, import_helpers.addError)(onError, token.lineNumber, "Unescaped opening angle bracket");
9877
+ const rawContent = childToken.line.slice(
9878
+ node2.position.start.offset,
9879
+ node2.position.end.offset
9880
+ );
9881
+ const matches = rawContent.matchAll(UNESCAPED_REGEX);
9882
+ for (const match of matches) {
9883
+ (0, import_helpers.addError)(
9884
+ onError,
9885
+ childToken.lineNumber,
9886
+ "Unescaped opening angle bracket",
9887
+ void 0,
9888
+ [node2.position.start.offset + 1 + match.index, 1]
9889
+ );
9880
9890
  }
9881
9891
  }
9882
9892
  );
@@ -4,7 +4,8 @@ import { fromMarkdown } from 'mdast-util-from-markdown';
4
4
  import { visit } from 'unist-util-visit';
5
5
 
6
6
  export const names = ['EMD002', 'no-angle-brackets'];
7
- export const description = 'No unescaped opening angle brackets in text (does not play nice with MDX)';
7
+ export const description =
8
+ 'No unescaped opening angle brackets in text (does not play nice with MDX)';
8
9
  export const tags = ['brackets'];
9
10
 
10
11
  const UNESCAPED_REGEX = /(?<!\\)<(?!\s)/g;
@@ -32,16 +33,27 @@ function EMD002(params, onError) {
32
33
  tree,
33
34
  (node) => node.type === 'text',
34
35
  (node) => {
35
- const rawContent = childToken.line.slice(node.position.start.offset, node.position.end.offset);
36
+ const rawContent = childToken.line.slice(
37
+ node.position.start.offset,
38
+ node.position.end.offset,
39
+ );
36
40
 
37
- if (rawContent.match(UNESCAPED_REGEX) !== null) {
38
- addError(onError, token.lineNumber, 'Unescaped opening angle bracket');
41
+ const matches = rawContent.matchAll(UNESCAPED_REGEX);
42
+
43
+ for (const match of matches) {
44
+ addError(
45
+ onError,
46
+ childToken.lineNumber,
47
+ 'Unescaped opening angle bracket',
48
+ undefined,
49
+ [node.position.start.offset + 1 + match.index, 1],
50
+ );
39
51
  }
40
52
  },
41
53
  );
42
54
  }
43
55
  }
44
56
  });
45
- };
57
+ }
46
58
 
47
59
  export { EMD002 as function };
@@ -9874,9 +9874,16 @@ function EMD003(params, onError) {
9874
9874
  tree,
9875
9875
  (node2) => node2.type === "text",
9876
9876
  (node2) => {
9877
- const rawContent = childToken.line.slice(node2.position.start.offset, node2.position.end.offset);
9878
- if (rawContent.match(UNESCAPED_REGEX) !== null) {
9879
- (0, import_helpers.addError)(onError, token.lineNumber, "Unescaped opening curly brace");
9877
+ const rawContent = childToken.line.slice(
9878
+ node2.position.start.offset,
9879
+ node2.position.end.offset
9880
+ );
9881
+ const matches = rawContent.matchAll(UNESCAPED_REGEX);
9882
+ for (const match of matches) {
9883
+ (0, import_helpers.addError)(onError, childToken.lineNumber, "Unescaped opening curly brace", void 0, [
9884
+ node2.position.start.offset + 1 + match.index,
9885
+ 1
9886
+ ]);
9880
9887
  }
9881
9888
  }
9882
9889
  );
@@ -4,7 +4,8 @@ import { fromMarkdown } from 'mdast-util-from-markdown';
4
4
  import { visit } from 'unist-util-visit';
5
5
 
6
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)';
7
+ export const description =
8
+ 'No unescaped opening curly braces in text (does not play nice with MDX)';
8
9
  export const tags = ['braces'];
9
10
 
10
11
  const UNESCAPED_REGEX = /(?<!\\){/g;
@@ -31,16 +32,24 @@ function EMD003(params, onError) {
31
32
  tree,
32
33
  (node) => node.type === 'text',
33
34
  (node) => {
34
- const rawContent = childToken.line.slice(node.position.start.offset, node.position.end.offset);
35
+ const rawContent = childToken.line.slice(
36
+ node.position.start.offset,
37
+ node.position.end.offset,
38
+ );
35
39
 
36
- if (rawContent.match(UNESCAPED_REGEX) !== null) {
37
- addError(onError, token.lineNumber, 'Unescaped opening curly brace');
40
+ const matches = rawContent.matchAll(UNESCAPED_REGEX);
41
+
42
+ for (const match of matches) {
43
+ addError(onError, childToken.lineNumber, 'Unescaped opening curly brace', undefined, [
44
+ node.position.start.offset + 1 + match.index,
45
+ 1,
46
+ ]);
38
47
  }
39
48
  },
40
49
  );
41
50
  }
42
51
  }
43
52
  });
44
- };
53
+ }
45
54
 
46
55
  export { EMD003 as function };
@@ -0,0 +1,30 @@
1
+ const { addError, filterTokens } = require('markdownlint/helpers');
2
+
3
+ module.exports = {
4
+ names: ['EMD004', 'no-newline-in-links'],
5
+ description: 'Newlines inside link text',
6
+ tags: ['newline', 'links'],
7
+ parser: 'markdownit',
8
+ function: function EMD004(params, onError) {
9
+ filterTokens(params, 'inline', (token) => {
10
+ const { children } = token;
11
+ let { lineNumber } = token;
12
+ let inLink = false;
13
+ for (const child of children) {
14
+ const { type } = child;
15
+ if (type === 'link_open') {
16
+ inLink = true;
17
+ } else if (type === 'link_close') {
18
+ inLink = false;
19
+ } else if (type === 'softbreak') {
20
+ if (inLink) {
21
+ addError(onError, lineNumber);
22
+ break;
23
+ } else {
24
+ lineNumber++;
25
+ }
26
+ }
27
+ }
28
+ });
29
+ },
30
+ };
@@ -0,0 +1,5 @@
1
+ const EMD002 = require('./emd002.js');
2
+ const EMD003 = require('./emd003.js');
3
+ const EMD004 = require('./emd004.js');
4
+
5
+ module.exports = [EMD002, EMD003, EMD004];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electron/lint-roller",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Markdown linting helpers for Electron org repos",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -25,14 +25,14 @@
25
25
  "build:emd002": "esbuild --platform=node --target=node18 --format=cjs --bundle --outfile=markdownlint-rules/emd002.js markdownlint-rules/emd002.mjs",
26
26
  "build:emd003": "esbuild --platform=node --target=node18 --format=cjs --bundle --outfile=markdownlint-rules/emd003.js markdownlint-rules/emd003.mjs",
27
27
  "prepublishOnly": "yarn run build",
28
- "lint:eslint": "eslint \"{bin,lib,markdownlint-rules,tests}/**/*.{js,ts}\"",
29
- "lint:eslint:fix": "eslint --fix \"{bin,lib,markdownlint-rules,tests}/**/*.{js,ts}\"",
28
+ "lint:eslint": "eslint \"{bin,lib,markdownlint-rules,tests}/**/*.{js,mjs,ts}\"",
29
+ "lint:eslint:fix": "eslint --fix \"{bin,lib,markdownlint-rules,tests}/**/*.{js,mjs,ts}\"",
30
30
  "lint:markdown": "yarn run build && node ./dist/bin/markdownlint-cli-wrapper.js \"*.md\" && node ./dist/bin/lint-markdown-links.js \"*.md\"",
31
- "lint:prettier": "prettier --check \"{bin,lib,markdownlint-rules,tests}/**/*.{js,ts}\"",
32
- "lint:prettier:fix": "prettier --write \"{bin,lib,markdownlint-rules,tests}/**/*.{js,ts}\"",
31
+ "lint:prettier": "prettier --check \"{bin,lib,markdownlint-rules,tests}/**/*.{js,mjs,ts}\"",
32
+ "lint:prettier:fix": "prettier --write \"{bin,lib,markdownlint-rules,tests}/**/*.{js,mjs,ts}\"",
33
33
  "lint": "yarn run lint:prettier && yarn run lint:markdown",
34
34
  "lint:fix": "yarn run lint:eslint:fix && yarn run lint:prettier:fix",
35
- "test": "yarn run build && jest"
35
+ "test": "yarn run build && vitest run --reporter=verbose"
36
36
  },
37
37
  "repository": {
38
38
  "type": "git",
@@ -48,7 +48,6 @@
48
48
  "@electron-internal/eslint-config": "^1.0.1",
49
49
  "@types/balanced-match": "^1.0.3",
50
50
  "@types/glob": "^8.1.0",
51
- "@types/jest": "^29.5.8",
52
51
  "@types/markdown-it": "^13.0.6",
53
52
  "@types/minimist": "^1.2.5",
54
53
  "@types/node": "20.1.2",
@@ -56,10 +55,9 @@
56
55
  "eslint": "^8.54.0",
57
56
  "eslint-config-prettier": "^9.1.0",
58
57
  "eslint-plugin-node": "^11.1.0",
59
- "jest": "^29.7.0",
60
58
  "prettier": "^3.2.5",
61
- "ts-jest": "^29.1.1",
62
- "typescript": "^5.4.5"
59
+ "typescript": "^5.4.5",
60
+ "vitest": "^1.5.3"
63
61
  },
64
62
  "dependencies": {
65
63
  "@dsanders11/vscode-markdown-languageservice": "^0.3.0",