Skip to content

Commit 36e5f99

Browse files
committed
Merge branch 'main' into streams-editorial
2 parents 58aa3ae + e5bddd9 commit 36e5f99

File tree

4 files changed

+75
-9
lines changed

4 files changed

+75
-9
lines changed

.github/algorithm-format-check.mjs

+68-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ for (const filename of filenames) {
2323
{
2424
// Is it an algorithm definition?
2525
const matches = line.match(/^([a-z0-9A-Z]+)(\s*)\(([^)]*)\)(\s*):(\s*)$/);
26+
const grammarMatches =
27+
filename === "Section 2 -- Language.md" &&
28+
line.match(/^([A-Za-z0-9]+) :\s+((\S).*)$/);
2629
if (matches) {
2730
const [, algorithmName, ns1, _args, ns2, ns3] = matches;
2831
if (ns1 || ns2 || ns3) {
2932
console.log(
3033
`Bad whitespace in definition of ${algorithmName} in '${filename}':`
3134
);
32-
console.log(line);
35+
console.dir(line);
3336
console.log();
3437
process.exitCode = 1;
3538
}
@@ -47,7 +50,7 @@ for (const filename of filenames) {
4750
console.log(
4851
`Bad algorithm ${algorithmName} step in '${filename}':`
4952
);
50-
console.log(step);
53+
console.dir(step);
5154
console.log();
5255
process.exitCode = 1;
5356
}
@@ -57,15 +60,15 @@ for (const filename of filenames) {
5760
console.log(
5861
`Bad formatting for '${algorithmName}' step (does not end in '.' or ':') in '${filename}':`
5962
);
60-
console.log(step);
63+
console.dir(step);
6164
console.log();
6265
process.exitCode = 1;
6366
}
6467
if (step.match(/^\s*(-|[0-9]\.)\s+[a-z]/)) {
6568
console.log(
6669
`Bad formatting of '${algorithmName}' step (should start with a capital) in '${filename}':`
6770
);
68-
console.log(step);
71+
console.dir(step);
6972
console.log();
7073
process.exitCode = 1;
7174
}
@@ -79,7 +82,67 @@ for (const filename of filenames) {
7982
console.log(
8083
`Potential bad formatting of '${algorithmName}' step (true/false/null should be wrapped in curly braces, e.g. '{true}') in '${filename}':`
8184
);
82-
console.log(step);
85+
console.dir(step);
86+
console.log();
87+
process.exitCode = 1;
88+
}
89+
}
90+
} else if (grammarMatches) {
91+
// This is super loosey-goosey
92+
const [, grammarName, rest] = grammarMatches;
93+
if (rest.trim() === "one of") {
94+
// Still grammar, not algorithm
95+
continue;
96+
}
97+
if (rest.trim() === "" && lines[i + 1] !== "") {
98+
console.log(
99+
`No empty space after grammar ${grammarName} header in '${filename}'`
100+
);
101+
console.log();
102+
process.exitCode = 1;
103+
}
104+
if (!lines[i + 2].startsWith("- ")) {
105+
// Not an algorithm; probably more grammar
106+
continue;
107+
}
108+
for (let j = i + 2; j < l; j++) {
109+
const step = lines[j];
110+
if (!step.match(/^\s*(-|[0-9]+\.) /)) {
111+
if (step !== "") {
112+
console.log(`Bad grammar ${grammarName} step in '${filename}':`);
113+
console.dir(step);
114+
console.log();
115+
process.exitCode = 1;
116+
}
117+
break;
118+
}
119+
if (!step.match(/[.:]$/)) {
120+
console.log(
121+
`Bad formatting for '${grammarName}' step (does not end in '.' or ':') in '${filename}':`
122+
);
123+
console.dir(step);
124+
console.log();
125+
process.exitCode = 1;
126+
}
127+
if (step.match(/^\s*(-|[0-9]\.)\s+[a-z]/)) {
128+
console.log(
129+
`Bad formatting of '${grammarName}' step (should start with a capital) in '${filename}':`
130+
);
131+
console.dir(step);
132+
console.log();
133+
process.exitCode = 1;
134+
}
135+
const trimmedInnerLine = step.replace(/\s+/g, " ");
136+
if (
137+
trimmedInnerLine.match(
138+
/(?:[rR]eturn|is (?:not )?)(true|false|null)\b/
139+
) &&
140+
!trimmedInnerLine.match(/null or empty/)
141+
) {
142+
console.log(
143+
`Potential bad formatting of '${grammarName}' step (true/false/null should be wrapped in curly braces, e.g. '{true}') in '${filename}':`
144+
);
145+
console.dir(step);
83146
console.log();
84147
process.exitCode = 1;
85148
}

cspell.yml

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ words:
2121
- tatooine
2222
- zuck
2323
- zuckerberg
24+
# Alternative spellings
25+
- !implementor
26+
- !implementors

spec/Section 5 -- Validation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ fragment aliasedLyingFieldTargetNotDefined on Dog {
362362
```
363363

364364
For interfaces, direct field selection can only be done on fields. Fields of
365-
concrete implementors are not relevant to the validity of the given
365+
concrete implementers are not relevant to the validity of the given
366366
interface-typed selection set.
367367

368368
For example, the following is valid:
@@ -376,7 +376,7 @@ fragment interfaceFieldSelection on Pet {
376376
and the following is invalid:
377377

378378
```graphql counter-example
379-
fragment definedOnImplementorsButNotInterface on Pet {
379+
fragment definedOnImplementersButNotInterface on Pet {
380380
nickname
381381
}
382382
```

spec/Section 7 -- Response.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ request failed before execution, due to a syntax error, missing information, or
2323
validation error, this entry must not be present.
2424

2525
The response map may also contain an entry with key `extensions`. This entry, if
26-
set, must have a map as its value. This entry is reserved for implementors to
26+
set, must have a map as its value. This entry is reserved for implementers to
2727
extend the protocol however they see fit, and hence there are no additional
2828
restrictions on its contents.
2929

@@ -203,7 +203,7 @@ be the same:
203203

204204
GraphQL services may provide an additional entry to errors with key
205205
`extensions`. This entry, if set, must have a map as its value. This entry is
206-
reserved for implementors to add additional information to errors however they
206+
reserved for implementers to add additional information to errors however they
207207
see fit, and there are no additional restrictions on its contents.
208208

209209
```json example

0 commit comments

Comments
 (0)