eslint-plugin-markdown-preferences 0.1.1 → 0.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.
package/README.md CHANGED
@@ -91,6 +91,7 @@ The rules with the following star ⭐ are included in the configs.
91
91
  | Rule ID | Description | Fixable | RECOMMENDED |
92
92
  |:--------|:------------|:-------:|:-----------:|
93
93
  | [markdown-preferences/hard-linebreak-style](https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/hard-linebreak-style.html) | enforce consistent hard linebreak style. | 🔧 | ⭐ |
94
+ | [markdown-preferences/no-text-backslash-linebreak](https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/no-text-backslash-linebreak.html) | disallow text backslash at the end of a line. | | ⭐ |
94
95
  | [markdown-preferences/prefer-linked-words](https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/prefer-linked-words.html) | enforce the specified word to be a link. | 🔧 | |
95
96
 
96
97
  <!--RULES_TABLE_END-->
package/lib/index.d.ts CHANGED
@@ -19,7 +19,7 @@ declare namespace meta_d_exports {
19
19
  export { name, version };
20
20
  }
21
21
  declare const name: "eslint-plugin-markdown-preferences";
22
- declare const version: "0.1.1";
22
+ declare const version: "0.2.0";
23
23
  //#endregion
24
24
  //#region src/index.d.ts
25
25
  declare const configs: {
package/lib/index.js CHANGED
@@ -69,6 +69,61 @@ var hard_linebreak_style_default = createRule("hard-linebreak-style", {
69
69
  }
70
70
  });
71
71
 
72
+ //#endregion
73
+ //#region src/rules/no-text-backslash-linebreak.ts
74
+ var no_text_backslash_linebreak_default = createRule("no-text-backslash-linebreak", {
75
+ meta: {
76
+ type: "suggestion",
77
+ docs: {
78
+ description: "disallow text backslash at the end of a line.",
79
+ categories: ["recommended"]
80
+ },
81
+ fixable: void 0,
82
+ hasSuggestions: true,
83
+ schema: [],
84
+ messages: {
85
+ textBackslashWithLinebreak: "Text backslash at the end of a line is not allowed.",
86
+ removeBackslash: "Remove the backslash."
87
+ }
88
+ },
89
+ create(context) {
90
+ const sourceCode = context.sourceCode;
91
+ return { text(node) {
92
+ if (!node.value.endsWith("\\")) return;
93
+ const range = sourceCode.getRange(node);
94
+ for (let i = range[1]; i < sourceCode.text.length; i++) {
95
+ const c = sourceCode.text[i];
96
+ if (c.trim() !== "") return;
97
+ if (c === "\n") break;
98
+ }
99
+ const loc = sourceCode.getLoc(node);
100
+ const beforeLines = sourceCode.text.slice(range[0], range[1] - 1).split(/\n/u);
101
+ const line = loc.start.line + beforeLines.length - 1;
102
+ const column = (beforeLines.length === 1 ? loc.start.column : 1) + (beforeLines.at(-1) || "").length;
103
+ context.report({
104
+ node,
105
+ loc: {
106
+ start: {
107
+ line,
108
+ column
109
+ },
110
+ end: {
111
+ line,
112
+ column: column + 1
113
+ }
114
+ },
115
+ messageId: "textBackslashWithLinebreak",
116
+ suggest: [{
117
+ messageId: "removeBackslash",
118
+ fix: (fixer) => {
119
+ return fixer.removeRange([range[1] - 1, range[1]]);
120
+ }
121
+ }]
122
+ });
123
+ } };
124
+ }
125
+ });
126
+
72
127
  //#endregion
73
128
  //#region src/rules/prefer-linked-words.ts
74
129
  const RE_PUNCTUATOR = /^[\s,:]*$/u;
@@ -169,7 +224,11 @@ var prefer_linked_words_default = createRule("prefer-linked-words", {
169
224
 
170
225
  //#endregion
171
226
  //#region src/utils/rules.ts
172
- const rules$1 = [hard_linebreak_style_default, prefer_linked_words_default];
227
+ const rules$1 = [
228
+ hard_linebreak_style_default,
229
+ no_text_backslash_linebreak_default,
230
+ prefer_linked_words_default
231
+ ];
173
232
 
174
233
  //#endregion
175
234
  //#region src/configs/recommended.ts
@@ -190,7 +249,10 @@ const plugins = {
190
249
  return src_default;
191
250
  }
192
251
  };
193
- const rules$2 = { "markdown-preferences/hard-linebreak-style": "error" };
252
+ const rules$2 = {
253
+ "markdown-preferences/hard-linebreak-style": "error",
254
+ "markdown-preferences/no-text-backslash-linebreak": "error"
255
+ };
194
256
 
195
257
  //#endregion
196
258
  //#region src/meta.ts
@@ -200,7 +262,7 @@ __export(meta_exports, {
200
262
  version: () => version
201
263
  });
202
264
  const name = "eslint-plugin-markdown-preferences";
203
- const version = "0.1.1";
265
+ const version = "0.2.0";
204
266
 
205
267
  //#endregion
206
268
  //#region src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-markdown-preferences",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "ESLint plugin that enforces our markdown preferences",
5
5
  "type": "module",
6
6
  "exports": {