gurkencheck 0.0.4

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.
Files changed (259) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +327 -0
  3. package/dist/config-parser.d.ts +21 -0
  4. package/dist/config-parser.d.ts.map +1 -0
  5. package/dist/config-parser.js +171 -0
  6. package/dist/config-parser.js.map +1 -0
  7. package/dist/config-verifier.d.ts +4 -0
  8. package/dist/config-verifier.d.ts.map +1 -0
  9. package/dist/config-verifier.js +81 -0
  10. package/dist/config-verifier.js.map +1 -0
  11. package/dist/feature-finder.d.ts +18 -0
  12. package/dist/feature-finder.d.ts.map +1 -0
  13. package/dist/feature-finder.js +70 -0
  14. package/dist/feature-finder.js.map +1 -0
  15. package/dist/formatters/index.d.ts +23 -0
  16. package/dist/formatters/index.d.ts.map +1 -0
  17. package/dist/formatters/index.js +79 -0
  18. package/dist/formatters/index.js.map +1 -0
  19. package/dist/formatters/json.d.ts +31 -0
  20. package/dist/formatters/json.d.ts.map +1 -0
  21. package/dist/formatters/json.js +31 -0
  22. package/dist/formatters/json.js.map +1 -0
  23. package/dist/formatters/junit.d.ts +17 -0
  24. package/dist/formatters/junit.d.ts.map +1 -0
  25. package/dist/formatters/junit.js +61 -0
  26. package/dist/formatters/junit.js.map +1 -0
  27. package/dist/formatters/sarif.d.ts +6 -0
  28. package/dist/formatters/sarif.d.ts.map +1 -0
  29. package/dist/formatters/sarif.js +81 -0
  30. package/dist/formatters/sarif.js.map +1 -0
  31. package/dist/formatters/stylish.d.ts +9 -0
  32. package/dist/formatters/stylish.d.ts.map +1 -0
  33. package/dist/formatters/stylish.js +66 -0
  34. package/dist/formatters/stylish.js.map +1 -0
  35. package/dist/formatters/tap.d.ts +14 -0
  36. package/dist/formatters/tap.d.ts.map +1 -0
  37. package/dist/formatters/tap.js +45 -0
  38. package/dist/formatters/tap.js.map +1 -0
  39. package/dist/gherkin/dialects.d.ts +31 -0
  40. package/dist/gherkin/dialects.d.ts.map +1 -0
  41. package/dist/gherkin/dialects.js +40 -0
  42. package/dist/gherkin/dialects.js.map +1 -0
  43. package/dist/gherkin/keywords.d.ts +21 -0
  44. package/dist/gherkin/keywords.d.ts.map +1 -0
  45. package/dist/gherkin/keywords.js +53 -0
  46. package/dist/gherkin/keywords.js.map +1 -0
  47. package/dist/gherkin/parse.d.ts +32 -0
  48. package/dist/gherkin/parse.d.ts.map +1 -0
  49. package/dist/gherkin/parse.js +236 -0
  50. package/dist/gherkin/parse.js.map +1 -0
  51. package/dist/gherkin/traverse.d.ts +45 -0
  52. package/dist/gherkin/traverse.d.ts.map +1 -0
  53. package/dist/gherkin/traverse.js +89 -0
  54. package/dist/gherkin/traverse.js.map +1 -0
  55. package/dist/gherkin/variables.d.ts +26 -0
  56. package/dist/gherkin/variables.d.ts.map +1 -0
  57. package/dist/gherkin/variables.js +51 -0
  58. package/dist/gherkin/variables.js.map +1 -0
  59. package/dist/index.d.ts +39 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +31 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/linter.d.ts +23 -0
  64. package/dist/linter.d.ts.map +1 -0
  65. package/dist/linter.js +57 -0
  66. package/dist/linter.js.map +1 -0
  67. package/dist/logger.d.ts +16 -0
  68. package/dist/logger.d.ts.map +1 -0
  69. package/dist/logger.js +28 -0
  70. package/dist/logger.js.map +1 -0
  71. package/dist/main.d.ts +3 -0
  72. package/dist/main.d.ts.map +1 -0
  73. package/dist/main.js +144 -0
  74. package/dist/main.js.map +1 -0
  75. package/dist/presets.d.ts +19 -0
  76. package/dist/presets.d.ts.map +1 -0
  77. package/dist/presets.js +24 -0
  78. package/dist/presets.js.map +1 -0
  79. package/dist/rules/allowed-tags.d.ts +4 -0
  80. package/dist/rules/allowed-tags.d.ts.map +1 -0
  81. package/dist/rules/allowed-tags.js +34 -0
  82. package/dist/rules/allowed-tags.js.map +1 -0
  83. package/dist/rules/file-name.d.ts +4 -0
  84. package/dist/rules/file-name.d.ts.map +1 -0
  85. package/dist/rules/file-name.js +41 -0
  86. package/dist/rules/file-name.js.map +1 -0
  87. package/dist/rules/indentation.d.ts +4 -0
  88. package/dist/rules/indentation.d.ts.map +1 -0
  89. package/dist/rules/indentation.js +153 -0
  90. package/dist/rules/indentation.js.map +1 -0
  91. package/dist/rules/index.d.ts +13 -0
  92. package/dist/rules/index.d.ts.map +1 -0
  93. package/dist/rules/index.js +70 -0
  94. package/dist/rules/index.js.map +1 -0
  95. package/dist/rules/keywords-in-logical-order.d.ts +4 -0
  96. package/dist/rules/keywords-in-logical-order.d.ts.map +1 -0
  97. package/dist/rules/keywords-in-logical-order.js +37 -0
  98. package/dist/rules/keywords-in-logical-order.js.map +1 -0
  99. package/dist/rules/max-scenarios-per-file.d.ts +4 -0
  100. package/dist/rules/max-scenarios-per-file.d.ts.map +1 -0
  101. package/dist/rules/max-scenarios-per-file.js +42 -0
  102. package/dist/rules/max-scenarios-per-file.js.map +1 -0
  103. package/dist/rules/name-length.d.ts +4 -0
  104. package/dist/rules/name-length.d.ts.map +1 -0
  105. package/dist/rules/name-length.js +50 -0
  106. package/dist/rules/name-length.js.map +1 -0
  107. package/dist/rules/new-line-at-eof.d.ts +4 -0
  108. package/dist/rules/new-line-at-eof.d.ts.map +1 -0
  109. package/dist/rules/new-line-at-eof.js +30 -0
  110. package/dist/rules/new-line-at-eof.js.map +1 -0
  111. package/dist/rules/no-background-only-scenario.d.ts +4 -0
  112. package/dist/rules/no-background-only-scenario.d.ts.map +1 -0
  113. package/dist/rules/no-background-only-scenario.js +43 -0
  114. package/dist/rules/no-background-only-scenario.js.map +1 -0
  115. package/dist/rules/no-dupe-feature-names.d.ts +4 -0
  116. package/dist/rules/no-dupe-feature-names.d.ts.map +1 -0
  117. package/dist/rules/no-dupe-feature-names.js +25 -0
  118. package/dist/rules/no-dupe-feature-names.js.map +1 -0
  119. package/dist/rules/no-dupe-file-names.d.ts +4 -0
  120. package/dist/rules/no-dupe-file-names.d.ts.map +1 -0
  121. package/dist/rules/no-dupe-file-names.js +28 -0
  122. package/dist/rules/no-dupe-file-names.js.map +1 -0
  123. package/dist/rules/no-dupe-scenario-names.d.ts +4 -0
  124. package/dist/rules/no-dupe-scenario-names.d.ts.map +1 -0
  125. package/dist/rules/no-dupe-scenario-names.js +41 -0
  126. package/dist/rules/no-dupe-scenario-names.js.map +1 -0
  127. package/dist/rules/no-duplicate-tags.d.ts +4 -0
  128. package/dist/rules/no-duplicate-tags.d.ts.map +1 -0
  129. package/dist/rules/no-duplicate-tags.js +38 -0
  130. package/dist/rules/no-duplicate-tags.js.map +1 -0
  131. package/dist/rules/no-empty-background.d.ts +4 -0
  132. package/dist/rules/no-empty-background.d.ts.map +1 -0
  133. package/dist/rules/no-empty-background.js +24 -0
  134. package/dist/rules/no-empty-background.js.map +1 -0
  135. package/dist/rules/no-empty-file.d.ts +4 -0
  136. package/dist/rules/no-empty-file.d.ts.map +1 -0
  137. package/dist/rules/no-empty-file.js +12 -0
  138. package/dist/rules/no-empty-file.js.map +1 -0
  139. package/dist/rules/no-examples-in-scenarios.d.ts +4 -0
  140. package/dist/rules/no-examples-in-scenarios.d.ts.map +1 -0
  141. package/dist/rules/no-examples-in-scenarios.js +25 -0
  142. package/dist/rules/no-examples-in-scenarios.js.map +1 -0
  143. package/dist/rules/no-files-without-scenarios.d.ts +4 -0
  144. package/dist/rules/no-files-without-scenarios.d.ts.map +1 -0
  145. package/dist/rules/no-files-without-scenarios.js +18 -0
  146. package/dist/rules/no-files-without-scenarios.js.map +1 -0
  147. package/dist/rules/no-homogenous-tags.d.ts +4 -0
  148. package/dist/rules/no-homogenous-tags.d.ts.map +1 -0
  149. package/dist/rules/no-homogenous-tags.js +54 -0
  150. package/dist/rules/no-homogenous-tags.js.map +1 -0
  151. package/dist/rules/no-multiple-empty-lines.d.ts +4 -0
  152. package/dist/rules/no-multiple-empty-lines.d.ts.map +1 -0
  153. package/dist/rules/no-multiple-empty-lines.js +44 -0
  154. package/dist/rules/no-multiple-empty-lines.js.map +1 -0
  155. package/dist/rules/no-partially-commented-tag-lines.d.ts +4 -0
  156. package/dist/rules/no-partially-commented-tag-lines.d.ts.map +1 -0
  157. package/dist/rules/no-partially-commented-tag-lines.js +44 -0
  158. package/dist/rules/no-partially-commented-tag-lines.js.map +1 -0
  159. package/dist/rules/no-restricted-patterns.d.ts +4 -0
  160. package/dist/rules/no-restricted-patterns.d.ts.map +1 -0
  161. package/dist/rules/no-restricted-patterns.js +101 -0
  162. package/dist/rules/no-restricted-patterns.js.map +1 -0
  163. package/dist/rules/no-restricted-tags.d.ts +4 -0
  164. package/dist/rules/no-restricted-tags.d.ts.map +1 -0
  165. package/dist/rules/no-restricted-tags.js +35 -0
  166. package/dist/rules/no-restricted-tags.js.map +1 -0
  167. package/dist/rules/no-scenario-outlines-without-examples.d.ts +4 -0
  168. package/dist/rules/no-scenario-outlines-without-examples.d.ts.map +1 -0
  169. package/dist/rules/no-scenario-outlines-without-examples.js +29 -0
  170. package/dist/rules/no-scenario-outlines-without-examples.js.map +1 -0
  171. package/dist/rules/no-superfluous-tags.d.ts +4 -0
  172. package/dist/rules/no-superfluous-tags.d.ts.map +1 -0
  173. package/dist/rules/no-superfluous-tags.js +40 -0
  174. package/dist/rules/no-superfluous-tags.js.map +1 -0
  175. package/dist/rules/no-trailing-spaces.d.ts +4 -0
  176. package/dist/rules/no-trailing-spaces.d.ts.map +1 -0
  177. package/dist/rules/no-trailing-spaces.js +24 -0
  178. package/dist/rules/no-trailing-spaces.js.map +1 -0
  179. package/dist/rules/no-undeclared-variables.d.ts +4 -0
  180. package/dist/rules/no-undeclared-variables.d.ts.map +1 -0
  181. package/dist/rules/no-undeclared-variables.js +35 -0
  182. package/dist/rules/no-undeclared-variables.js.map +1 -0
  183. package/dist/rules/no-unnamed-features.d.ts +4 -0
  184. package/dist/rules/no-unnamed-features.d.ts.map +1 -0
  185. package/dist/rules/no-unnamed-features.js +19 -0
  186. package/dist/rules/no-unnamed-features.js.map +1 -0
  187. package/dist/rules/no-unnamed-scenarios.d.ts +4 -0
  188. package/dist/rules/no-unnamed-scenarios.d.ts.map +1 -0
  189. package/dist/rules/no-unnamed-scenarios.js +24 -0
  190. package/dist/rules/no-unnamed-scenarios.js.map +1 -0
  191. package/dist/rules/no-unused-variables.d.ts +4 -0
  192. package/dist/rules/no-unused-variables.d.ts.map +1 -0
  193. package/dist/rules/no-unused-variables.js +36 -0
  194. package/dist/rules/no-unused-variables.js.map +1 -0
  195. package/dist/rules/one-space-between-tags.d.ts +4 -0
  196. package/dist/rules/one-space-between-tags.d.ts.map +1 -0
  197. package/dist/rules/one-space-between-tags.js +36 -0
  198. package/dist/rules/one-space-between-tags.js.map +1 -0
  199. package/dist/rules/only-one-when.d.ts +4 -0
  200. package/dist/rules/only-one-when.d.ts.map +1 -0
  201. package/dist/rules/only-one-when.js +59 -0
  202. package/dist/rules/only-one-when.js.map +1 -0
  203. package/dist/rules/required-tags.d.ts +4 -0
  204. package/dist/rules/required-tags.d.ts.map +1 -0
  205. package/dist/rules/required-tags.js +36 -0
  206. package/dist/rules/required-tags.js.map +1 -0
  207. package/dist/rules/scenario-size.d.ts +4 -0
  208. package/dist/rules/scenario-size.d.ts.map +1 -0
  209. package/dist/rules/scenario-size.js +37 -0
  210. package/dist/rules/scenario-size.js.map +1 -0
  211. package/dist/rules/use-and.d.ts +4 -0
  212. package/dist/rules/use-and.d.ts.map +1 -0
  213. package/dist/rules/use-and.js +33 -0
  214. package/dist/rules/use-and.js.map +1 -0
  215. package/dist/rules.d.ts +24 -0
  216. package/dist/rules.d.ts.map +1 -0
  217. package/dist/rules.js +109 -0
  218. package/dist/rules.js.map +1 -0
  219. package/dist/suppressions.d.ts +33 -0
  220. package/dist/suppressions.d.ts.map +1 -0
  221. package/dist/suppressions.js +84 -0
  222. package/dist/suppressions.js.map +1 -0
  223. package/dist/types.d.ts +81 -0
  224. package/dist/types.d.ts.map +1 -0
  225. package/dist/types.js +2 -0
  226. package/dist/types.js.map +1 -0
  227. package/dist/util/case.d.ts +21 -0
  228. package/dist/util/case.d.ts.map +1 -0
  229. package/dist/util/case.js +42 -0
  230. package/dist/util/case.js.map +1 -0
  231. package/dist/util/collections.d.ts +30 -0
  232. package/dist/util/collections.d.ts.map +1 -0
  233. package/dist/util/collections.js +87 -0
  234. package/dist/util/collections.js.map +1 -0
  235. package/dist/util/glob.d.ts +20 -0
  236. package/dist/util/glob.d.ts.map +1 -0
  237. package/dist/util/glob.js +203 -0
  238. package/dist/util/glob.js.map +1 -0
  239. package/dist/util/json.d.ts +14 -0
  240. package/dist/util/json.d.ts.map +1 -0
  241. package/dist/util/json.js +63 -0
  242. package/dist/util/json.js.map +1 -0
  243. package/dist/util/lines.d.ts +24 -0
  244. package/dist/util/lines.d.ts.map +1 -0
  245. package/dist/util/lines.js +45 -0
  246. package/dist/util/lines.js.map +1 -0
  247. package/dist/util/location.d.ts +15 -0
  248. package/dist/util/location.d.ts.map +1 -0
  249. package/dist/util/location.js +11 -0
  250. package/dist/util/location.js.map +1 -0
  251. package/dist/util/xml.d.ts +16 -0
  252. package/dist/util/xml.d.ts.map +1 -0
  253. package/dist/util/xml.js +36 -0
  254. package/dist/util/xml.js.map +1 -0
  255. package/dist/version.d.ts +3 -0
  256. package/dist/version.d.ts.map +1 -0
  257. package/dist/version.js +24 -0
  258. package/dist/version.js.map +1 -0
  259. package/package.json +61 -0
@@ -0,0 +1,29 @@
1
+ import { getNodeType } from '../gherkin/keywords.js';
2
+ import { scenariosOf } from '../gherkin/traverse.js';
3
+ import { at } from '../util/location.js';
4
+ const name = 'no-scenario-outlines-without-examples';
5
+ const rule = {
6
+ name,
7
+ run(feature) {
8
+ if (feature === undefined) {
9
+ return [];
10
+ }
11
+ const errors = [];
12
+ for (const { scenario } of scenariosOf(feature)) {
13
+ if (getNodeType(scenario, feature.language) !== 'Scenario Outline') {
14
+ continue;
15
+ }
16
+ const hasRows = scenario.examples.some((examples) => examples.tableBody.length > 0);
17
+ if (!hasRows) {
18
+ errors.push({
19
+ message: 'Scenario Outline does not have any Examples',
20
+ rule: name,
21
+ ...at(scenario.location),
22
+ });
23
+ }
24
+ }
25
+ return errors;
26
+ },
27
+ };
28
+ export default rule;
29
+ //# sourceMappingURL=no-scenario-outlines-without-examples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-scenario-outlines-without-examples.js","sourceRoot":"","sources":["../../src/rules/no-scenario-outlines-without-examples.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,MAAM,IAAI,GAAG,uCAAuC,CAAC;AAErD,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,GAAG,CAAC,OAAO;QACT,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAgB,EAAE,CAAC;QAE/B,KAAK,MAAM,EAAC,QAAQ,EAAC,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9C,IAAI,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,kBAAkB,EAAE,CAAC;gBACnE,SAAS;YACX,CAAC;YACD,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACpF,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,6CAA6C;oBACtD,IAAI,EAAE,IAAI;oBACV,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;iBACzB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=no-superfluous-tags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-superfluous-tags.d.ts","sourceRoot":"","sources":["../../src/rules/no-superfluous-tags.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAMrD,QAAA,MAAM,IAAI,EAAE,QAoCX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,40 @@
1
+ import { getNodeType } from '../gherkin/keywords.js';
2
+ import { taggedNodesOf } from '../gherkin/traverse.js';
3
+ import { intersectionBy } from '../util/collections.js';
4
+ import { at } from '../util/location.js';
5
+ const name = 'no-superfluous-tags';
6
+ const rule = {
7
+ name,
8
+ run(feature) {
9
+ if (feature === undefined) {
10
+ return [];
11
+ }
12
+ const errors = [];
13
+ const language = feature.language;
14
+ const check = (child, parent) => {
15
+ const duplicated = intersectionBy(child.tags, parent.tags, (tag) => tag.name);
16
+ if (duplicated.length === 0) {
17
+ return;
18
+ }
19
+ const childType = getNodeType(child, language);
20
+ const parentType = getNodeType(parent, language);
21
+ for (const tag of duplicated) {
22
+ errors.push({
23
+ message: `Tag duplication between ${childType} and its corresponding ${parentType}: ${tag.name}`,
24
+ rule: name,
25
+ ...at(tag.location),
26
+ });
27
+ }
28
+ };
29
+ // A node inherits the tags of everything it sits inside, so a tag repeated
30
+ // on any ancestor is superfluous - not only one repeated on the nearest.
31
+ for (const { node, ancestors } of taggedNodesOf(feature)) {
32
+ for (const ancestor of ancestors) {
33
+ check(node, ancestor);
34
+ }
35
+ }
36
+ return errors;
37
+ },
38
+ };
39
+ export default rule;
40
+ //# sourceMappingURL=no-superfluous-tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-superfluous-tags.js","sourceRoot":"","sources":["../../src/rules/no-superfluous-tags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAoB,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,MAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,GAAG,CAAC,OAAO;QACT,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAElC,MAAM,KAAK,GAAG,CAAC,KAAmB,EAAE,MAAoB,EAAQ,EAAE;YAChE,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC9E,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5B,OAAO;YACT,CAAC;YACD,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC/C,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACjD,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;gBAC7B,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,2BAA2B,SAAS,0BAA0B,UAAU,KAAK,GAAG,CAAC,IAAI,EAAE;oBAChG,IAAI,EAAE,IAAI;oBACV,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC;iBACpB,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;QAEF,2EAA2E;QAC3E,yEAAyE;QACzE,KAAK,MAAM,EAAC,IAAI,EAAE,SAAS,EAAC,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;YACvD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=no-trailing-spaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-trailing-spaces.d.ts","sourceRoot":"","sources":["../../src/rules/no-trailing-spaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAMrD,QAAA,MAAM,IAAI,EAAE,QAkBX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,24 @@
1
+ import { atLineColumn } from '../util/location.js';
2
+ const name = 'no-trailing-spaces';
3
+ const TRAILING_WHITESPACE = /[\t ]+$/;
4
+ const rule = {
5
+ name,
6
+ run(_feature, file) {
7
+ const errors = [];
8
+ file.lines.forEach((line, index) => {
9
+ const trailing = TRAILING_WHITESPACE.exec(line);
10
+ if (trailing !== null) {
11
+ errors.push({
12
+ message: 'Trailing spaces are not allowed',
13
+ rule: name,
14
+ // Point at the first character of the run, so an editor can
15
+ // underline exactly what has to go.
16
+ ...atLineColumn(index + 1, trailing.index + 1),
17
+ });
18
+ }
19
+ });
20
+ return errors;
21
+ },
22
+ };
23
+ export default rule;
24
+ //# sourceMappingURL=no-trailing-spaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-trailing-spaces.js","sourceRoot":"","sources":["../../src/rules/no-trailing-spaces.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAEjD,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAEtC,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,GAAG,CAAC,QAAQ,EAAE,IAAI;QAChB,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACjC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACtB,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,iCAAiC;oBAC1C,IAAI,EAAE,IAAI;oBACV,4DAA4D;oBAC5D,oCAAoC;oBACpC,GAAG,YAAY,CAAC,KAAK,GAAG,CAAC,EAAE,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;iBAC/C,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=no-undeclared-variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-undeclared-variables.d.ts","sourceRoot":"","sources":["../../src/rules/no-undeclared-variables.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAIrD,QAAA,MAAM,IAAI,EAAE,QAkCX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,35 @@
1
+ import { variablesOf } from '../gherkin/variables.js';
2
+ import { scenariosOf } from '../gherkin/traverse.js';
3
+ const name = 'no-undeclared-variables';
4
+ const rule = {
5
+ name,
6
+ run(feature) {
7
+ if (feature === undefined) {
8
+ return [];
9
+ }
10
+ const errors = [];
11
+ for (const { scenario } of scenariosOf(feature)) {
12
+ // Without an Examples table there is nothing to declare a variable in,
13
+ // and a <placeholder> is just text.
14
+ if (scenario.examples.length === 0) {
15
+ continue;
16
+ }
17
+ const { declared, used } = variablesOf(scenario);
18
+ for (const [variable, positions] of used) {
19
+ if (declared.has(variable)) {
20
+ continue;
21
+ }
22
+ for (const position of positions) {
23
+ errors.push({
24
+ message: `Step variable "${variable}" does not exist in the examples table`,
25
+ rule: name,
26
+ ...position,
27
+ });
28
+ }
29
+ }
30
+ }
31
+ return errors;
32
+ },
33
+ };
34
+ export default rule;
35
+ //# sourceMappingURL=no-undeclared-variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-undeclared-variables.js","sourceRoot":"","sources":["../../src/rules/no-undeclared-variables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAGnD,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,GAAG,CAAC,OAAO;QACT,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAgB,EAAE,CAAC;QAE/B,KAAK,MAAM,EAAC,QAAQ,EAAC,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9C,uEAAuE;YACvE,oCAAoC;YACpC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnC,SAAS;YACX,CAAC;YAED,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;YAE/C,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;gBACzC,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC3B,SAAS;gBACX,CAAC;gBACD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;oBACjC,MAAM,CAAC,IAAI,CAAC;wBACV,OAAO,EAAE,kBAAkB,QAAQ,wCAAwC;wBAC3E,IAAI,EAAE,IAAI;wBACV,GAAG,QAAQ;qBACZ,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=no-unnamed-features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unnamed-features.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnamed-features.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAK1C,QAAA,MAAM,IAAI,EAAE,QAcX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,19 @@
1
+ import { at } from '../util/location.js';
2
+ const name = 'no-unnamed-features';
3
+ const rule = {
4
+ name,
5
+ run(feature) {
6
+ if (feature !== undefined && feature.name !== '') {
7
+ return [];
8
+ }
9
+ return [
10
+ {
11
+ message: 'Missing Feature name',
12
+ rule: name,
13
+ ...(feature === undefined ? { line: 0 } : at(feature.location)),
14
+ },
15
+ ];
16
+ },
17
+ };
18
+ export default rule;
19
+ //# sourceMappingURL=no-unnamed-features.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unnamed-features.js","sourceRoot":"","sources":["../../src/rules/no-unnamed-features.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,MAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,GAAG,CAAC,OAAO;QACT,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;YACjD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO;YACL;gBACE,OAAO,EAAE,sBAAsB;gBAC/B,IAAI,EAAE,IAAI;gBACV,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;aAC9D;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=no-unnamed-scenarios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unnamed-scenarios.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnamed-scenarios.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAKrD,QAAA,MAAM,IAAI,EAAE,QAkBX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,24 @@
1
+ import { scenariosOf } from '../gherkin/traverse.js';
2
+ import { at } from '../util/location.js';
3
+ const name = 'no-unnamed-scenarios';
4
+ const rule = {
5
+ name,
6
+ run(feature) {
7
+ if (feature === undefined) {
8
+ return [];
9
+ }
10
+ const errors = [];
11
+ for (const { scenario } of scenariosOf(feature)) {
12
+ if (scenario.name === '') {
13
+ errors.push({
14
+ message: 'Missing Scenario name',
15
+ rule: name,
16
+ ...at(scenario.location),
17
+ });
18
+ }
19
+ }
20
+ return errors;
21
+ },
22
+ };
23
+ export default rule;
24
+ //# sourceMappingURL=no-unnamed-scenarios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unnamed-scenarios.js","sourceRoot":"","sources":["../../src/rules/no-unnamed-scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,MAAM,IAAI,GAAG,sBAAsB,CAAC;AAEpC,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,GAAG,CAAC,OAAO;QACT,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,KAAK,MAAM,EAAC,QAAQ,EAAC,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9C,IAAI,QAAQ,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;gBACzB,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,uBAAuB;oBAChC,IAAI,EAAE,IAAI;oBACV,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;iBACzB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=no-unused-variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unused-variables.d.ts","sourceRoot":"","sources":["../../src/rules/no-unused-variables.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAIrD,QAAA,MAAM,IAAI,EAAE,QAmCX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,36 @@
1
+ import { variablesOf } from '../gherkin/variables.js';
2
+ import { scenariosOf } from '../gherkin/traverse.js';
3
+ const name = 'no-unused-variables';
4
+ const rule = {
5
+ name,
6
+ run(feature) {
7
+ if (feature === undefined) {
8
+ return [];
9
+ }
10
+ const errors = [];
11
+ for (const { scenario } of scenariosOf(feature)) {
12
+ // Without an Examples table there is nothing to be unused.
13
+ if (scenario.examples.length === 0) {
14
+ continue;
15
+ }
16
+ const { declared, used } = variablesOf(scenario);
17
+ // Every place a problem appears is reported, not just the last one, so
18
+ // that fixing the file does not turn into a game of whack-a-mole.
19
+ for (const [variable, positions] of declared) {
20
+ if (used.has(variable)) {
21
+ continue;
22
+ }
23
+ for (const position of positions) {
24
+ errors.push({
25
+ message: `Examples table variable "${variable}" is not used in any step`,
26
+ rule: name,
27
+ ...position,
28
+ });
29
+ }
30
+ }
31
+ }
32
+ return errors;
33
+ },
34
+ };
35
+ export default rule;
36
+ //# sourceMappingURL=no-unused-variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unused-variables.js","sourceRoot":"","sources":["../../src/rules/no-unused-variables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAGnD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,GAAG,CAAC,OAAO;QACT,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAgB,EAAE,CAAC;QAE/B,KAAK,MAAM,EAAC,QAAQ,EAAC,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9C,2DAA2D;YAC3D,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnC,SAAS;YACX,CAAC;YAED,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;YAE/C,uEAAuE;YACvE,kEAAkE;YAClE,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,QAAQ,EAAE,CAAC;gBAC7C,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACvB,SAAS;gBACX,CAAC;gBACD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;oBACjC,MAAM,CAAC,IAAI,CAAC;wBACV,OAAO,EAAE,4BAA4B,QAAQ,2BAA2B;wBACxE,IAAI,EAAE,IAAI;wBACV,GAAG,QAAQ;qBACZ,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=one-space-between-tags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"one-space-between-tags.d.ts","sourceRoot":"","sources":["../../src/rules/one-space-between-tags.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAwBrD,QAAA,MAAM,IAAI,EAAE,QAaX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,36 @@
1
+ import { taggedNodesOf } from '../gherkin/traverse.js';
2
+ import { groupBy, sortBy } from '../util/collections.js';
3
+ import { at } from '../util/location.js';
4
+ const name = 'one-space-between-tags';
5
+ function checkTags(tags, errors) {
6
+ for (const [, tagsOnLine] of groupBy(tags, (tag) => tag.location.line)) {
7
+ const ordered = sortBy(tagsOnLine, (tag) => tag.location.column ?? 0);
8
+ for (let index = 0; index < ordered.length - 1; index++) {
9
+ const current = ordered[index];
10
+ const next = ordered[index + 1];
11
+ const endOfCurrent = (current.location.column ?? 0) + current.name.length;
12
+ if (endOfCurrent < (next.location.column ?? 0) - 1) {
13
+ errors.push({
14
+ message: `There is more than one space between the tags ${current.name} and ${next.name}`,
15
+ rule: name,
16
+ ...at(current.location),
17
+ });
18
+ }
19
+ }
20
+ }
21
+ }
22
+ const rule = {
23
+ name,
24
+ run(feature) {
25
+ if (feature === undefined) {
26
+ return [];
27
+ }
28
+ const errors = [];
29
+ for (const { node } of taggedNodesOf(feature)) {
30
+ checkTags(node.tags, errors);
31
+ }
32
+ return errors;
33
+ },
34
+ };
35
+ export default rule;
36
+ //# sourceMappingURL=one-space-between-tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"one-space-between-tags.js","sourceRoot":"","sources":["../../src/rules/one-space-between-tags.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAEtC,SAAS,SAAS,CAAC,IAAoB,EAAE,MAAmB;IAC1D,KAAK,MAAM,CAAC,EAAE,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACvE,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;QACtE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACxD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAE,CAAC;YAChC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;YACjC,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;YAC1E,IAAI,YAAY,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnD,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,iDAAiD,OAAO,CAAC,IAAI,QAAQ,IAAI,CAAC,IAAI,EAAE;oBACzF,IAAI,EAAE,IAAI;oBACV,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;iBACxB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,GAAG,CAAC,OAAO;QACT,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,KAAK,MAAM,EAAC,IAAI,EAAC,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=only-one-when.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"only-one-when.d.ts","sourceRoot":"","sources":["../../src/rules/only-one-when.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAiBrD,QAAA,MAAM,IAAI,EAAE,QAiDX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,59 @@
1
+ import { getNeutralKeyword } from '../gherkin/keywords.js';
2
+ import { scenariosOf } from '../gherkin/traverse.js';
3
+ import { mergeDefaults } from '../util/collections.js';
4
+ import { at } from '../util/location.js';
5
+ const name = 'only-one-when';
6
+ const availableConfigs = {
7
+ /**
8
+ * Whether an `And` following a `When` counts as another `When`.
9
+ *
10
+ * On, because the rule is really about one action per scenario, and
11
+ * `When I log in / And I log out` is two actions. Turn it off if your team
12
+ * writes a single action across several And steps.
13
+ */
14
+ countAnd: true,
15
+ };
16
+ const rule = {
17
+ name,
18
+ availableConfigs,
19
+ run(feature, _file, configuration) {
20
+ if (feature === undefined) {
21
+ return [];
22
+ }
23
+ const { countAnd } = mergeDefaults(availableConfigs, configuration);
24
+ const errors = [];
25
+ for (const { scenario } of scenariosOf(feature)) {
26
+ let lastRealKeyword = '';
27
+ let whenCount = 0;
28
+ let firstViolation = { line: 0 };
29
+ for (const step of scenario.steps) {
30
+ const keyword = getNeutralKeyword(step, feature.language);
31
+ // An `And` carries on from whichever keyword came before it, however
32
+ // many of them are chained together.
33
+ const continuesWhen = keyword === 'and' && lastRealKeyword === 'when';
34
+ if (keyword !== 'when' && !continuesWhen) {
35
+ lastRealKeyword = keyword;
36
+ continue;
37
+ }
38
+ lastRealKeyword = 'when';
39
+ if (keyword === 'and' && !countAnd) {
40
+ continue;
41
+ }
42
+ whenCount++;
43
+ if (whenCount > 1 && firstViolation.line === 0) {
44
+ firstViolation = at(step.location);
45
+ }
46
+ }
47
+ if (whenCount > 1) {
48
+ errors.push({
49
+ message: `Scenario "${scenario.name}" contains ${whenCount} When statements (max 1)`,
50
+ rule: name,
51
+ ...firstViolation,
52
+ });
53
+ }
54
+ }
55
+ return errors;
56
+ },
57
+ };
58
+ export default rule;
59
+ //# sourceMappingURL=only-one-when.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"only-one-when.js","sourceRoot":"","sources":["../../src/rules/only-one-when.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,MAAM,IAAI,GAAG,eAAe,CAAC;AAE7B,MAAM,gBAAgB,GAAG;IACvB;;;;;;OAMG;IACH,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,gBAAgB;IAChB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa;QAC/B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,EAAC,QAAQ,EAAC,GAAG,aAAa,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;QAClE,MAAM,MAAM,GAAgB,EAAE,CAAC;QAE/B,KAAK,MAAM,EAAC,QAAQ,EAAC,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9C,IAAI,eAAe,GAAG,EAAE,CAAC;YACzB,IAAI,SAAS,GAAG,CAAC,CAAC;YAClB,IAAI,cAAc,GAAoC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC;YAEhE,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBAClC,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1D,qEAAqE;gBACrE,qCAAqC;gBACrC,MAAM,aAAa,GAAG,OAAO,KAAK,KAAK,IAAI,eAAe,KAAK,MAAM,CAAC;gBAEtE,IAAI,OAAO,KAAK,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;oBACzC,eAAe,GAAG,OAAO,CAAC;oBAC1B,SAAS;gBACX,CAAC;gBAED,eAAe,GAAG,MAAM,CAAC;gBACzB,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACnC,SAAS;gBACX,CAAC;gBAED,SAAS,EAAE,CAAC;gBACZ,IAAI,SAAS,GAAG,CAAC,IAAI,cAAc,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;oBAC/C,cAAc,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;YAED,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;gBAClB,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,aAAa,QAAQ,CAAC,IAAI,cAAc,SAAS,0BAA0B;oBACpF,IAAI,EAAE,IAAI;oBACV,GAAG,cAAc;iBAClB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=required-tags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"required-tags.d.ts","sourceRoot":"","sources":["../../src/rules/required-tags.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAerD,QAAA,MAAM,IAAI,EAAE,QA+BX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,36 @@
1
+ import { getNodeType } from '../gherkin/keywords.js';
2
+ import { scenariosOf } from '../gherkin/traverse.js';
3
+ import { mergeDefaults } from '../util/collections.js';
4
+ import { at } from '../util/location.js';
5
+ const name = 'required-tags';
6
+ const availableConfigs = { tags: [], ignoreUntagged: true };
7
+ const rule = {
8
+ name,
9
+ availableConfigs,
10
+ run(feature, _file, configuration) {
11
+ if (feature === undefined) {
12
+ return [];
13
+ }
14
+ const config = mergeDefaults(availableConfigs, configuration);
15
+ const errors = [];
16
+ for (const { scenario } of scenariosOf(feature)) {
17
+ if (config.ignoreUntagged && scenario.tags.length === 0) {
18
+ continue;
19
+ }
20
+ const scenarioType = getNodeType(scenario, feature.language);
21
+ for (const required of config.tags) {
22
+ const pattern = new RegExp(required);
23
+ if (!scenario.tags.some((tag) => pattern.test(tag.name))) {
24
+ errors.push({
25
+ message: `No tag found matching ${required} for ${scenarioType}`,
26
+ rule: name,
27
+ ...at(scenario.location),
28
+ });
29
+ }
30
+ }
31
+ }
32
+ return errors;
33
+ },
34
+ };
35
+ export default rule;
36
+ //# sourceMappingURL=required-tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"required-tags.js","sourceRoot":"","sources":["../../src/rules/required-tags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,MAAM,IAAI,GAAG,eAAe,CAAC;AAS7B,MAAM,gBAAgB,GAAuB,EAAC,IAAI,EAAE,EAAE,EAAE,cAAc,EAAE,IAAI,EAAC,CAAC;AAE9E,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,gBAAgB;IAChB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa;QAC/B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,aAAa,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAgB,EAAE,CAAC;QAE/B,KAAK,MAAM,EAAC,QAAQ,EAAC,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9C,IAAI,MAAM,CAAC,cAAc,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACxD,SAAS;YACX,CAAC;YAED,MAAM,YAAY,GAAG,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC7D,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;gBACnC,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACrC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;oBACzD,MAAM,CAAC,IAAI,CAAC;wBACV,OAAO,EAAE,yBAAyB,QAAQ,QAAQ,YAAY,EAAE;wBAChE,IAAI,EAAE,IAAI;wBACV,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;qBACzB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=scenario-size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario-size.d.ts","sourceRoot":"","sources":["../../src/rules/scenario-size.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAcrD,QAAA,MAAM,IAAI,EAAE,QAyBX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,37 @@
1
+ import { getNodeType } from '../gherkin/keywords.js';
2
+ import { stepContainersOf } from '../gherkin/traverse.js';
3
+ import { mergeDefaults } from '../util/collections.js';
4
+ import { at } from '../util/location.js';
5
+ const name = 'scenario-size';
6
+ /** Maximum number of steps allowed in each kind of block. */
7
+ const availableConfigs = {
8
+ 'steps-length': {
9
+ Background: 15,
10
+ Scenario: 15,
11
+ },
12
+ };
13
+ const rule = {
14
+ name,
15
+ availableConfigs,
16
+ run(feature, _file, configuration) {
17
+ if (feature === undefined) {
18
+ return [];
19
+ }
20
+ const config = mergeDefaults(availableConfigs, configuration);
21
+ const errors = [];
22
+ for (const { node } of stepContainersOf(feature)) {
23
+ const key = 'examples' in node ? 'Scenario' : 'Background';
24
+ const maximum = config['steps-length'][key];
25
+ if (typeof maximum === 'number' && node.steps.length > maximum) {
26
+ errors.push({
27
+ message: `Element ${getNodeType(node, feature.language)} too long: actual ${node.steps.length}, expected ${maximum}`,
28
+ rule: name,
29
+ ...at(node.location),
30
+ });
31
+ }
32
+ }
33
+ return errors;
34
+ },
35
+ };
36
+ export default rule;
37
+ //# sourceMappingURL=scenario-size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario-size.js","sourceRoot":"","sources":["../../src/rules/scenario-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,MAAM,IAAI,GAAG,eAAe,CAAC;AAE7B,6DAA6D;AAC7D,MAAM,gBAAgB,GAAG;IACvB,cAAc,EAAE;QACd,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;KACb;CACF,CAAC;AAEF,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,gBAAgB;IAChB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa;QAC/B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,aAAa,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAgB,EAAE,CAAC;QAE/B,KAAK,MAAM,EAAC,IAAI,EAAC,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/C,MAAM,GAAG,GAAG,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC;YAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;gBAC/D,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,WAAW,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,IAAI,CAAC,KAAK,CAAC,MAAM,cAAc,OAAO,EAAE;oBACpH,IAAI,EAAE,IAAI;oBACV,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;iBACrB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintRule } from '../types.ts';
2
+ declare const rule: LintRule;
3
+ export default rule;
4
+ //# sourceMappingURL=use-and.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-and.d.ts","sourceRoot":"","sources":["../../src/rules/use-and.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAY,MAAM,aAAa,CAAC;AAKrD,QAAA,MAAM,IAAI,EAAE,QA8BX,CAAC;eAEa,IAAI"}
@@ -0,0 +1,33 @@
1
+ import { getNeutralKeyword } from '../gherkin/keywords.js';
2
+ import { stepContainersOf } from '../gherkin/traverse.js';
3
+ import { at } from '../util/location.js';
4
+ const name = 'use-and';
5
+ const rule = {
6
+ name,
7
+ run(feature) {
8
+ if (feature === undefined) {
9
+ return [];
10
+ }
11
+ const errors = [];
12
+ for (const { node } of stepContainersOf(feature)) {
13
+ let previousKeyword;
14
+ for (const step of node.steps) {
15
+ const keyword = getNeutralKeyword(step, feature.language);
16
+ if (keyword === 'and') {
17
+ continue;
18
+ }
19
+ if (keyword === previousKeyword) {
20
+ errors.push({
21
+ message: `Step "${step.keyword}${step.text}" should use And instead of ${step.keyword}`,
22
+ rule: name,
23
+ ...at(step.location),
24
+ });
25
+ }
26
+ previousKeyword = keyword;
27
+ }
28
+ }
29
+ return errors;
30
+ },
31
+ };
32
+ export default rule;
33
+ //# sourceMappingURL=use-and.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-and.js","sourceRoot":"","sources":["../../src/rules/use-and.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,MAAM,IAAI,GAAG,SAAS,CAAC;AAEvB,MAAM,IAAI,GAAa;IACrB,IAAI;IACJ,GAAG,CAAC,OAAO;QACT,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAgB,EAAE,CAAC;QAE/B,KAAK,MAAM,EAAC,IAAI,EAAC,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/C,IAAI,eAAmC,CAAC;YAExC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC9B,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1D,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;oBACtB,SAAS;gBACX,CAAC;gBACD,IAAI,OAAO,KAAK,eAAe,EAAE,CAAC;oBAChC,MAAM,CAAC,IAAI,CAAC;wBACV,OAAO,EAAE,SAAS,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,+BAA+B,IAAI,CAAC,OAAO,EAAE;wBACvF,IAAI,EAAE,IAAI;wBACV,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;qBACrB,CAAC,CAAC;gBACL,CAAC;gBACD,eAAe,GAAG,OAAO,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { Configuration, FeatureFile, RuleConfig, RuleError, RuleRegistry, Severity } from './types.ts';
2
+ import type { Feature } from '@cucumber/messages';
3
+ /**
4
+ * The built-in rules, plus any found in the given directories. A custom rule
5
+ * with the same name as a built-in one replaces it.
6
+ */
7
+ export declare function loadRules(additionalRulesDirs?: readonly string[]): Promise<RuleRegistry>;
8
+ /** True when the configuration switches this rule on, to warn or to fail. */
9
+ export declare function isRuleEnabled(config: RuleConfig | undefined): boolean;
10
+ /** How loudly a rule reports: `warn` only warns, anything else fails the run. */
11
+ export declare function getRuleSeverity(config: RuleConfig | undefined): Severity;
12
+ /** The rule's own settings, or `undefined` when only a state was given. */
13
+ export declare function getRuleSettings(config: RuleConfig | undefined): unknown;
14
+ /** Clears the state kept by rules that look for duplicates across files. */
15
+ export declare function resetRules(rules: RuleRegistry): void;
16
+ /**
17
+ * Runs every enabled rule against one feature file.
18
+ *
19
+ * Rules are awaited one at a time. Most return an array outright, in which
20
+ * case awaiting costs nothing; a rule that needs to wait for something can
21
+ * return a promise instead.
22
+ */
23
+ export declare function runEnabledRules(feature: Feature | undefined, file: FeatureFile, configuration: Configuration, rules: RuleRegistry): Promise<RuleError[]>;
24
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EAEX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,QAAQ,EACT,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AA4ChD;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,OAAO,CAAC,YAAY,CAAC,CAavB;AAOD,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAGrE;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,CAExE;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAEvE;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAIpD;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,IAAI,EAAE,WAAW,EACjB,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,SAAS,EAAE,CAAC,CAiBtB"}