Skip to content

Commit 70eb0f4

Browse files
committed
review changes
1 parent fab81c4 commit 70eb0f4

File tree

14 files changed

+95
-47
lines changed

14 files changed

+95
-47
lines changed

.eslintrc.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,13 @@ overrides:
453453
extends:
454454
- plugin:import/typescript
455455
rules:
456+
##########################################################################
457+
# `eslint-plugin-tsdoc` rule list based on `v0.2.x`
458+
# https://github.com/microsoft/tsdoc/tree/master/eslint-plugin
459+
##########################################################################
460+
461+
tsdoc/syntax: error
462+
456463
##########################################################################
457464
# `@typescript-eslint/eslint-plugin` rule list based on `v4.25.x`
458465
##########################################################################
@@ -615,11 +622,6 @@ overrides:
615622
- files: 'src/**'
616623
rules:
617624
internal-rules/require-to-string-tag: error
618-
619-
# Validating TS Doc comments. see:
620-
# https://tsdoc.org/pages/packages/eslint-plugin-tsdoc/
621-
'tsdoc/syntax': error
622-
623625
- files: 'src/**/__*__/**'
624626
rules:
625627
internal-rules/require-to-string-tag: off

src/__testUtils__/dedent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function dedentString(string: string): string {
1818
/**
1919
* An ES6 string tag that fixes indentation and also trims string.
2020
*
21-
* Example Usage:
21+
* Example usage:
2222
* ```ts
2323
* const str = dedent`
2424
* {

src/__tests__/starWarsSchema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import { getFriends, getHero, getHuman, getDroid } from './starWarsData';
5959
* droid(id: String!): Droid
6060
* }
6161
* ```
62+
*
6263
* We begin by setting up our schema.
6364
*/
6465

src/error/formatError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function formatError(error: GraphQLError): GraphQLFormattedError {
2121
}
2222

2323
/**
24-
* @see {@link https://github.com/graphql/graphql-spec/blob/main/spec/Section%207%20--%20Response.md#errors | Errors}
24+
* See: https://spec.graphql.org/draft/#sec-Errors
2525
*/
2626
export interface GraphQLFormattedError {
2727
/**

src/execution/execute.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ import {
8282
*
8383
* "Selections" are the definitions that can appear legally and at
8484
* single level of the query. These include:
85-
* 1) field references e.g `"a"`
86-
* 2) fragment "spreads" e.g. `"...c"`
87-
* 3) inline fragment "spreads" e.g. `"...on Type { a }"`
85+
* 1) field references e.g `a`
86+
* 2) fragment "spreads" e.g. `...c`
87+
* 3) inline fragment "spreads" e.g. `...on Type { a }`
8888
*/
8989

9090
/**

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
* This also includes utility functions for operating on GraphQL types and
1616
* GraphQL documents to facilitate building tools.
1717
*
18-
* You may also import from each sub-directory directly.
19-
* the following two import statements are equivalent:
18+
* You may also import from each sub-directory directly. For example, the
19+
* following two import statements are equivalent:
20+
*
2021
* ```ts
2122
* import { parse } from 'graphql';
2223
* import { parse } from 'graphql/language';

src/jsutils/keyMap.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ import type { ObjMap } from './ObjMap';
1212
* { name: 'Jenny', num: '867-5309' }
1313
* ]
1414
*
15-
* // { Jon: { name: 'Jon', num: '555-1234' },
16-
* // Jenny: { name: 'Jenny', num: '867-5309' } }
1715
* const entriesByName = keyMap(
1816
* phoneBook,
1917
* entry => entry.name
2018
* )
2119
*
22-
* // { name: 'Jenny', num: '857-6309' }
20+
* // {
21+
* // Jon: { name: 'Jon', num: '555-1234' },
22+
* // Jenny: { name: 'Jenny', num: '867-5309' }
23+
* // }
24+
*
2325
* const jennyEntry = entriesByName['Jenny']
26+
*
27+
* // { name: 'Jenny', num: '857-6309' }
2428
* ```
2529
*/
2630
export function keyMap<T>(

src/language/lexer.ts

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,22 @@ export function isPunctuatorTokenKind(kind: TokenKindEnum): boolean {
107107
);
108108
}
109109

110-
/*
110+
/**
111+
* ```
111112
* SourceCharacter ::
112113
* - U+0009 (Horizontal Tab)
113114
* - U+000A (New Line)
114115
* - U+000D (Carriage Return)
115116
* - U+0020-U+FFFF
117+
* ```
116118
*/
117119
function isSourceCharacter(code: number): boolean {
118120
return (
119121
code >= 0x0020 || code === 0x0009 || code === 0x000a || code === 0x000d
120122
);
121123
}
122124

123-
/*
125+
/**
124126
* Prints the code point (or end of file reference) at a given location in a
125127
* source for use in error messages.
126128
*
@@ -143,7 +145,7 @@ function printCodePointAt(lexer: Lexer, location: number): string {
143145
return `U+${zeroPad}${code.toString(16).toUpperCase()}`;
144146
}
145147

146-
/*
148+
/**
147149
* Create a token with line and column location information.
148150
*/
149151
function createToken(
@@ -158,7 +160,7 @@ function createToken(
158160
return new Token(kind, start, end, line, col, value);
159161
}
160162

161-
/*
163+
/**
162164
* Gets the next token from the source starting at the given position.
163165
*
164166
* This skips over whitespace until it finds the next lexable token, then lexes
@@ -293,7 +295,7 @@ function readNextToken(lexer: Lexer, start: number): Token {
293295
return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);
294296
}
295297

296-
/*
298+
/**
297299
* Reads a comment token from the source file.
298300
*
299301
* ```
@@ -332,10 +334,11 @@ function readComment(lexer: Lexer, start: number): Token {
332334
);
333335
}
334336

335-
/*
337+
/**
336338
* Reads a number token from the source file, either a FloatValue or an IntValue
337339
* depending on whether a FractionalPart or ExponentPart is encountered.
338340
*
341+
* ```
339342
* IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]
340343
*
341344
* IntegerPart ::
@@ -358,6 +361,7 @@ function readComment(lexer: Lexer, start: number): Token {
358361
* ExponentIndicator :: one of `e` `E`
359362
*
360363
* Sign :: one of + -
364+
* ```
361365
*/
362366
function readNumber(lexer: Lexer, start: number, firstCode: number): Token {
363367
const body = lexer.source.body;
@@ -431,7 +435,7 @@ function readNumber(lexer: Lexer, start: number, firstCode: number): Token {
431435
);
432436
}
433437

434-
/*
438+
/**
435439
* Returns the new position in the source after reading one or more digits.
436440
*/
437441
function readDigits(lexer: Lexer, start: number, firstCode: number): number {
@@ -457,7 +461,7 @@ function readDigits(lexer: Lexer, start: number, firstCode: number): number {
457461
return position;
458462
}
459463

460-
/*
464+
/**
461465
* Reads a single-quote string token from the source file.
462466
*
463467
* ```
@@ -548,7 +552,7 @@ function readEscapedUnicode(lexer: Lexer, position: number): EscapeSequence {
548552
);
549553
}
550554

551-
/*
555+
/**
552556
* Reads four hexadecimal characters and returns the positive integer that 16bit
553557
* hexadecimal string represents. For example, "000f" will return 15, and "dead"
554558
* will return 57005.
@@ -566,7 +570,7 @@ function read16BitHexCode(body: string, position: number): number {
566570
);
567571
}
568572

569-
/*
573+
/**
570574
* Reads a hexadecimal character and returns its positive integer value (0-15).
571575
*
572576
* '0' becomes 0, '9' becomes 9
@@ -585,17 +589,17 @@ function readHexDigit(code: number): number {
585589
: -1;
586590
}
587591

588-
/*
592+
/**
589593
* | Escaped Character | Code Point | Character Name |
590594
* | ----------------- | ---------- | ---------------------------- |
591-
* | {`"`} | U+0022 | double quote |
592-
* | {`\`} | U+005C | reverse solidus (back slash) |
593-
* | {`/`} | U+002F | solidus (forward slash) |
594-
* | {`b`} | U+0008 | backspace |
595-
* | {`f`} | U+000C | form feed |
596-
* | {`n`} | U+000A | line feed (new line) |
597-
* | {`r`} | U+000D | carriage return |
598-
* | {`t`} | U+0009 | horizontal tab |
595+
* | `"` | U+0022 | double quote |
596+
* | `\` | U+005C | reverse solidus (back slash) |
597+
* | `/` | U+002F | solidus (forward slash) |
598+
* | `b` | U+0008 | backspace |
599+
* | `f` | U+000C | form feed |
600+
* | `n` | U+000A | line feed (new line) |
601+
* | `r` | U+000D | carriage return |
602+
* | `t` | U+0009 | horizontal tab |
599603
*/
600604
function readEscapedCharacter(lexer: Lexer, position: number): EscapeSequence {
601605
const body = lexer.source.body;
@@ -628,15 +632,17 @@ function readEscapedCharacter(lexer: Lexer, position: number): EscapeSequence {
628632
);
629633
}
630634

631-
/*
635+
/**
632636
* Reads a block string token from the source file.
633637
*
638+
* ```
634639
* StringValue ::
635640
* - `"""` BlockStringCharacter* `"""`
636641
*
637642
* BlockStringCharacter ::
638643
* - SourceCharacter but not `"""` or `\"""`
639644
* - `\"""`
645+
* ```
640646
*/
641647
function readBlockString(lexer: Lexer, start: number): Token {
642648
const body = lexer.source.body;
@@ -707,9 +713,10 @@ function readBlockString(lexer: Lexer, start: number): Token {
707713
throw syntaxError(lexer.source, position, 'Unterminated string.');
708714
}
709715

710-
/*
716+
/**
711717
* Reads an alphanumeric + underscore name from the source.
712718
*
719+
* ```
713720
* Name ::
714721
* - NameStart NameContinue* [lookahead != NameContinue]
715722
*
@@ -721,6 +728,7 @@ function readBlockString(lexer: Lexer, start: number): Token {
721728
* - Letter
722729
* - Digit
723730
* - `_`
731+
* ```
724732
*/
725733
function readName(lexer: Lexer, start: number): Token {
726734
const body = lexer.source.body;
@@ -750,20 +758,24 @@ function isNameStart(code: number): boolean {
750758
return isLetter(code) || code === 0x005f;
751759
}
752760

753-
/*
761+
/**
762+
* ```
754763
* Digit :: one of
755764
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
765+
* ```
756766
*/
757767
function isDigit(code: number): boolean {
758768
return code >= 0x0030 && code <= 0x0039;
759769
}
760770

761-
/*
771+
/**
772+
* ```
762773
* Letter :: one of
763774
* - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`
764775
* - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`
765776
* - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`
766777
* - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`
778+
* ```
767779
*/
768780
function isLetter(code: number): boolean {
769781
return (

src/language/printer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,7 @@ function join(
316316
}
317317

318318
/**
319-
* Given array, print each item on its own line, wrapped in an
320-
* indented `"{ }"` block.
319+
* Given array, print each item on its own line, wrapped in an indented `{ }` block.
321320
*/
322321
function block(array: Maybe<ReadonlyArray<string | undefined>>): string {
323322
return wrap('{\n', indent(join(array, '\n')), '\n}');

src/language/visitor.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export const BREAK: unknown = Object.freeze({});
178178
* a new version of the AST with the changes applied will be returned from the
179179
* visit function.
180180
*
181-
* ```
181+
* ```ts
182182
* const editedAST = visit(ast, {
183183
* enter(node, key, parent, path, ancestors) {
184184
* // @return
@@ -198,22 +198,25 @@ export const BREAK: unknown = Object.freeze({});
198198
* }
199199
* });
200200
* ```
201+
*
201202
* Alternatively to providing enter() and leave() functions, a visitor can
202203
* instead provide functions named the same as the kinds of AST nodes, or
203204
* enter/leave visitors at a named key, leading to three permutations of the
204205
* visitor API:
205206
*
206207
* 1) Named visitors triggered when entering a node of a specific kind.
207-
* ```
208+
*
209+
* ```ts
208210
* visit(ast, {
209211
* Kind(node) {
210212
* // enter the "Kind" node
211213
* }
212214
* })
213215
* ```
214-
* 2) Named visitors that trigger upon entering and leaving a node of
215-
* a specific kind.
216-
* ```
216+
*
217+
* 2) Named visitors that trigger upon entering and leaving a node of a specific kind.
218+
*
219+
* ```ts
217220
* visit(ast, {
218221
* Kind: {
219222
* enter(node) {
@@ -225,8 +228,10 @@ export const BREAK: unknown = Object.freeze({});
225228
* }
226229
* })
227230
* ```
231+
*
228232
* 3) Generic visitors that trigger upon entering and leaving any node.
229-
* ```
233+
*
234+
* ```ts
230235
* visit(ast, {
231236
* enter(node) {
232237
* // enter any node

0 commit comments

Comments
 (0)