@yegor256/dogent 0.7.5 → 0.7.7

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/package.json CHANGED
@@ -40,7 +40,7 @@
40
40
  "lint": "eslint .",
41
41
  "test": "mocha 'test/**/*.js' --timeout 60000"
42
42
  },
43
- "version": "0.7.5",
43
+ "version": "0.7.7",
44
44
  "dependencies": {
45
45
  "minimist": "^1.2.8"
46
46
  }
package/src/mask.js ADDED
@@ -0,0 +1,18 @@
1
+ /*
2
+ * SPDX-FileCopyrightText: Copyright (c) 2026 Yegor Bugayenko
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ /**
9
+ * Mask.
10
+ *
11
+ * Blanks out inline-code spans inside a prose line so word-scanning
12
+ * rules never match quoted examples or filename templates. Each
13
+ * backtick run becomes equal-length spaces, keeping every column
14
+ * offset intact for the violations that survive.
15
+ */
16
+ const mask = (text) => text.replace(/`[^`]*`/gu, (span) => ' '.repeat(span.length));
17
+
18
+ module.exports = mask;
@@ -39,6 +39,7 @@ class Atomic {
39
39
  const clean = text.replace(/^\s*(?:[-*+]|\d+\.)\s+/u, '').trimEnd();
40
40
  const weld = /(?<!,)\s(?:and|then)\s+(?<verb>[a-z]+)\s+\S/u.exec(clean);
41
41
  const welded = weld !== null &&
42
+ !/^(?:the|a|an)$/u.test(weld.groups.verb) &&
42
43
  !/(?:ly|al|ial|ous|ive|less|ic|ary|ory|able|ible|ate)$/u.test(weld.groups.verb);
43
44
  if (!/[.!?]\s+\S/u.test(clean) && !/;/u.test(clean) && !welded) {
44
45
  return [];
@@ -7,6 +7,7 @@
7
7
 
8
8
  const Violation = require('../violation');
9
9
  const Region = require('../region');
10
+ const mask = require('../mask');
10
11
 
11
12
  /**
12
13
  * Hedging.
@@ -41,7 +42,8 @@ class Hedging {
41
42
  'when necessary|usually|generally|etc|just|simply|very)\\b',
42
43
  'giu'
43
44
  );
44
- let hit = regex.exec(text);
45
+ const masked = mask(text);
46
+ let hit = regex.exec(masked);
45
47
  while (hit !== null) {
46
48
  found.push(new Violation(
47
49
  this.id,
@@ -49,7 +51,7 @@ class Hedging {
49
51
  `hedge word "${hit[0]}" must be removed`,
50
52
  new Region(uri, line, hit.index + 1)
51
53
  ));
52
- hit = regex.exec(text);
54
+ hit = regex.exec(masked);
53
55
  }
54
56
  return found;
55
57
  }
@@ -7,6 +7,7 @@
7
7
 
8
8
  const Violation = require('../violation');
9
9
  const Region = require('../region');
10
+ const mask = require('../mask');
10
11
 
11
12
  /**
12
13
  * NoArticles.
@@ -33,8 +34,9 @@ class NoArticles {
33
34
  }
34
35
  scan(text, line, uri) {
35
36
  const found = [];
37
+ const masked = mask(text);
36
38
  const regex = /\b(?:a|an|the)\b/giu;
37
- let hit = regex.exec(text);
39
+ let hit = regex.exec(masked);
38
40
  while (hit !== null) {
39
41
  found.push(new Violation(
40
42
  this.id,
@@ -42,7 +44,7 @@ class NoArticles {
42
44
  `article "${hit[0]}" must be removed`,
43
45
  new Region(uri, line, hit.index + 1)
44
46
  ));
45
- hit = regex.exec(text);
47
+ hit = regex.exec(masked);
46
48
  }
47
49
  return found;
48
50
  }
@@ -7,6 +7,7 @@
7
7
 
8
8
  const Violation = require('../violation');
9
9
  const Region = require('../region');
10
+ const mask = require('../mask');
10
11
 
11
12
  /**
12
13
  * Polite.
@@ -38,7 +39,7 @@ class Polite {
38
39
  }
39
40
  scan(text, line, uri) {
40
41
  const found = [];
41
- const masked = this.mask(text);
42
+ const masked = mask(text);
42
43
  const regex = /\b(?:please|kindly|feel free to|make sure to|be sure to|don't forget to|remember to|note that|it is important to)\b/giu;
43
44
  let hit = regex.exec(masked);
44
45
  while (hit !== null) {
@@ -52,9 +53,6 @@ class Polite {
52
53
  }
53
54
  return found;
54
55
  }
55
- mask(text) {
56
- return text.replace(/`[^`]*`/gu, (span) => ' '.repeat(span.length));
57
- }
58
56
  }
59
57
 
60
58
  module.exports = Polite;
@@ -7,6 +7,7 @@
7
7
 
8
8
  const Violation = require('../violation');
9
9
  const Region = require('../region');
10
+ const mask = require('../mask');
10
11
 
11
12
  /**
12
13
  * Unfinished.
@@ -44,7 +45,8 @@ class Unfinished {
44
45
  /\.\.\.\s*$/u,
45
46
  /<[^>\n]*>/u
46
47
  ];
47
- if (!markers.some((marker) => marker.test(text))) {
48
+ const masked = mask(text);
49
+ if (!markers.some((marker) => marker.test(masked))) {
48
50
  return [];
49
51
  }
50
52
  return [new Violation(