Skip to content

Commit 0ecd247

Browse files
committed
review changes
1 parent 12b541b commit 0ecd247

File tree

14 files changed

+95
-46
lines changed

14 files changed

+95
-46
lines changed

.eslintrc.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,11 @@ overrides:
454454
- plugin:import/typescript
455455
rules:
456456
##########################################################################
457-
# Validating TS Doc comments
457+
# `eslint-plugin-tsdoc` rule list based on `v0.2.x`
458+
# https://github.com/microsoft/tsdoc/tree/master/eslint-plugin
458459
##########################################################################
459460

460-
# Supported Rules
461-
# https://tsdoc.org/pages/packages/eslint-plugin-tsdoc/
462-
'tsdoc/syntax': error
461+
tsdoc/syntax: error
463462

464463
##########################################################################
465464
# `@typescript-eslint/eslint-plugin` rule list based on `v4.25.x`

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: 39 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,12 +295,14 @@ 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
*
301+
* ```
299302
* Comment :: # CommentChar* [lookahead != CommentChar]
300303
*
301304
* CommentChar :: SourceCharacter but not LineTerminator
305+
* ```
302306
*/
303307
function readComment(lexer: Lexer, start: number): Token {
304308
const body = lexer.source.body;
@@ -330,10 +334,11 @@ function readComment(lexer: Lexer, start: number): Token {
330334
);
331335
}
332336

333-
/*
337+
/**
334338
* Reads a number token from the source file, either a FloatValue or an IntValue
335339
* depending on whether a FractionalPart or ExponentPart is encountered.
336340
*
341+
* ```
337342
* IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]
338343
*
339344
* IntegerPart ::
@@ -356,6 +361,7 @@ function readComment(lexer: Lexer, start: number): Token {
356361
* ExponentIndicator :: one of `e` `E`
357362
*
358363
* Sign :: one of + -
364+
* ```
359365
*/
360366
function readNumber(lexer: Lexer, start: number, firstCode: number): Token {
361367
const body = lexer.source.body;
@@ -429,7 +435,7 @@ function readNumber(lexer: Lexer, start: number, firstCode: number): Token {
429435
);
430436
}
431437

432-
/*
438+
/**
433439
* Returns the new position in the source after reading one or more digits.
434440
*/
435441
function readDigits(lexer: Lexer, start: number, firstCode: number): number {
@@ -455,9 +461,10 @@ function readDigits(lexer: Lexer, start: number, firstCode: number): number {
455461
return position;
456462
}
457463

458-
/*
464+
/**
459465
* Reads a single-quote string token from the source file.
460466
*
467+
* ```
461468
* StringValue ::
462469
* - `""` [lookahead != `"`]
463470
* - `"` StringCharacter+ `"`
@@ -470,6 +477,7 @@ function readDigits(lexer: Lexer, start: number, firstCode: number): number {
470477
* EscapedUnicode :: /[0-9A-Fa-f]{4}/
471478
*
472479
* EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t`
480+
* ```
473481
*/
474482
function readString(lexer: Lexer, start: number): Token {
475483
const body = lexer.source.body;
@@ -544,7 +552,7 @@ function readEscapedUnicode(lexer: Lexer, position: number): EscapeSequence {
544552
);
545553
}
546554

547-
/*
555+
/**
548556
* Reads four hexadecimal characters and returns the positive integer that 16bit
549557
* hexadecimal string represents. For example, "000f" will return 15, and "dead"
550558
* will return 57005.
@@ -562,7 +570,7 @@ function read16BitHexCode(body: string, position: number): number {
562570
);
563571
}
564572

565-
/*
573+
/**
566574
* Reads a hexadecimal character and returns its positive integer value (0-15).
567575
*
568576
* '0' becomes 0, '9' becomes 9
@@ -581,17 +589,17 @@ function readHexDigit(code: number): number {
581589
: -1;
582590
}
583591

584-
/*
592+
/**
585593
* | Escaped Character | Code Point | Character Name |
586594
* | ----------------- | ---------- | ---------------------------- |
587-
* | {`"`} | U+0022 | double quote |
588-
* | {`\`} | U+005C | reverse solidus (back slash) |
589-
* | {`/`} | U+002F | solidus (forward slash) |
590-
* | {`b`} | U+0008 | backspace |
591-
* | {`f`} | U+000C | form feed |
592-
* | {`n`} | U+000A | line feed (new line) |
593-
* | {`r`} | U+000D | carriage return |
594-
* | {`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 |
595603
*/
596604
function readEscapedCharacter(lexer: Lexer, position: number): EscapeSequence {
597605
const body = lexer.source.body;
@@ -624,15 +632,17 @@ function readEscapedCharacter(lexer: Lexer, position: number): EscapeSequence {
624632
);
625633
}
626634

627-
/*
635+
/**
628636
* Reads a block string token from the source file.
629637
*
638+
* ```
630639
* StringValue ::
631640
* - `"""` BlockStringCharacter* `"""`
632641
*
633642
* BlockStringCharacter ::
634643
* - SourceCharacter but not `"""` or `\"""`
635644
* - `\"""`
645+
* ```
636646
*/
637647
function readBlockString(lexer: Lexer, start: number): Token {
638648
const body = lexer.source.body;
@@ -703,9 +713,10 @@ function readBlockString(lexer: Lexer, start: number): Token {
703713
throw syntaxError(lexer.source, position, 'Unterminated string.');
704714
}
705715

706-
/*
716+
/**
707717
* Reads an alphanumeric + underscore name from the source.
708718
*
719+
* ```
709720
* Name ::
710721
* - NameStart NameContinue* [lookahead != NameContinue]
711722
*
@@ -717,6 +728,7 @@ function readBlockString(lexer: Lexer, start: number): Token {
717728
* - Letter
718729
* - Digit
719730
* - `_`
731+
* ```
720732
*/
721733
function readName(lexer: Lexer, start: number): Token {
722734
const body = lexer.source.body;
@@ -746,20 +758,24 @@ function isNameStart(code: number): boolean {
746758
return isLetter(code) || code === 0x005f;
747759
}
748760

749-
/*
761+
/**
762+
* ```
750763
* Digit :: one of
751764
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
765+
* ```
752766
*/
753767
function isDigit(code: number): boolean {
754768
return code >= 0x0030 && code <= 0x0039;
755769
}
756770

757-
/*
771+
/**
772+
* ```
758773
* Letter :: one of
759774
* - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`
760775
* - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`
761776
* - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`
762777
* - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`
778+
* ```
763779
*/
764780
function isLetter(code: number): boolean {
765781
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)