@produtype/core 1.17.1 → 1.17.2

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.
@@ -99,7 +99,7 @@ function spellsItsOwnName(trimmed) {
99
99
  * those really do introduce a declaration.
100
100
  */
101
101
  const STATEMENT_KEYWORD = /^(?:import|package|from|export|return|case|new|type|class|struct|interface|enum|func|fun|def|public|private|protected|internal|throw|throws|extends|implements|use|using|namespace|module|require|await|yield|delete|typeof|instanceof|in|is|as|if|else|for|while|switch|do|try|catch|finally|with|assert|raise|lambda|val|const)\b/;
102
- const TYPE_DECLARATION = /^(?:var\s+|let\s+|readonly\s+)?\w+\??\s*(?::\s*|\s+)(?:\[\]|\*|Array<|Map<|\bstring\b|\bnumber\b|\bboolean\b|\bbool\b|\bany\b|\bunknown\b|\bvoid\b|[A-Z])[\w.<>[\]|&\s]*;?$/;
102
+ const TYPE_DECLARATION = /^(?:var\s+|let\s+|readonly\s+)?\w+\??\s*(?::\s*|\s+)(?:\[\]|\*|Array<|Map<|\bstring\b|\bnumber\b|\bboolean\b|\bbool\b|\bany\b|\bunknown\b|\bvoid\b|[A-Z])[\w.<>[\]|&*\s]*;?$/;
103
103
  /**
104
104
  * Prose about the code, rather than the code.
105
105
  *
@@ -130,9 +130,22 @@ const COMMENT_LINE = /^(?:\/\/|\/\*|\*\/?|#(?![![])(?!!)|<!--|--\s)/;
130
130
  *
131
131
  * Nothing in the shape of the line tells the two apart, so the rule is not made.
132
132
  */
133
+ /**
134
+ * Two shapes the first version of this let through, both found in caddy.
135
+ *
136
+ * `allowedOrigins []*url.URL` is a struct field and the type is a pointer, which the
137
+ * character class did not allow — so a declaration was cited as a cross-origin
138
+ * decision. `AllowDomain []string // FIXME: this option is from legacy` is the same
139
+ * thing with gitea's note after it, and the rule required the line to end at the
140
+ * type.
141
+ *
142
+ * A trailing comment is dropped before the test, exactly as the self-naming rule
143
+ * drops it, and `*` and `&` join the characters a type may be written with.
144
+ */
133
145
  function declaresAType(trimmed) {
134
- const withoutDeclarator = trimmed.replace(/^(?:var|let|readonly)\s+/, '');
135
- return !STATEMENT_KEYWORD.test(withoutDeclarator) && TYPE_DECLARATION.test(trimmed);
146
+ const withoutComment = trimmed.replace(/\s*(?:\/\/|#).*$/, '').trimEnd();
147
+ const withoutDeclarator = withoutComment.replace(/^(?:var|let|readonly)\s+/, '');
148
+ return !STATEMENT_KEYWORD.test(withoutDeclarator) && TYPE_DECLARATION.test(withoutComment);
136
149
  }
137
150
  function declaresRatherThanDoes(line) {
138
151
  const trimmed = line.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produtype/core",
3
- "version": "1.17.1",
3
+ "version": "1.17.2",
4
4
  "description": "Deterministic CLI and library that analyzes a web application repository and reports how far it is from production-ready for the kind of product it is meant to be.",
5
5
  "license": "MIT",
6
6
  "bin": {