You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/_tools/eslint/rules/tsdoc-doctest/README.md
+5-15Lines changed: 5 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,15 +40,6 @@ var rule = require( '@stdlib/_tools/eslint/rules/tsdoc-doctest' );
40
40
41
41
[ESLint rule][eslint-rules] to ensure that return annotations in TSDoc examples match the actual output. The rule validates `@example` blocks in TSDoc comments within `.d.ts` files.
42
42
43
-
The rule:
44
-
45
-
- Extracts `@example` blocks from TSDoc comments in TypeScript declaration files
46
-
- Loads the actual JavaScript package corresponding to the declaration file
47
-
- Executes the example code in a sandboxed environment
48
-
- Compares the actual output with the expected return annotations
49
-
- Supports functions, constants, classes, and namespace objects
50
-
- Handles `// returns`, `// throws`, and `// =>` annotations
51
-
52
43
**Bad**:
53
44
54
45
<!-- eslint-disable stdlib/tsdoc-doctest -->
@@ -140,9 +131,7 @@ var result = linter.verify( code, {
- The rule requires that the TypeScript declaration file path follows the stdlib convention: `lib/node_modules/@stdlib/<package>/docs/types/index.d.ts`
170
158
- The corresponding JavaScript package must be loadable via `require('@stdlib/<package>')`
171
-
- The rule skips validation if the package cannot be loaded
172
-
- Examples are executed in a sandboxed VM context with limited globals
159
+
- The rule skips validation if the package cannot be loaded.
160
+
- Examples are executed in a sandboxed VM context with limited globals.
161
+
- The rule validates assignment-form examples (e.g., `var x = fn(...);` followed by an annotation). It does not validate console output or expression-only forms using `// =>`.
162
+
- The implementation path the rule uses to load the JavaScript implementation can be overridden via the `implementationPath` rule option (default: `../../lib` relative to the declaration file).
0 commit comments