eslint-markdown 0.7.0 → 0.8.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.
@@ -13,7 +13,7 @@ declare const _default: {
13
13
  'no-curly-quote': import("../core/types.js").RuleModule<import("./no-curly-quote.js").RuleOptions, "noCurlyQuote">;
14
14
  'no-double-punctuation': import("../core/types.js").RuleModule<import("./no-double-punctuation.js").RuleOptions, "noDoublePunctuation">;
15
15
  'no-double-space': import("../core/types.js").RuleModule<import("./no-double-space.js").RuleOptions, import("./no-double-space.js").MessageIds>;
16
- 'no-emoji': import("../core/types.js").RuleModule<[], "noEmoji">;
16
+ 'no-emoji': import("../core/types.js").RuleModule<import("./no-emoji.js").RuleOptions, "noEmoji">;
17
17
  'no-git-conflict-marker': import("../core/types.js").RuleModule<import("./no-git-conflict-marker.js").RuleOptions, "noGitConflictMarker">;
18
18
  'no-irregular-dash': import("../core/types.js").RuleModule<import("./no-irregular-dash.js").RuleOptions, "noIrregularDash">;
19
19
  'no-irregular-whitespace': import("../core/types.js").RuleModule<import("./no-irregular-whitespace.js").RuleOptions, "noIrregularWhitespace">;
@@ -7,6 +7,22 @@ declare const _default: {
7
7
  recommended: boolean;
8
8
  stylistic: false;
9
9
  };
10
+ schema: {
11
+ type: "object";
12
+ properties: {
13
+ allow: {
14
+ type: "array";
15
+ items: {
16
+ type: "string";
17
+ };
18
+ uniqueItems: true;
19
+ };
20
+ };
21
+ additionalProperties: false;
22
+ }[];
23
+ defaultOptions: [{
24
+ allow: never[];
25
+ }];
10
26
  messages: {
11
27
  noEmoji: string;
12
28
  };
@@ -16,7 +32,7 @@ declare const _default: {
16
32
  create(context: import("@eslint/core").RuleContext<{
17
33
  LangOptions: import("@eslint/markdown").MarkdownLanguageOptions;
18
34
  Code: import("@eslint/markdown").MarkdownSourceCode;
19
- RuleOptions: [];
35
+ RuleOptions: RuleOptions;
20
36
  Node: import("mdast").Node;
21
37
  MessageIds: "noEmoji";
22
38
  }>): {
@@ -24,5 +40,7 @@ declare const _default: {
24
40
  };
25
41
  };
26
42
  export default _default;
27
- export type RuleOptions = [];
43
+ export type RuleOptions = [{
44
+ allow: string[];
45
+ }];
28
46
  export type MessageIds = "noEmoji";
@@ -7,6 +7,7 @@ declare const _default: {
7
7
  recommended: boolean;
8
8
  stylistic: false;
9
9
  };
10
+ fixable: "code";
10
11
  schema: {
11
12
  type: "object";
12
13
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-markdown",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "Lint your Markdown with ESLint.🛠️",
6
6
  "exports": {
@@ -15,7 +15,7 @@ import { URL_RULE_DOCS } from '../core/constants.js';
15
15
 
16
16
  /**
17
17
  * @import { RuleModule } from '../core/types.js';
18
- * @typedef {[]} RuleOptions
18
+ * @typedef {[{ allow: string[] }]} RuleOptions
19
19
  * @typedef {'noEmoji'} MessageIds
20
20
  */
21
21
 
@@ -41,6 +41,28 @@ export default {
41
41
  stylistic: false,
42
42
  },
43
43
 
44
+ schema: [
45
+ {
46
+ type: 'object',
47
+ properties: {
48
+ allow: {
49
+ type: 'array',
50
+ items: {
51
+ type: 'string',
52
+ },
53
+ uniqueItems: true,
54
+ },
55
+ },
56
+ additionalProperties: false,
57
+ },
58
+ ],
59
+
60
+ defaultOptions: [
61
+ {
62
+ allow: [],
63
+ },
64
+ ],
65
+
44
66
  messages: {
45
67
  noEmoji: 'Emojis are not allowed.',
46
68
  },
@@ -52,6 +74,7 @@ export default {
52
74
 
53
75
  create(context) {
54
76
  const { sourceCode } = context;
77
+ const [{ allow }] = context.options;
55
78
 
56
79
  return {
57
80
  text(node) {
@@ -59,8 +82,12 @@ export default {
59
82
  const matches = sourceCode.getText(node).matchAll(emojiRegex);
60
83
 
61
84
  for (const match of matches) {
85
+ const emoji = match[0];
86
+
87
+ if (allow.includes(emoji)) continue;
88
+
62
89
  const startOffset = nodeStartOffset + match.index;
63
- const endOffset = startOffset + match[0].length;
90
+ const endOffset = startOffset + emoji.length;
64
91
 
65
92
  context.report({
66
93
  loc: {
@@ -24,7 +24,8 @@ import { URL_RULE_DOCS } from '../core/constants.js';
24
24
  // Helper
25
25
  // --------------------------------------------------------------------------------
26
26
 
27
- const gitConflictMarkerRegex = /(?:^|(?<=[\r\n]))(?:<{7}(?!<)|={7}(?!=)|>{7}(?!>))/gu;
27
+ const gitConflictMarkerRegex =
28
+ /(?:^|(?<=[\r\n]))(?<gitConflictMarker><{7}(?!<)|={7}(?!=)|>{7}(?!>))[^\r\n]*\r?\n?/gu;
28
29
 
29
30
  // --------------------------------------------------------------------------------
30
31
  // Rule Definition
@@ -42,6 +43,8 @@ export default {
42
43
  stylistic: false,
43
44
  },
44
45
 
46
+ fixable: 'code',
47
+
45
48
  schema: [
46
49
  {
47
50
  type: 'object',
@@ -99,7 +102,7 @@ export default {
99
102
  const matches = sourceCode.text.matchAll(gitConflictMarkerRegex);
100
103
 
101
104
  for (const match of matches) {
102
- const gitConflictMarker = match[0];
105
+ const gitConflictMarker = match[1];
103
106
 
104
107
  const startOffset = match.index;
105
108
  const endOffset = startOffset + gitConflictMarker.length;
@@ -117,6 +120,11 @@ export default {
117
120
  },
118
121
 
119
122
  messageId: 'noGitConflictMarker',
123
+
124
+ fix(fixer) {
125
+ // Remove the entire line containing the git conflict marker, including the newline character.
126
+ return fixer.removeRange([startOffset, startOffset + match[0].length]);
127
+ },
120
128
  });
121
129
  }
122
130
  },