@yegor256/dogent 0.7.0 → 0.7.1

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.0",
43
+ "version": "0.7.1",
44
44
  "dependencies": {
45
45
  "minimist": "^1.2.8"
46
46
  }
@@ -38,8 +38,9 @@ class Polite {
38
38
  }
39
39
  scan(text, line, uri) {
40
40
  const found = [];
41
+ const masked = this.mask(text);
41
42
  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;
42
- let hit = regex.exec(text);
43
+ let hit = regex.exec(masked);
43
44
  while (hit !== null) {
44
45
  found.push(new Violation(
45
46
  this.id,
@@ -47,10 +48,13 @@ class Polite {
47
48
  `courtesy phrase "${hit[0]}" must be removed`,
48
49
  new Region(uri, line, hit.index + 1)
49
50
  ));
50
- hit = regex.exec(text);
51
+ hit = regex.exec(masked);
51
52
  }
52
53
  return found;
53
54
  }
55
+ mask(text) {
56
+ return text.replace(/`[^`]*`/gu, (span) => ' '.repeat(span.length));
57
+ }
54
58
  }
55
59
 
56
60
  module.exports = Polite;