@thethracian/oxlint-config 0.2.0 → 0.3.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/CHANGELOG.md +13 -0
- package/README.md +125 -19
- package/dist/codemod-fix/cli.d.ts +3 -0
- package/dist/codemod-fix/cli.d.ts.map +1 -0
- package/dist/codemod-fix/cli.js +22 -0
- package/dist/codemod-fix/cli.js.map +1 -0
- package/dist/codemod-fix/index.d.ts +44 -0
- package/dist/codemod-fix/index.d.ts.map +1 -0
- package/dist/codemod-fix/index.js +110 -0
- package/dist/codemod-fix/index.js.map +1 -0
- package/dist/codemods/arrow-body-style.d.ts +7 -0
- package/dist/codemods/arrow-body-style.d.ts.map +1 -0
- package/dist/codemods/arrow-body-style.js +106 -0
- package/dist/codemods/arrow-body-style.js.map +1 -0
- package/dist/codemods/comment-format.d.ts +24 -0
- package/dist/codemods/comment-format.d.ts.map +1 -0
- package/dist/codemods/comment-format.js +100 -0
- package/dist/codemods/comment-format.js.map +1 -0
- package/dist/codemods/explicit-return-types.d.ts +7 -0
- package/dist/codemods/explicit-return-types.d.ts.map +1 -0
- package/dist/codemods/explicit-return-types.js +350 -0
- package/dist/codemods/explicit-return-types.js.map +1 -0
- package/dist/codemods/format-file-header.d.ts +7 -0
- package/dist/codemods/format-file-header.d.ts.map +1 -0
- package/dist/codemods/format-file-header.js +163 -0
- package/dist/codemods/format-file-header.js.map +1 -0
- package/dist/codemods/format-jsdoc-comments.d.ts +7 -0
- package/dist/codemods/format-jsdoc-comments.d.ts.map +1 -0
- package/dist/codemods/format-jsdoc-comments.js +129 -0
- package/dist/codemods/format-jsdoc-comments.js.map +1 -0
- package/dist/codemods/function-declarations.d.ts +7 -0
- package/dist/codemods/function-declarations.d.ts.map +1 -0
- package/dist/codemods/function-declarations.js +202 -0
- package/dist/codemods/function-declarations.js.map +1 -0
- package/dist/codemods/inline-export-lists.d.ts +7 -0
- package/dist/codemods/inline-export-lists.d.ts.map +1 -0
- package/dist/codemods/inline-export-lists.js +168 -0
- package/dist/codemods/inline-export-lists.js.map +1 -0
- package/dist/codemods/internal-export-docs.d.ts +7 -0
- package/dist/codemods/internal-export-docs.d.ts.map +1 -0
- package/dist/codemods/internal-export-docs.js +93 -0
- package/dist/codemods/internal-export-docs.js.map +1 -0
- package/dist/codemods/no-ternary-branch-initializers.d.ts +14 -0
- package/dist/codemods/no-ternary-branch-initializers.d.ts.map +1 -0
- package/dist/codemods/no-ternary-branch-initializers.js +240 -0
- package/dist/codemods/no-ternary-branch-initializers.js.map +1 -0
- package/dist/codemods/no-ternary-variable-initializers.d.ts +14 -0
- package/dist/codemods/no-ternary-variable-initializers.d.ts.map +1 -0
- package/dist/codemods/no-ternary-variable-initializers.js +235 -0
- package/dist/codemods/no-ternary-variable-initializers.js.map +1 -0
- package/dist/codemods/no-ternary.d.ts +7 -0
- package/dist/codemods/no-ternary.d.ts.map +1 -0
- package/dist/codemods/no-ternary.js +215 -0
- package/dist/codemods/no-ternary.js.map +1 -0
- package/dist/codemods/rename-acronyms.d.ts +8 -0
- package/dist/codemods/rename-acronyms.d.ts.map +1 -0
- package/dist/codemods/rename-acronyms.js +193 -0
- package/dist/codemods/rename-acronyms.js.map +1 -0
- package/dist/codemods/run.d.ts +2 -0
- package/dist/codemods/run.d.ts.map +1 -0
- package/dist/codemods/run.js +14 -0
- package/dist/codemods/run.js.map +1 -0
- package/dist/codemods/sort-imports.d.ts +7 -0
- package/dist/codemods/sort-imports.d.ts.map +1 -0
- package/dist/codemods/sort-imports.js +235 -0
- package/dist/codemods/sort-imports.js.map +1 -0
- package/dist/index.d.ts +30 -96
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +157 -95
- package/dist/index.js.map +1 -1
- package/dist/rules/acronym-case.d.ts +7 -3
- package/dist/rules/acronym-case.d.ts.map +1 -1
- package/dist/rules/acronym-case.js +129 -120
- package/dist/rules/acronym-case.js.map +1 -1
- package/dist/rules/acronyms-1.d.ts +3 -0
- package/dist/rules/acronyms-1.d.ts.map +1 -0
- package/dist/rules/acronyms-1.js +407 -0
- package/dist/rules/acronyms-1.js.map +1 -0
- package/dist/rules/acronyms-2.d.ts +3 -0
- package/dist/rules/acronyms-2.d.ts.map +1 -0
- package/dist/rules/acronyms-2.js +407 -0
- package/dist/rules/acronyms-2.js.map +1 -0
- package/dist/rules/acronyms-3.d.ts +3 -0
- package/dist/rules/acronyms-3.d.ts.map +1 -0
- package/dist/rules/acronyms-3.js +407 -0
- package/dist/rules/acronyms-3.js.map +1 -0
- package/dist/rules/acronyms-4.d.ts +3 -0
- package/dist/rules/acronyms-4.d.ts.map +1 -0
- package/dist/rules/acronyms-4.js +377 -0
- package/dist/rules/acronyms-4.js.map +1 -0
- package/dist/rules/acronyms.d.ts +1 -8
- package/dist/rules/acronyms.d.ts.map +1 -1
- package/dist/rules/acronyms.js +14 -1578
- package/dist/rules/acronyms.js.map +1 -1
- package/dist/rules/boolean-prefix.d.ts +11 -2
- package/dist/rules/boolean-prefix.d.ts.map +1 -1
- package/dist/rules/boolean-prefix.js +95 -59
- package/dist/rules/boolean-prefix.js.map +1 -1
- package/dist/rules/camel-case-identifiers.d.ts +3 -4
- package/dist/rules/camel-case-identifiers.d.ts.map +1 -1
- package/dist/rules/camel-case-identifiers.js +59 -40
- package/dist/rules/camel-case-identifiers.js.map +1 -1
- package/dist/rules/char-class.d.ts +26 -13
- package/dist/rules/char-class.d.ts.map +1 -1
- package/dist/rules/char-class.js +56 -24
- package/dist/rules/char-class.js.map +1 -1
- package/dist/rules/diagnostic-guidance.d.ts +91 -0
- package/dist/rules/diagnostic-guidance.d.ts.map +1 -0
- package/dist/rules/diagnostic-guidance.js +243 -0
- package/dist/rules/diagnostic-guidance.js.map +1 -0
- package/dist/rules/effect-default-ast.d.ts +89 -0
- package/dist/rules/effect-default-ast.d.ts.map +1 -0
- package/dist/rules/effect-default-ast.js +208 -0
- package/dist/rules/effect-default-ast.js.map +1 -0
- package/dist/rules/effect-default-compat-rules.d.ts +76 -0
- package/dist/rules/effect-default-compat-rules.d.ts.map +1 -0
- package/dist/rules/effect-default-compat-rules.js +270 -0
- package/dist/rules/effect-default-compat-rules.js.map +1 -0
- package/dist/rules/effect-default-env-rules.d.ts +60 -0
- package/dist/rules/effect-default-env-rules.d.ts.map +1 -0
- package/dist/rules/effect-default-env-rules.js +259 -0
- package/dist/rules/effect-default-env-rules.js.map +1 -0
- package/dist/rules/effect-default-fiber-helpers.d.ts +13 -0
- package/dist/rules/effect-default-fiber-helpers.d.ts.map +1 -0
- package/dist/rules/effect-default-fiber-helpers.js +76 -0
- package/dist/rules/effect-default-fiber-helpers.js.map +1 -0
- package/dist/rules/effect-default-floating-helpers.d.ts +7 -0
- package/dist/rules/effect-default-floating-helpers.d.ts.map +1 -0
- package/dist/rules/effect-default-floating-helpers.js +113 -0
- package/dist/rules/effect-default-floating-helpers.js.map +1 -0
- package/dist/rules/effect-default-helpers.d.ts +8 -32
- package/dist/rules/effect-default-helpers.d.ts.map +1 -1
- package/dist/rules/effect-default-helpers.js +11 -458
- package/dist/rules/effect-default-helpers.js.map +1 -1
- package/dist/rules/effect-default-resource-helpers.d.ts +18 -4
- package/dist/rules/effect-default-resource-helpers.d.ts.map +1 -1
- package/dist/rules/effect-default-resource-helpers.js +30 -13
- package/dist/rules/effect-default-resource-helpers.js.map +1 -1
- package/dist/rules/effect-default-safety-helpers.d.ts +43 -0
- package/dist/rules/effect-default-safety-helpers.d.ts.map +1 -0
- package/dist/rules/effect-default-safety-helpers.js +126 -0
- package/dist/rules/effect-default-safety-helpers.js.map +1 -0
- package/dist/rules/effect-default-scan-helpers.d.ts +43 -0
- package/dist/rules/effect-default-scan-helpers.d.ts.map +1 -0
- package/dist/rules/effect-default-scan-helpers.js +141 -0
- package/dist/rules/effect-default-scan-helpers.js.map +1 -0
- package/dist/rules/effect-default-schema-helpers.d.ts +37 -0
- package/dist/rules/effect-default-schema-helpers.d.ts.map +1 -0
- package/dist/rules/effect-default-schema-helpers.js +104 -0
- package/dist/rules/effect-default-schema-helpers.js.map +1 -0
- package/dist/rules/effect-default-test-helpers.d.ts +18 -4
- package/dist/rules/effect-default-test-helpers.d.ts.map +1 -1
- package/dist/rules/effect-default-test-helpers.js +41 -20
- package/dist/rules/effect-default-test-helpers.js.map +1 -1
- package/dist/rules/effect-default-workflow-helpers.d.ts +91 -0
- package/dist/rules/effect-default-workflow-helpers.d.ts.map +1 -0
- package/dist/rules/effect-default-workflow-helpers.js +247 -0
- package/dist/rules/effect-default-workflow-helpers.js.map +1 -0
- package/dist/rules/effect-default.d.ts +1 -1
- package/dist/rules/effect-default.d.ts.map +1 -1
- package/dist/rules/effect-default.js +198 -637
- package/dist/rules/effect-default.js.map +1 -1
- package/dist/rules/effect-exported-declarations.d.ts +19 -0
- package/dist/rules/effect-exported-declarations.d.ts.map +1 -0
- package/dist/rules/effect-exported-declarations.js +237 -0
- package/dist/rules/effect-exported-declarations.js.map +1 -0
- package/dist/rules/effect-path-options.d.ts +49 -11
- package/dist/rules/effect-path-options.d.ts.map +1 -1
- package/dist/rules/effect-path-options.js +85 -52
- package/dist/rules/effect-path-options.js.map +1 -1
- package/dist/rules/effect-rule-aliases.d.ts +55 -0
- package/dist/rules/effect-rule-aliases.d.ts.map +1 -0
- package/dist/rules/effect-rule-aliases.js +278 -0
- package/dist/rules/effect-rule-aliases.js.map +1 -0
- package/dist/rules/effect-rule-core.d.ts +46 -24
- package/dist/rules/effect-rule-core.d.ts.map +1 -1
- package/dist/rules/effect-rule-core.js +263 -303
- package/dist/rules/effect-rule-core.js.map +1 -1
- package/dist/rules/effect-rule-names.d.ts +12 -3
- package/dist/rules/effect-rule-names.d.ts.map +1 -1
- package/dist/rules/effect-rule-names.js +15 -3
- package/dist/rules/effect-rule-names.js.map +1 -1
- package/dist/rules/effect-source-comments.d.ts +7 -0
- package/dist/rules/effect-source-comments.d.ts.map +1 -0
- package/dist/rules/effect-source-comments.js +227 -0
- package/dist/rules/effect-source-comments.js.map +1 -0
- package/dist/rules/effect-source-helpers.d.ts +4 -9
- package/dist/rules/effect-source-helpers.d.ts.map +1 -1
- package/dist/rules/effect-source-helpers.js +7 -333
- package/dist/rules/effect-source-helpers.js.map +1 -1
- package/dist/rules/effect-source-navigation.d.ts +25 -0
- package/dist/rules/effect-source-navigation.d.ts.map +1 -0
- package/dist/rules/effect-source-navigation.js +244 -0
- package/dist/rules/effect-source-navigation.js.map +1 -0
- package/dist/rules/effect-source-scan.d.ts +30 -7
- package/dist/rules/effect-source-scan.d.ts.map +1 -1
- package/dist/rules/effect-source-scan.js +377 -297
- package/dist/rules/effect-source-scan.js.map +1 -1
- package/dist/rules/effect-strict-ast-specs.d.ts +8 -0
- package/dist/rules/effect-strict-ast-specs.d.ts.map +1 -0
- package/dist/rules/effect-strict-ast-specs.js +166 -0
- package/dist/rules/effect-strict-ast-specs.js.map +1 -0
- package/dist/rules/effect-strict-boundary-helpers.d.ts +25 -0
- package/dist/rules/effect-strict-boundary-helpers.d.ts.map +1 -0
- package/dist/rules/effect-strict-boundary-helpers.js +127 -0
- package/dist/rules/effect-strict-boundary-helpers.js.map +1 -0
- package/dist/rules/effect-strict-core-specs.d.ts +8 -0
- package/dist/rules/effect-strict-core-specs.d.ts.map +1 -0
- package/dist/rules/effect-strict-core-specs.js +334 -0
- package/dist/rules/effect-strict-core-specs.js.map +1 -0
- package/dist/rules/effect-strict-external-helpers.d.ts +25 -0
- package/dist/rules/effect-strict-external-helpers.d.ts.map +1 -0
- package/dist/rules/effect-strict-external-helpers.js +87 -0
- package/dist/rules/effect-strict-external-helpers.js.map +1 -0
- package/dist/rules/effect-strict-helpers.d.ts +75 -33
- package/dist/rules/effect-strict-helpers.d.ts.map +1 -1
- package/dist/rules/effect-strict-helpers.js +124 -246
- package/dist/rules/effect-strict-helpers.js.map +1 -1
- package/dist/rules/effect-strict-internals.d.ts +198 -0
- package/dist/rules/effect-strict-internals.d.ts.map +1 -0
- package/dist/rules/effect-strict-internals.js +477 -0
- package/dist/rules/effect-strict-internals.js.map +1 -0
- package/dist/rules/effect-strict-segment-helpers.d.ts +79 -0
- package/dist/rules/effect-strict-segment-helpers.d.ts.map +1 -0
- package/dist/rules/effect-strict-segment-helpers.js +308 -0
- package/dist/rules/effect-strict-segment-helpers.js.map +1 -0
- package/dist/rules/effect-strict.d.ts +1 -1
- package/dist/rules/effect-strict.d.ts.map +1 -1
- package/dist/rules/effect-strict.js +10 -661
- package/dist/rules/effect-strict.js.map +1 -1
- package/dist/rules/max-import-depth.d.ts +2 -2
- package/dist/rules/max-import-depth.d.ts.map +1 -1
- package/dist/rules/max-import-depth.js +52 -17
- package/dist/rules/max-import-depth.js.map +1 -1
- package/dist/rules/max-line-length.d.ts +9 -2
- package/dist/rules/max-line-length.d.ts.map +1 -1
- package/dist/rules/max-line-length.js +62 -7
- package/dist/rules/max-line-length.js.map +1 -1
- package/dist/rules/no-commented-out-code.d.ts +3 -7
- package/dist/rules/no-commented-out-code.d.ts.map +1 -1
- package/dist/rules/no-commented-out-code.js +157 -102
- package/dist/rules/no-commented-out-code.js.map +1 -1
- package/dist/rules/pascal-case-types.d.ts +1 -1
- package/dist/rules/pascal-case-types.d.ts.map +1 -1
- package/dist/rules/pascal-case-types.js +65 -46
- package/dist/rules/pascal-case-types.js.map +1 -1
- package/dist/rules/plugin-commented-out-code-rule.d.ts +32 -0
- package/dist/rules/plugin-commented-out-code-rule.d.ts.map +1 -0
- package/dist/rules/plugin-commented-out-code-rule.js +135 -0
- package/dist/rules/plugin-commented-out-code-rule.js.map +1 -0
- package/dist/rules/plugin.d.ts +3 -121
- package/dist/rules/plugin.d.ts.map +1 -1
- package/dist/rules/plugin.js +195 -201
- package/dist/rules/plugin.js.map +1 -1
- package/dist/rules/private-underscore.d.ts +1 -1
- package/dist/rules/private-underscore.d.ts.map +1 -1
- package/dist/rules/private-underscore.js +11 -4
- package/dist/rules/private-underscore.js.map +1 -1
- package/dist/rules/require-file-doc.d.ts +5 -6
- package/dist/rules/require-file-doc.d.ts.map +1 -1
- package/dist/rules/require-file-doc.js +127 -78
- package/dist/rules/require-file-doc.js.map +1 -1
- package/dist/rules/require-function-doc-ignored-text.d.ts +7 -0
- package/dist/rules/require-function-doc-ignored-text.d.ts.map +1 -0
- package/dist/rules/require-function-doc-ignored-text.js +67 -0
- package/dist/rules/require-function-doc-ignored-text.js.map +1 -0
- package/dist/rules/require-function-doc-local-exports.d.ts +7 -0
- package/dist/rules/require-function-doc-local-exports.d.ts.map +1 -0
- package/dist/rules/require-function-doc-local-exports.js +114 -0
- package/dist/rules/require-function-doc-local-exports.js.map +1 -0
- package/dist/rules/require-function-doc.d.ts +3 -18
- package/dist/rules/require-function-doc.d.ts.map +1 -1
- package/dist/rules/require-function-doc.js +404 -218
- package/dist/rules/require-function-doc.js.map +1 -1
- package/dist/rules/source-cache.d.ts +19 -0
- package/dist/rules/source-cache.d.ts.map +1 -0
- package/dist/rules/source-cache.js +63 -0
- package/dist/rules/source-cache.js.map +1 -0
- package/package.json +15 -10
|
@@ -1,63 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
/* -------------------------------------------------------------------------- */
|
|
2
|
+
/* Exported-declaration documentation requirement helper for custom Oxlint */
|
|
3
|
+
/* Rules. */
|
|
4
|
+
/* -------------------------------------------------------------------------- */
|
|
5
|
+
import { isDocumentedLocalExportList } from './require-function-doc-local-exports.js';
|
|
6
|
+
import { isInsideIgnoredText } from './require-function-doc-ignored-text.js';
|
|
7
|
+
const CHAR_CODE_SPACE = 32;
|
|
8
|
+
const CHAR_CODE_TAB = 9;
|
|
9
|
+
const CHAR_CODE_NEWLINE = 10;
|
|
10
|
+
const CHAR_CODE_CARRIAGE_RETURN = 13;
|
|
11
|
+
const CHAR_CODE_ASTERISK = 42;
|
|
12
|
+
const CHAR_CODE_SLASH = 47;
|
|
13
|
+
const CHAR_CODE_HASH = 35;
|
|
14
|
+
const CHAR_CODE_AT_SIGN = 64;
|
|
15
|
+
const CHAR_CODE_OPEN_PAREN = 40;
|
|
16
|
+
const CHAR_CODE_OPEN_BRACE = 123;
|
|
17
|
+
const CHAR_CODE_SEMICOLON = 59;
|
|
18
|
+
const CHAR_CODE_LESS_THAN = 60;
|
|
19
|
+
const CHAR_CODE_LOWER_A = 97;
|
|
20
|
+
const CHAR_CODE_LOWER_C = 99;
|
|
21
|
+
const CHAR_CODE_LOWER_D = 100;
|
|
22
|
+
const CHAR_CODE_LOWER_E = 101;
|
|
23
|
+
const CHAR_CODE_LOWER_F = 102;
|
|
24
|
+
const CHAR_CODE_LOWER_I = 105;
|
|
25
|
+
const CHAR_CODE_LOWER_L = 108;
|
|
26
|
+
const CHAR_CODE_LOWER_N = 110;
|
|
27
|
+
const CHAR_CODE_LOWER_T = 116;
|
|
28
|
+
const CHAR_CODE_LOWER_V = 118;
|
|
29
|
+
const CHAR_CODE_UPPER_C = 67;
|
|
30
|
+
const CHAR_CODE_UPPER_E = 69;
|
|
31
|
+
const CHAR_CODE_UPPER_F = 70;
|
|
32
|
+
const CHAR_CODE_UPPER_I = 73;
|
|
33
|
+
const CHAR_CODE_UPPER_L = 76;
|
|
34
|
+
const CHAR_CODE_UPPER_N = 78;
|
|
35
|
+
const CHAR_CODE_UPPER_V = 86;
|
|
36
|
+
const ASYNC_KEYWORD_LENGTH = 'async '.length;
|
|
37
|
+
const TYPE_KEYWORD_LENGTH = 'type '.length;
|
|
38
|
+
const EXPORT_KEYWORD_LENGTH = 'export '.length;
|
|
39
|
+
const DEFAULT_KEYWORD_LENGTH = 'default '.length;
|
|
40
|
+
const DECLARE_KEYWORD_LENGTH = 'declare '.length;
|
|
41
|
+
const ABSTRACT_KEYWORD_LENGTH = 'abstract '.length;
|
|
42
|
+
const isWhitespace = (code) => code === CHAR_CODE_SPACE ||
|
|
43
|
+
code === CHAR_CODE_TAB ||
|
|
44
|
+
code === CHAR_CODE_NEWLINE ||
|
|
45
|
+
code === CHAR_CODE_CARRIAGE_RETURN;
|
|
46
|
+
const lineEndFor = (source, lineStart, len) => {
|
|
47
|
+
const newlineIndex = source.indexOf('\n', lineStart);
|
|
48
|
+
if (newlineIndex === -1) {
|
|
49
|
+
return len;
|
|
38
50
|
}
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
return newlineIndex;
|
|
52
|
+
};
|
|
53
|
+
const skipLinePrefix = (source, pos, lineEnd) => {
|
|
54
|
+
let cursor = pos;
|
|
55
|
+
while (cursor < lineEnd && isWhitespace(source.charCodeAt(cursor))) {
|
|
56
|
+
cursor++;
|
|
57
|
+
}
|
|
58
|
+
if (cursor < lineEnd && source.charCodeAt(cursor) === CHAR_CODE_ASTERISK) {
|
|
59
|
+
cursor++;
|
|
60
|
+
}
|
|
61
|
+
while (cursor < lineEnd && isWhitespace(source.charCodeAt(cursor))) {
|
|
62
|
+
cursor++;
|
|
41
63
|
}
|
|
42
|
-
|
|
64
|
+
return cursor;
|
|
65
|
+
};
|
|
66
|
+
const isJSDocTagLine = (source, pos, lineEnd) => pos < lineEnd && source.charCodeAt(pos) === CHAR_CODE_AT_SIGN;
|
|
67
|
+
const lineHasDescriptionContent = (source, lineStart, lineEnd) => {
|
|
68
|
+
let pos = skipLinePrefix(source, lineStart, lineEnd);
|
|
69
|
+
if (isJSDocTagLine(source, pos, lineEnd)) {
|
|
43
70
|
return false;
|
|
44
71
|
}
|
|
45
|
-
|
|
72
|
+
while (pos < lineEnd) {
|
|
73
|
+
if (!isWhitespace(source.charCodeAt(pos))) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
pos++;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
};
|
|
80
|
+
const nextDescriptionLineStart = (newlineIndex) => {
|
|
81
|
+
if (newlineIndex === -1) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
return newlineIndex + 1;
|
|
85
|
+
};
|
|
86
|
+
const hasDescriptionLine = (jsdocBody, lineStart, len) => {
|
|
87
|
+
const newlineIndex = jsdocBody.indexOf('\n', lineStart);
|
|
88
|
+
const lineEnd = lineEndFor(jsdocBody, lineStart, len);
|
|
89
|
+
if (lineHasDescriptionContent(jsdocBody, lineStart, lineEnd)) {
|
|
90
|
+
return { found: true };
|
|
91
|
+
}
|
|
92
|
+
return { found: false, nextLineStart: nextDescriptionLineStart(newlineIndex) };
|
|
93
|
+
};
|
|
94
|
+
const hasDescriptionContent = (jsdocBody) => {
|
|
95
|
+
let lineStart = 0;
|
|
96
|
+
const len = jsdocBody.length;
|
|
97
|
+
while (lineStart <= len) {
|
|
98
|
+
const result = hasDescriptionLine(jsdocBody, lineStart, len);
|
|
99
|
+
if (result.found) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
if (result.nextLineStart === undefined) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
lineStart = result.nextLineStart;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
};
|
|
109
|
+
const skipWhitespaceBack = (source, pos) => {
|
|
110
|
+
let cursor = pos;
|
|
111
|
+
while (cursor > 0 && isWhitespace(source.charCodeAt(cursor - 1))) {
|
|
112
|
+
cursor--;
|
|
113
|
+
}
|
|
114
|
+
return cursor;
|
|
115
|
+
};
|
|
116
|
+
const hasBlockCommentCloseAt = (source, pos) => pos >= '*/'.length &&
|
|
117
|
+
source.charCodeAt(pos - '*/'.length) === CHAR_CODE_ASTERISK &&
|
|
118
|
+
source.charCodeAt(pos - 1) === CHAR_CODE_SLASH;
|
|
119
|
+
const jsdocContentBeforeClose = (source, open, closeStar) => {
|
|
120
|
+
if (open + 1 < closeStar && source.charCodeAt(open + 1) === CHAR_CODE_ASTERISK) {
|
|
121
|
+
return source.slice(open + '/**'.length, closeStar).trim();
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
};
|
|
125
|
+
const previousJSDocContent = (source, closeStar) => {
|
|
46
126
|
let open = closeStar - 1;
|
|
47
127
|
while (open > 0) {
|
|
48
|
-
if (source.charCodeAt(open) ===
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
128
|
+
if (source.charCodeAt(open) === CHAR_CODE_ASTERISK &&
|
|
129
|
+
source.charCodeAt(open - 1) === CHAR_CODE_SLASH) {
|
|
130
|
+
const content = jsdocContentBeforeClose(source, open, closeStar);
|
|
131
|
+
if (content !== undefined) {
|
|
132
|
+
return content;
|
|
52
133
|
}
|
|
53
|
-
open -=
|
|
54
|
-
|
|
134
|
+
open -= '/*'.length;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
open--;
|
|
55
138
|
}
|
|
56
|
-
open--;
|
|
57
139
|
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
140
|
+
return undefined;
|
|
141
|
+
};
|
|
142
|
+
const hasJSDocBefore = (source, exportPOS) => {
|
|
143
|
+
const pos = skipWhitespaceBack(source, exportPOS);
|
|
144
|
+
if (!hasBlockCommentCloseAt(source, pos)) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const closeStar = pos - '*/'.length;
|
|
148
|
+
const content = previousJSDocContent(source, closeStar);
|
|
149
|
+
return content !== undefined && hasDescriptionContent(content);
|
|
150
|
+
};
|
|
151
|
+
const endsWithWord = (source, pos, word) => {
|
|
61
152
|
const end = pos + word.length;
|
|
62
153
|
if (end > source.length) {
|
|
63
154
|
return false;
|
|
@@ -69,200 +160,295 @@ function endsWithWord(source, pos, word) {
|
|
|
69
160
|
return true;
|
|
70
161
|
}
|
|
71
162
|
const next = source.charCodeAt(end);
|
|
72
|
-
return isWhitespace(next) ||
|
|
73
|
-
|
|
74
|
-
|
|
163
|
+
return (isWhitespace(next) ||
|
|
164
|
+
next === CHAR_CODE_OPEN_PAREN ||
|
|
165
|
+
next === CHAR_CODE_OPEN_BRACE ||
|
|
166
|
+
next === CHAR_CODE_SEMICOLON ||
|
|
167
|
+
next === CHAR_CODE_LESS_THAN);
|
|
168
|
+
};
|
|
169
|
+
const isDefaultDeclaration = (source, pos, _len) => {
|
|
75
170
|
const ch = source.charCodeAt(pos);
|
|
76
|
-
if (ch ===
|
|
171
|
+
if (ch === CHAR_CODE_LOWER_F) {
|
|
77
172
|
return endsWithWord(source, pos, 'function');
|
|
78
173
|
}
|
|
79
|
-
if (ch ===
|
|
174
|
+
if (ch === CHAR_CODE_LOWER_C) {
|
|
80
175
|
return endsWithWord(source, pos, 'class');
|
|
81
176
|
}
|
|
82
|
-
if (ch ===
|
|
177
|
+
if (ch === CHAR_CODE_LOWER_I) {
|
|
83
178
|
return endsWithWord(source, pos, 'interface');
|
|
84
179
|
}
|
|
85
180
|
return false;
|
|
86
|
-
}
|
|
181
|
+
};
|
|
87
182
|
const AMBIENT_DECLARE_PREFIXES = ['declare module', 'declare namespace', 'declare global'];
|
|
88
|
-
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return false;
|
|
183
|
+
const skipShebangComments = (source, idx) => {
|
|
184
|
+
let cursor = idx;
|
|
185
|
+
while (cursor < source.length && source.charCodeAt(cursor) === CHAR_CODE_HASH) {
|
|
186
|
+
cursor = source.indexOf('\n', cursor);
|
|
187
|
+
if (cursor === -1) {
|
|
188
|
+
return undefined;
|
|
95
189
|
}
|
|
96
|
-
|
|
190
|
+
cursor++;
|
|
191
|
+
}
|
|
192
|
+
return cursor;
|
|
193
|
+
};
|
|
194
|
+
const skipBlockComment = (source, idx) => {
|
|
195
|
+
const close = source.indexOf('*/', idx + '/*'.length);
|
|
196
|
+
if (close === -1) {
|
|
197
|
+
return undefined;
|
|
97
198
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
199
|
+
return close + '*/'.length;
|
|
200
|
+
};
|
|
201
|
+
const skipLineComment = (source, idx) => {
|
|
202
|
+
const nl = source.indexOf('\n', idx);
|
|
203
|
+
if (nl === -1) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
return nl + 1;
|
|
207
|
+
};
|
|
208
|
+
const skipTriviaToken = (source, idx) => {
|
|
209
|
+
const ch = source.charCodeAt(idx);
|
|
210
|
+
if (isWhitespace(ch)) {
|
|
211
|
+
return idx + 1;
|
|
212
|
+
}
|
|
213
|
+
if (ch === CHAR_CODE_SLASH &&
|
|
214
|
+
idx + 1 < source.length &&
|
|
215
|
+
source.charCodeAt(idx + 1) === CHAR_CODE_ASTERISK) {
|
|
216
|
+
return skipBlockComment(source, idx);
|
|
217
|
+
}
|
|
218
|
+
if (ch === CHAR_CODE_SLASH &&
|
|
219
|
+
idx + 1 < source.length &&
|
|
220
|
+
source.charCodeAt(idx + 1) === CHAR_CODE_SLASH) {
|
|
221
|
+
return skipLineComment(source, idx);
|
|
222
|
+
}
|
|
223
|
+
return idx;
|
|
224
|
+
};
|
|
225
|
+
const skipLeadingTrivia = (source, idx) => {
|
|
226
|
+
let cursor = idx;
|
|
227
|
+
while (cursor < source.length) {
|
|
228
|
+
const next = skipTriviaToken(source, cursor);
|
|
229
|
+
if (next === undefined) {
|
|
230
|
+
return undefined;
|
|
103
231
|
}
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
if (close !== -1) {
|
|
107
|
-
idx = close + 2;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
return false;
|
|
232
|
+
if (next === cursor) {
|
|
233
|
+
return cursor;
|
|
111
234
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
235
|
+
cursor = next;
|
|
236
|
+
}
|
|
237
|
+
return cursor;
|
|
238
|
+
};
|
|
239
|
+
const hasAmbientPrefixAt = (source, idx) => AMBIENT_DECLARE_PREFIXES.some((prefix) => idx + prefix.length <= source.length && source.slice(idx, idx + prefix.length) === prefix);
|
|
240
|
+
const isAmbientDeclarationFile = (source) => {
|
|
241
|
+
const shebangEnd = skipShebangComments(source, 0);
|
|
242
|
+
if (shebangEnd === undefined) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
const idx = skipLeadingTrivia(source, shebangEnd);
|
|
246
|
+
if (idx === undefined || idx >= source.length) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
return hasAmbientPrefixAt(source, idx);
|
|
250
|
+
};
|
|
251
|
+
const nextExportPosition = (source, start) => {
|
|
252
|
+
const exp = source.indexOf('export ', start);
|
|
253
|
+
if (exp === -1) {
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
return exp;
|
|
257
|
+
};
|
|
258
|
+
const isStandaloneExportKeyword = (source, exp) => {
|
|
259
|
+
if (exp === 0) {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
return isWhitespace(source.charCodeAt(exp - 1));
|
|
263
|
+
};
|
|
264
|
+
const isDeclareExport = (source, exp) => exp >= DECLARE_KEYWORD_LENGTH && source.slice(exp - DECLARE_KEYWORD_LENGTH, exp) === 'declare ';
|
|
265
|
+
const skipWhitespace = (source, pos) => {
|
|
266
|
+
let cursor = pos;
|
|
267
|
+
while (cursor < source.length && isWhitespace(source.charCodeAt(cursor))) {
|
|
268
|
+
cursor++;
|
|
269
|
+
}
|
|
270
|
+
return cursor;
|
|
271
|
+
};
|
|
272
|
+
const isReExportAt = (source, afterExport) => {
|
|
273
|
+
if (afterExport >= source.length) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
const c0 = source.charCodeAt(afterExport);
|
|
277
|
+
if (c0 === CHAR_CODE_OPEN_BRACE || c0 === CHAR_CODE_ASTERISK) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
if (c0 !== CHAR_CODE_LOWER_T ||
|
|
281
|
+
afterExport + TYPE_KEYWORD_LENGTH > source.length ||
|
|
282
|
+
source.slice(afterExport, afterExport + TYPE_KEYWORD_LENGTH) !== 'type ') {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
const afterType = afterExport + TYPE_KEYWORD_LENGTH;
|
|
286
|
+
return afterType < source.length && source.charCodeAt(afterType) === CHAR_CODE_OPEN_BRACE;
|
|
287
|
+
};
|
|
288
|
+
const modifierSpecs = [
|
|
289
|
+
{
|
|
290
|
+
charCode: CHAR_CODE_LOWER_D,
|
|
291
|
+
isDefault: true,
|
|
292
|
+
length: DEFAULT_KEYWORD_LENGTH,
|
|
293
|
+
shouldStop: false,
|
|
294
|
+
text: 'default ',
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
charCode: CHAR_CODE_LOWER_A,
|
|
298
|
+
isDefault: false,
|
|
299
|
+
length: ASYNC_KEYWORD_LENGTH,
|
|
300
|
+
shouldStop: false,
|
|
301
|
+
text: 'async ',
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
charCode: CHAR_CODE_LOWER_A,
|
|
305
|
+
isDefault: false,
|
|
306
|
+
length: ABSTRACT_KEYWORD_LENGTH,
|
|
307
|
+
shouldStop: false,
|
|
308
|
+
text: 'abstract ',
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
charCode: CHAR_CODE_LOWER_T,
|
|
312
|
+
isDefault: false,
|
|
313
|
+
length: TYPE_KEYWORD_LENGTH,
|
|
314
|
+
shouldStop: false,
|
|
315
|
+
text: 'type ',
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
charCode: CHAR_CODE_LOWER_N,
|
|
319
|
+
isDefault: false,
|
|
320
|
+
length: 0,
|
|
321
|
+
shouldStop: true,
|
|
322
|
+
text: 'namespace ',
|
|
323
|
+
},
|
|
324
|
+
];
|
|
325
|
+
const modifierSpecMatches = (source, pos, spec) => source.charCodeAt(pos) === spec.charCode &&
|
|
326
|
+
pos + spec.text.length <= source.length &&
|
|
327
|
+
source.slice(pos, pos + spec.text.length) === spec.text;
|
|
328
|
+
const modifierLengthAt = (source, pos) => {
|
|
329
|
+
for (const spec of modifierSpecs) {
|
|
330
|
+
if (modifierSpecMatches(source, pos, spec)) {
|
|
331
|
+
return spec;
|
|
119
332
|
}
|
|
120
|
-
break;
|
|
121
333
|
}
|
|
122
|
-
|
|
334
|
+
return undefined;
|
|
335
|
+
};
|
|
336
|
+
const scanExportModifiers = (source, start) => {
|
|
337
|
+
let pos = start;
|
|
338
|
+
let hasSawDefault = false;
|
|
339
|
+
let modifier = modifierLengthAt(source, pos);
|
|
340
|
+
while (modifier && !modifier.shouldStop) {
|
|
341
|
+
hasSawDefault ||= modifier.isDefault;
|
|
342
|
+
pos = skipWhitespace(source, pos + modifier.length);
|
|
343
|
+
modifier = modifierLengthAt(source, pos);
|
|
344
|
+
}
|
|
345
|
+
return { hasSawDefault, pos };
|
|
346
|
+
};
|
|
347
|
+
const declarationStartCodes = new Set([
|
|
348
|
+
CHAR_CODE_LOWER_F,
|
|
349
|
+
CHAR_CODE_UPPER_F,
|
|
350
|
+
CHAR_CODE_LOWER_C,
|
|
351
|
+
CHAR_CODE_UPPER_C,
|
|
352
|
+
CHAR_CODE_LOWER_I,
|
|
353
|
+
CHAR_CODE_UPPER_I,
|
|
354
|
+
CHAR_CODE_LOWER_E,
|
|
355
|
+
CHAR_CODE_UPPER_E,
|
|
356
|
+
CHAR_CODE_LOWER_L,
|
|
357
|
+
CHAR_CODE_UPPER_L,
|
|
358
|
+
CHAR_CODE_LOWER_V,
|
|
359
|
+
CHAR_CODE_UPPER_V,
|
|
360
|
+
CHAR_CODE_LOWER_N,
|
|
361
|
+
CHAR_CODE_UPPER_N,
|
|
362
|
+
]);
|
|
363
|
+
const isDeclarationStartCode = (code) => declarationStartCodes.has(code);
|
|
364
|
+
const canSkipDocumentedExport = (source, modifiers) => {
|
|
365
|
+
if (modifiers.pos >= source.length) {
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
const next = source.charCodeAt(modifiers.pos);
|
|
369
|
+
if (!isDeclarationStartCode(next)) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
return modifiers.hasSawDefault && !isDefaultDeclaration(source, modifiers.pos, source.length);
|
|
373
|
+
};
|
|
374
|
+
const documentedLocalExportListResult = (source, after, exp) => isDocumentedLocalExportList(source, after, exp, hasJSDocBefore);
|
|
375
|
+
const exhaustedExportDocResult = (source, after) => {
|
|
376
|
+
if (after >= source.length) {
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
return undefined;
|
|
380
|
+
};
|
|
381
|
+
const earlyExportDocResult = (source, after, exp) => {
|
|
382
|
+
const exhaustedExport = exhaustedExportDocResult(source, after);
|
|
383
|
+
if (exhaustedExport !== undefined) {
|
|
384
|
+
return exhaustedExport;
|
|
385
|
+
}
|
|
386
|
+
const localExportList = documentedLocalExportListResult(source, after, exp);
|
|
387
|
+
if (localExportList !== undefined) {
|
|
388
|
+
return localExportList;
|
|
389
|
+
}
|
|
390
|
+
if (isReExportAt(source, after)) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
return undefined;
|
|
394
|
+
};
|
|
395
|
+
const isDocumentedExportDeclaration = (source, exp) => {
|
|
396
|
+
const after = skipWhitespace(source, exp + EXPORT_KEYWORD_LENGTH);
|
|
397
|
+
const earlyResult = earlyExportDocResult(source, after, exp);
|
|
398
|
+
if (earlyResult !== undefined) {
|
|
399
|
+
return earlyResult;
|
|
400
|
+
}
|
|
401
|
+
const modifiers = scanExportModifiers(source, after);
|
|
402
|
+
if (canSkipDocumentedExport(source, modifiers)) {
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
return hasJSDocBefore(source, exp);
|
|
406
|
+
};
|
|
407
|
+
const isUndocumentedExportAt = (source, exp) => {
|
|
408
|
+
if (isInsideIgnoredText(source, exp) ||
|
|
409
|
+
!isStandaloneExportKeyword(source, exp) ||
|
|
410
|
+
isDeclareExport(source, exp)) {
|
|
123
411
|
return false;
|
|
124
412
|
}
|
|
125
|
-
|
|
126
|
-
|
|
413
|
+
return isDocumentedExportDeclaration(source, exp) === false;
|
|
414
|
+
};
|
|
415
|
+
const nextExportSearchPosition = (source, pos) => {
|
|
416
|
+
const exp = nextExportPosition(source, pos);
|
|
417
|
+
if (exp === undefined) {
|
|
418
|
+
return undefined;
|
|
419
|
+
}
|
|
420
|
+
return {
|
|
421
|
+
nextPOS: exp + EXPORT_KEYWORD_LENGTH,
|
|
422
|
+
undocumented: isUndocumentedExportAt(source, exp),
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
const hasUndocumentedExport = (source) => {
|
|
426
|
+
let pos = 0;
|
|
427
|
+
while (pos < source.length) {
|
|
428
|
+
const exportSearch = nextExportSearchPosition(source, pos);
|
|
429
|
+
if (!exportSearch) {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
if (exportSearch.undocumented) {
|
|
127
433
|
return true;
|
|
128
434
|
}
|
|
435
|
+
pos = exportSearch.nextPOS;
|
|
129
436
|
}
|
|
130
437
|
return false;
|
|
131
|
-
}
|
|
438
|
+
};
|
|
132
439
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
440
|
+
* Checks whether exported declarations have meaningful JSDoc comments.
|
|
441
|
+
*
|
|
442
|
+
* @param source - TypeScript source text to inspect.
|
|
443
|
+
* @returns True when every public declaration is documented or no public declarations exist.
|
|
136
444
|
*/
|
|
137
445
|
export default function hasRequiredFunctionDocs(source) {
|
|
138
|
-
|
|
139
|
-
if (isAmbientDeclarationFile(source)) {
|
|
446
|
+
if (!source.includes('export ')) {
|
|
140
447
|
return true;
|
|
141
448
|
}
|
|
142
|
-
|
|
143
|
-
const exportPositions = [];
|
|
144
|
-
while (pos < len) {
|
|
145
|
-
const exp = source.indexOf('export ', pos);
|
|
146
|
-
if (exp === -1) {
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
if (exp > 0) {
|
|
150
|
-
const prev = source.charCodeAt(exp - 1);
|
|
151
|
-
if (prev !== 10 && prev !== 13 && prev !== 9 && prev !== 32) {
|
|
152
|
-
pos = exp + 1;
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
if (exp >= 8 && source.slice(exp - 8, exp) === 'declare ') {
|
|
156
|
-
pos = exp + 7;
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
let after = exp + 7;
|
|
161
|
-
while (after < len && isWhitespace(source.charCodeAt(after))) {
|
|
162
|
-
after++;
|
|
163
|
-
}
|
|
164
|
-
if (after >= len) {
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
const c0 = source.charCodeAt(after);
|
|
168
|
-
// Re-export block: export { ... }
|
|
169
|
-
if (c0 === 123) {
|
|
170
|
-
pos = exp + 7;
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
// Wildcard re-export: export *
|
|
174
|
-
if (c0 === 42) {
|
|
175
|
-
pos = exp + 7;
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
// Type re-export: export type { ... }
|
|
179
|
-
if (c0 === 116 && after + 5 <= len && source.slice(after, after + 5) === 'type ') {
|
|
180
|
-
const afterType = after + 5;
|
|
181
|
-
if (afterType < len && source.charCodeAt(afterType) === 123) {
|
|
182
|
-
pos = afterType;
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
let afterMod = after;
|
|
187
|
-
let changed = true;
|
|
188
|
-
let sawDefault = false;
|
|
189
|
-
while (changed && afterMod < len) {
|
|
190
|
-
changed = false;
|
|
191
|
-
const ch = source.charCodeAt(afterMod);
|
|
192
|
-
if (ch === 100 &&
|
|
193
|
-
afterMod + 8 <= len &&
|
|
194
|
-
source.slice(afterMod, afterMod + 8) === 'default ') {
|
|
195
|
-
afterMod += 8;
|
|
196
|
-
changed = true;
|
|
197
|
-
sawDefault = true;
|
|
198
|
-
}
|
|
199
|
-
else if (ch === 97 &&
|
|
200
|
-
afterMod + 6 <= len &&
|
|
201
|
-
source.slice(afterMod, afterMod + 6) === 'async ') {
|
|
202
|
-
afterMod += 6;
|
|
203
|
-
changed = true;
|
|
204
|
-
}
|
|
205
|
-
else if (ch === 97 &&
|
|
206
|
-
afterMod + 9 <= len &&
|
|
207
|
-
source.slice(afterMod, afterMod + 9) === 'abstract ') {
|
|
208
|
-
afterMod += 9;
|
|
209
|
-
changed = true;
|
|
210
|
-
}
|
|
211
|
-
else if (ch === 116 &&
|
|
212
|
-
afterMod + 5 <= len &&
|
|
213
|
-
source.slice(afterMod, afterMod + 5) === 'type ') {
|
|
214
|
-
afterMod += 5;
|
|
215
|
-
changed = true;
|
|
216
|
-
}
|
|
217
|
-
else if (ch === 110 &&
|
|
218
|
-
afterMod + 10 <= len &&
|
|
219
|
-
source.slice(afterMod, afterMod + 10) === 'namespace ') {
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
if (changed) {
|
|
223
|
-
while (afterMod < len && isWhitespace(source.charCodeAt(afterMod))) {
|
|
224
|
-
afterMod++;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (afterMod >= len) {
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
const next = source.charCodeAt(afterMod);
|
|
232
|
-
// Declaration keyword check (case-insensitive first character):
|
|
233
|
-
// First chars: f/F=function, c/C=class|const, i/I=interface, e/E=enum, l/L=let, v/V=var, n/N=namespace
|
|
234
|
-
if (next === 102 ||
|
|
235
|
-
next === 70 ||
|
|
236
|
-
next === 99 ||
|
|
237
|
-
next === 67 ||
|
|
238
|
-
next === 105 ||
|
|
239
|
-
next === 73 ||
|
|
240
|
-
next === 101 ||
|
|
241
|
-
next === 69 ||
|
|
242
|
-
next === 108 ||
|
|
243
|
-
next === 76 ||
|
|
244
|
-
next === 118 ||
|
|
245
|
-
next === 86 ||
|
|
246
|
-
next === 110 ||
|
|
247
|
-
next === 78) {
|
|
248
|
-
if (sawDefault) {
|
|
249
|
-
if (!isDefaultDeclaration(source, afterMod, len)) {
|
|
250
|
-
pos = exp + 7;
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
exportPositions.push(exp);
|
|
255
|
-
}
|
|
256
|
-
pos = exp + 7;
|
|
257
|
-
}
|
|
258
|
-
if (exportPositions.length === 0) {
|
|
449
|
+
if (isAmbientDeclarationFile(source)) {
|
|
259
450
|
return true;
|
|
260
451
|
}
|
|
261
|
-
|
|
262
|
-
if (!hasJSDocBefore(source, exportPositions[idx])) {
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return true;
|
|
452
|
+
return !hasUndocumentedExport(source);
|
|
267
453
|
}
|
|
268
454
|
//# sourceMappingURL=require-function-doc.js.map
|