Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct bunch of spelling mistakes #2295

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions resources/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const { sampleModule } = require('./benchmark-fork');
const NS_PER_SEC = 1e9;
const LOCAL = 'local';

// The maximum time in secounds a benchmark is allowed to run before finishing.
// The maximum time in seconds a benchmark is allowed to run before finishing.
const maxTime = 5;
// The minimum sample size required to perform statistical analysis.
const minSamples = 5;
Expand All @@ -30,7 +30,7 @@ function LOCAL_DIR(...paths) {
return path.join(__dirname, '..', ...paths);
}

// Build a benchmarkable environment for the given revision
// Build a benchmark-friendly environment for the given revision
// and returns path to its 'dist' directory.
function prepareRevision(revision) {
console.log(`🍳 Preparing ${revision}...`);
Expand Down
4 changes: 2 additions & 2 deletions resources/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ function showStats() {

for (const filepath of readdirRecursive('./dist')) {
const name = filepath.split(path.sep).pop();
const [base, ...splitedExt] = name.split('.');
const ext = splitedExt.join('.');
const [base, ...splitExt] = name.split('.');
const ext = splitExt.join('.');

const filetype = ext ? '*.' + ext : base;
fileTypes[filetype] = fileTypes[filetype] || { filepaths: [], size: 0 };
Expand Down
4 changes: 2 additions & 2 deletions resources/check-cover.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ async function getFullCoverage() {
.filter(filepath => filepath.endsWith('.js'))
.map(filepath => path.join('src/', filepath));

await Promise.all(files.map(getCoverage)).then(covarageObjs => {
for (const coverage of covarageObjs) {
await Promise.all(files.map(getCoverage)).then(coverages => {
for (const coverage of coverages) {
fullCoverage[coverage.path] = coverage;
}
});
Expand Down
62 changes: 62 additions & 0 deletions resources/check-cycles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// @noflow

'use strict';

const os = require('os');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const { exec } = require('./utils');

const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'flow-dep-graph'));
const tmpFile = path.join(tmpDir, 'out.dot');

exec(`yarn flow graph dep-graph --quiet --strip-root --out ${tmpFile}`);
const dot = fs.readFileSync(tmpFile, 'utf-8');
assert(dot.startsWith('digraph {\n') && dot.endsWith('\n}'));
const dotLines = dot.split('\n').slice(1, -1);

let depGraph = [];
for (const line of dotLines) {
const [, from, to] = line.trim().match(/^"(.*?)" -> "(.*?)"$/);
assert(from && to);
depGraph.push([from, to]);
}

for (const [from, to] of depGraph) {
if (
path.basename(to) === 'index.js' &&
!path.dirname(to).endsWith('__fixtures__') &&
path.basename(from) !== 'index.js'
) {
console.log(from);
}
}

let removedEdges;
do {
removedEdges = 0;
const fromFiles = new Set();
const toFiles = new Set();

for (const [from, to] of depGraph) {
fromFiles.add(from);
toFiles.add(to);
}

console.log(depGraph.length);
// eslint-disable-next-line no-loop-func
depGraph = depGraph.filter(([from, to]) => {
if (!toFiles.has(from) || !fromFiles.has(to)) {
++removedEdges;
return false;
}
return true;
});
} while (removedEdges > 0);

console.log('digraph {');
for (const [from, to] of depGraph) {
console.log(` "${from}" -> "${to}"`);
}
console.log('}');
14 changes: 7 additions & 7 deletions resources/gen-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const repoURLMatch = /https:\/\/github.com\/([^/]+)\/([^/]+).git/.exec(
packageJSON.repository.url,
);
if (repoURLMatch == null) {
console.error('Cannot extract organisation and repo name from repo URL!');
console.error('Cannot extract organization and repo name from repo URL!');
process.exit(1);
}
const [, githubOrg, githubRepo] = repoURLMatch;
Expand Down Expand Up @@ -80,7 +80,7 @@ function getChangeLog() {

function genChangeLog(tag, date, allPRs) {
const byLabel = {};
const commitersByLogin = {};
const committersByLogin = {};

for (const pr of allPRs) {
const labels = pr.labels.nodes
Expand All @@ -102,7 +102,7 @@ function genChangeLog(tag, date, allPRs) {
}
byLabel[label] = byLabel[label] || [];
byLabel[label].push(pr);
commitersByLogin[pr.author.login] = pr.author;
committersByLogin[pr.author.login] = pr.author;
}

let changelog = `## ${tag || 'Unreleased'} (${date})\n`;
Expand All @@ -128,12 +128,12 @@ function genChangeLog(tag, date, allPRs) {
}
}

const commiters = Object.values(commitersByLogin).sort((a, b) =>
const committers = Object.values(committersByLogin).sort((a, b) =>
(a.name || a.login).localeCompare(b.name || b.login),
);
changelog += `\n#### Committers: ${commiters.length}\n`;
for (const commiter of commiters) {
changelog += `* ${commiter.name}([@${commiter.login}](${commiter.url}))\n`;
changelog += `\n#### Committers: ${committers.length}\n`;
for (const committer of committers) {
changelog += `* ${committer.name}([@${committer.login}](${committer.url}))\n`;
}

return changelog;
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/starWarsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export type Droid = {|
* Helper function to get a character by ID.
*/
function getCharacter(id) {
// Returning a promise just to illustrate GraphQL.js's support.
// Returning a promise just to illustrate that GraphQL.js supports it.
return Promise.resolve(humanData[id] || droidData[id]);
}

Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/starWarsQuery-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('Star Wars Query Tests', () => {
friends: [
{
name: 'Luke Skywalker',
appearsIn: ['NEWHOPE', 'EMPIRE', 'JEDI'],
appearsIn: ['NEW_HOPE', 'EMPIRE', 'JEDI'],
friends: [
{
name: 'Han Solo',
Expand All @@ -126,7 +126,7 @@ describe('Star Wars Query Tests', () => {
},
{
name: 'Han Solo',
appearsIn: ['NEWHOPE', 'EMPIRE', 'JEDI'],
appearsIn: ['NEW_HOPE', 'EMPIRE', 'JEDI'],
friends: [
{
name: 'Luke Skywalker',
Expand All @@ -141,7 +141,7 @@ describe('Star Wars Query Tests', () => {
},
{
name: 'Leia Organa',
appearsIn: ['NEWHOPE', 'EMPIRE', 'JEDI'],
appearsIn: ['NEW_HOPE', 'EMPIRE', 'JEDI'],
friends: [
{
name: 'Luke Skywalker',
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/starWarsSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { getFriends, getHero, getHuman, getDroid } from './starWarsData';
* Using our shorthand to describe type systems, the type system for our
* Star Wars example is:
*
* enum Episode { NEWHOPE, EMPIRE, JEDI }
* enum Episode { NEW_HOPE, EMPIRE, JEDI }
*
* interface Character {
* id: String!
Expand Down Expand Up @@ -65,13 +65,13 @@ import { getFriends, getHero, getHuman, getDroid } from './starWarsData';
* The original trilogy consists of three movies.
*
* This implements the following type system shorthand:
* enum Episode { NEWHOPE, EMPIRE, JEDI }
* enum Episode { NEW_HOPE, EMPIRE, JEDI }
*/
const episodeEnum = new GraphQLEnumType({
name: 'Episode',
description: 'One of the films in the Star Wars Trilogy',
values: {
NEWHOPE: {
NEW_HOPE: {
value: 4,
description: 'Released in 1977.',
},
Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/executor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ describe('Execute: Handles basic execution tasks', () => {
}),
),
resolve() {
return Promise.reject(new Error('Dangit'));
return Promise.reject(new Error('Oops'));
},
},
},
Expand All @@ -561,7 +561,7 @@ describe('Execute: Handles basic execution tasks', () => {
errors: [
{
locations: [{ column: 9, line: 3 }],
message: 'Dangit',
message: 'Oops',
path: ['foods'],
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/schema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('Execute: Handles execution with a complex schema', () => {
title,
body,
hidden,
notdefined
notDefined
}
`);

Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/variables-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ describe('Execute: Handles inputs', () => {
fieldWithObjectInput(input: $input)
}
`;
const result = executeQuery(doc, { input: 'whoknows' });
const result = executeQuery(doc, { input: 'WhoKnows' });

expect(result).to.deep.equal({
errors: [
Expand Down
2 changes: 1 addition & 1 deletion src/execution/execute.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const defaultTypeResolver: GraphQLTypeResolver<any, any>;
export const defaultFieldResolver: GraphQLFieldResolver<any, any>;

/**
* This method looks up the field on the given type defintion.
* This method looks up the field on the given type definition.
* It has special casing for the two introspection fields, __schema
* and __typename. __typename is special because it can always be
* queried as a field, even in situations where no other fields
Expand Down
10 changes: 5 additions & 5 deletions src/jsutils/__tests__/dedent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ describe('dedent', () => {

it('removes only the first level of indentation', () => {
const output = dedent`
qux
quux
quuux
quuuux
first
second
third
fourth
`;
expect(output).to.equal(
['qux', ' quux', ' quuux', ' quuuux', ''].join('\n'),
['first', ' second', ' third', ' fourth', ''].join('\n'),
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/__tests__/inspect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('inspect', () => {
expect(inspect(customA)).to.equal('[Circular]');
});

it('Use class names for the shortform of an object', () => {
it('Use class names for the short form of an object', () => {
class Foo {
foo: string;

Expand Down
6 changes: 3 additions & 3 deletions src/language/__tests__/lexer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ describe('Lexer', () => {
value: 'contains " quote',
});

expect(lexOne('"""contains \\""" triplequote"""')).to.contain({
expect(lexOne('"""contains \\""" triple quote"""')).to.contain({
kind: TokenKind.BLOCK_STRING,
start: 0,
end: 31,
value: 'contains """ triplequote',
end: 32,
value: 'contains """ triple quote',
});

expect(lexOne('"""multi\nline"""')).to.contain({
Expand Down
4 changes: 2 additions & 2 deletions src/language/__tests__/parser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ describe('Parser', () => {
locations: [{ line: 1, column: 10 }],
});

expectSyntaxError('notanoperation Foo { field }').to.deep.include({
message: 'Syntax Error: Unexpected Name "notanoperation".',
expectSyntaxError('notAnOperation Foo { field }').to.deep.include({
message: 'Syntax Error: Unexpected Name "notAnOperation".',
locations: [{ line: 1, column: 1 }],
});

Expand Down
8 changes: 4 additions & 4 deletions src/language/__tests__/printLocation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { printSourceLocation } from '../printLocation';
describe('printSourceLocation', () => {
it('prints minified documents', () => {
const minifiedSource = new Source(
'query SomeMiniFiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String){someField(foo:$foo bar:$bar baz:SECOND_ERROR_HERE){fieldA fieldB{fieldC fieldD...on THIRD_ERROR_HERE}}}',
'query SomeMinifiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String){someField(foo:$foo bar:$bar baz:SECOND_ERROR_HERE){fieldA fieldB{fieldC fieldD...on THIRD_ERROR_HERE}}}',
);

const firstLocation = printSourceLocation(minifiedSource, {
Expand All @@ -20,7 +20,7 @@ describe('printSourceLocation', () => {
});
expect(firstLocation + '\n').to.equal(dedent`
GraphQL request:1:53
1 | query SomeMiniFiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String)
1 | query SomeMinifiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String)
| ^
| {someField(foo:$foo bar:$bar baz:SECOND_ERROR_HERE){fieldA fieldB{fieldC fieldD.
`);
Expand All @@ -31,7 +31,7 @@ describe('printSourceLocation', () => {
});
expect(secondLocation + '\n').to.equal(dedent`
GraphQL request:1:114
1 | query SomeMiniFiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String)
1 | query SomeMinifiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String)
| {someField(foo:$foo bar:$bar baz:SECOND_ERROR_HERE){fieldA fieldB{fieldC fieldD.
| ^
| ..on THIRD_ERROR_HERE}}}
Expand All @@ -43,7 +43,7 @@ describe('printSourceLocation', () => {
});
expect(thirdLocation + '\n').to.equal(dedent`
GraphQL request:1:166
1 | query SomeMiniFiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String)
1 | query SomeMinifiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String)
| {someField(foo:$foo bar:$bar baz:SECOND_ERROR_HERE){fieldA fieldB{fieldC fieldD.
| ..on THIRD_ERROR_HERE}}}
| ^
Expand Down
2 changes: 1 addition & 1 deletion src/language/blockString.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Produces the value of a block string from its parsed raw value, similar to
* Coffeescript's block string, Python's docstring trim or Ruby's strip_heredoc.
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
*
* This implements the GraphQL spec's BlockStringValue() static algorithm.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/language/lexer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Lexer {

/**
* Looks ahead and returns the next non-ignored token, but does not change
* the Lexer's state.
* the state of Lexer.
*/
lookahead(): Token;
}
Expand Down
2 changes: 1 addition & 1 deletion src/language/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Lexer {

/**
* Looks ahead and returns the next non-ignored token, but does not change
* the Lexer's state.
* the state of Lexer.
*/
lookahead(): Token {
let token = this.token;
Expand Down
5 changes: 3 additions & 2 deletions src/language/printLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ function printPrefixedLines(lines: $ReadOnlyArray<[string, string]>): string {
const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
return existingLines
.map(
([prefix, line]) => lpad(padLen, prefix) + (line ? ' | ' + line : ' |'),
([prefix, line]) =>
leftPad(padLen, prefix) + (line ? ' | ' + line : ' |'),
)
.join('\n');
}
Expand All @@ -82,6 +83,6 @@ function whitespace(len: number): string {
return Array(len + 1).join(' ');
}

function lpad(len: number, str: string): string {
function leftPad(len: number, str: string): string {
return whitespace(len - str.length) + str;
}
Loading