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

Migrate to ts tool #1

Closed
wants to merge 8 commits into from
Closed
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
142 changes: 64 additions & 78 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -509,84 +509,80 @@ overrides:

# Supported Rules
# https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules
'@typescript-eslint/adjacent-overload-signatures': error
'@typescript-eslint/array-type': [error, { default: generic }]
'@typescript-eslint/await-thenable': error
'@typescript-eslint/ban-ts-comment': [error, { 'ts-expect-error': false }]
'@typescript-eslint/ban-tslint-comment': error
'@typescript-eslint/ban-types': error
'@typescript-eslint/class-literal-property-style': off # TODO enable after TS conversion
'@typescript-eslint/consistent-indexed-object-style': off # TODO enable after TS conversion
'@typescript-eslint/consistent-type-assertions':
[error, { assertionStyle: as, objectLiteralTypeAssertions: never }]
'@typescript-eslint/adjacent-overload-signatures': off #TODO temporarily disabled
'@typescript-eslint/array-type': off #TODO temporarily disabled
'@typescript-eslint/await-thenable': off #TODO temporarily disabled
'@typescript-eslint/ban-ts-comment': off #TODO temporarily disabled
'@typescript-eslint/ban-tslint-comment': off #TODO temporarily disabled
'@typescript-eslint/ban-types': off #TODO temporarily disabled
'@typescript-eslint/class-literal-property-style': off
'@typescript-eslint/consistent-type-assertions': off #TODO temporarily disabled
'@typescript-eslint/consistent-type-definitions': off # TODO consider
'@typescript-eslint/consistent-type-imports': off # TODO enable after TS conversion
'@typescript-eslint/explicit-function-return-type': off # TODO consider
'@typescript-eslint/explicit-member-accessibility': off # TODO consider
'@typescript-eslint/explicit-module-boundary-types': off # TODO consider
'@typescript-eslint/member-ordering': off # TODO consider
'@typescript-eslint/method-signature-style': error
'@typescript-eslint/method-signature-style': off #TODO temporarily disabled
'@typescript-eslint/naming-convention': off # TODO consider
'@typescript-eslint/no-base-to-string': error
'@typescript-eslint/no-confusing-non-null-assertion': error
'@typescript-eslint/no-base-to-string': off #TODO temporarily disabled
'@typescript-eslint/no-confusing-non-null-assertion': off #TODO temporarily disabled
'@typescript-eslint/no-dynamic-delete': off
'@typescript-eslint/no-empty-interface': error
'@typescript-eslint/no-empty-interface': off #TODO temporarily disabled
'@typescript-eslint/no-explicit-any': off # TODO error
'@typescript-eslint/no-extra-non-null-assertion': error
'@typescript-eslint/no-extra-non-null-assertion': off #TODO temporarily disabled
'@typescript-eslint/no-extraneous-class': off # TODO consider
'@typescript-eslint/no-floating-promises': error
'@typescript-eslint/no-for-in-array': error
'@typescript-eslint/no-floating-promises': off #TODO temporarily disabled
'@typescript-eslint/no-for-in-array': off #TODO temporarily disabled
'@typescript-eslint/no-implicit-any-catch': off # TODO: Enable after TS convertion
'@typescript-eslint/no-implied-eval': error
'@typescript-eslint/no-inferrable-types':
[error, { ignoreParameters: true, ignoreProperties: true }]
'@typescript-eslint/no-misused-new': error
'@typescript-eslint/no-misused-promises': error
'@typescript-eslint/no-namespace': error
'@typescript-eslint/no-non-null-asserted-optional-chain': error
'@typescript-eslint/no-non-null-assertion': error
'@typescript-eslint/no-parameter-properties': error
'@typescript-eslint/no-invalid-void-type': error
'@typescript-eslint/no-require-imports': error
'@typescript-eslint/no-this-alias': error
'@typescript-eslint/no-throw-literal': error
'@typescript-eslint/no-implied-eval': off #TODO temporarily disabled
'@typescript-eslint/no-inferrable-types': off #TODO temporarily disabled
'@typescript-eslint/no-misused-new': off #TODO temporarily disabled
'@typescript-eslint/no-misused-promises': off #TODO temporarily disabled
'@typescript-eslint/no-namespace': off #TODO temporarily disabled
'@typescript-eslint/no-non-null-asserted-optional-chain': off #TODO temporarily disabled
'@typescript-eslint/no-non-null-assertion': off #TODO temporarily disabled
'@typescript-eslint/no-parameter-properties': off #TODO temporarily disabled
'@typescript-eslint/no-invalid-void-type': off #TODO temporarily disabled
'@typescript-eslint/no-require-imports': off #TODO temporarily disabled
'@typescript-eslint/no-this-alias': off #TODO temporarily disabled
'@typescript-eslint/no-throw-literal': off #TODO temporarily disabled
'@typescript-eslint/no-type-alias': off # TODO consider
'@typescript-eslint/no-unnecessary-boolean-literal-compare': error
'@typescript-eslint/no-unnecessary-condition': error
'@typescript-eslint/no-unnecessary-qualifier': error
'@typescript-eslint/no-unnecessary-type-arguments': error
'@typescript-eslint/no-unnecessary-type-assertion': error
'@typescript-eslint/no-unnecessary-boolean-literal-compare': off #TODO temporarily disabled
'@typescript-eslint/no-unnecessary-condition': off #TODO temporarily disabled
'@typescript-eslint/no-unnecessary-qualifier': off #TODO temporarily disabled
'@typescript-eslint/no-unnecessary-type-arguments': off #TODO temporarily disabled
'@typescript-eslint/no-unnecessary-type-assertion': off #TODO temporarily disabled
'@typescript-eslint/no-unsafe-assignment': off # TODO consider
'@typescript-eslint/no-unsafe-call': off # TODO consider
'@typescript-eslint/no-unsafe-member-access': off # TODO consider
'@typescript-eslint/no-unsafe-return': off # TODO consider
'@typescript-eslint/no-var-requires': error
'@typescript-eslint/no-var-requires': off #TODO temporarily disabled
'@typescript-eslint/prefer-as-const': off # TODO consider
'@typescript-eslint/prefer-enum-initializers': off # TODO consider
'@typescript-eslint/prefer-for-of': off # TODO switch to error after TS migration
'@typescript-eslint/prefer-function-type': error
'@typescript-eslint/prefer-function-type': off #TODO temporarily disabled
'@typescript-eslint/prefer-includes': off # TODO switch to error after IE11 drop
'@typescript-eslint/prefer-literal-enum-member': error
'@typescript-eslint/prefer-namespace-keyword': error
'@typescript-eslint/prefer-nullish-coalescing': error
'@typescript-eslint/prefer-optional-chain': error
'@typescript-eslint/prefer-readonly': error
'@typescript-eslint/prefer-literal-enum-member': off #TODO temporarily disabled
'@typescript-eslint/prefer-namespace-keyword': off #TODO temporarily disabled
'@typescript-eslint/prefer-nullish-coalescing': off #TODO temporarily disabled
'@typescript-eslint/prefer-optional-chain': off #TODO temporarily disabled
'@typescript-eslint/prefer-readonly': off #TODO temporarily disabled
'@typescript-eslint/prefer-readonly-parameter-types': off # TODO consider
'@typescript-eslint/prefer-reduce-type-parameter': error
'@typescript-eslint/prefer-regexp-exec': error
'@typescript-eslint/prefer-ts-expect-error': error
'@typescript-eslint/prefer-reduce-type-parameter': off #TODO temporarily disabled
'@typescript-eslint/prefer-regexp-exec': off #TODO temporarily disabled
'@typescript-eslint/prefer-ts-expect-error': off #TODO temporarily disabled
'@typescript-eslint/prefer-string-starts-ends-with': off # TODO switch to error after IE11 drop
'@typescript-eslint/promise-function-async': off
'@typescript-eslint/require-array-sort-compare': error
'@typescript-eslint/restrict-plus-operands':
[error, { checkCompoundAssignments: true }]
'@typescript-eslint/restrict-template-expressions': error
'@typescript-eslint/require-array-sort-compare': off #TODO temporarily disabled
'@typescript-eslint/restrict-plus-operands': off #TODO temporarily disabled
'@typescript-eslint/restrict-template-expressions': off #TODO temporarily disabled
'@typescript-eslint/strict-boolean-expressions': off # TODO consider
'@typescript-eslint/switch-exhaustiveness-check': error
'@typescript-eslint/triple-slash-reference': error
'@typescript-eslint/switch-exhaustiveness-check': off #TODO temporarily disabled
'@typescript-eslint/triple-slash-reference': off #TODO temporarily disabled
'@typescript-eslint/typedef': off
'@typescript-eslint/unbound-method': off # TODO consider
'@typescript-eslint/unified-signatures': error
'@typescript-eslint/unified-signatures': off #TODO temporarily disabled

# Extension Rules
# https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#extension-rules
Expand All @@ -608,32 +604,22 @@ overrides:
no-useless-constructor: off
require-await: off
no-return-await: off
'@typescript-eslint/default-param-last': error
'@typescript-eslint/dot-notation': error
'@typescript-eslint/lines-between-class-members':
[error, always, { exceptAfterSingleLine: true }]
'@typescript-eslint/no-array-constructor': error
'@typescript-eslint/no-dupe-class-members': error
'@typescript-eslint/no-empty-function': error
'@typescript-eslint/no-invalid-this': error
'@typescript-eslint/no-loop-func': error
'@typescript-eslint/no-loss-of-precision': error
'@typescript-eslint/no-redeclare': error
'@typescript-eslint/no-shadow': error
'@typescript-eslint/no-unused-expressions': error
'@typescript-eslint/no-unused-vars':
[
error,
{
vars: all,
args: all,
argsIgnorePattern: '^_',
varsIgnorePattern: '^_T',
},
]
'@typescript-eslint/no-useless-constructor': error
'@typescript-eslint/require-await': error
'@typescript-eslint/return-await': error
'@typescript-eslint/default-param-last': off #TODO temporarily disabled
'@typescript-eslint/dot-notation': off #TODO temporarily disabled
'@typescript-eslint/lines-between-class-members': off #TODO temporarily disabled
'@typescript-eslint/no-array-constructor': off #TODO temporarily disabled
'@typescript-eslint/no-dupe-class-members': off #TODO temporarily disabled
'@typescript-eslint/no-empty-function': off #TODO temporarily disabled
'@typescript-eslint/no-invalid-this': off #TODO temporarily disabled
'@typescript-eslint/no-loop-func': off #TODO temporarily disabled
'@typescript-eslint/no-loss-of-precision': off #TODO temporarily disabled
'@typescript-eslint/no-redeclare': off #TODO temporarily disabled
'@typescript-eslint/no-shadow': off #TODO temporarily disabled
'@typescript-eslint/no-unused-expressions': off #TODO temporarily disabled
'@typescript-eslint/no-unused-vars': off #TODO temporarily disabled
'@typescript-eslint/no-useless-constructor': off #TODO temporarily disabled
'@typescript-eslint/require-await': off #TODO temporarily disabled
'@typescript-eslint/return-await': off #TODO temporarily disabled

# Disable for JS, Flow and TS
'@typescript-eslint/init-declarations': off
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
"gitpublish:npm": "bash ./resources/gitpublish.sh npm npmDist",
"gitpublish:deno": "bash ./resources/gitpublish.sh deno denoDist"
},
"dependencies": {},
"dependencies": {
"utility-types": "^3.10.0"
},
"devDependencies": {
"@babel/core": "7.12.3",
"@babel/plugin-transform-flow-strip-types": "7.12.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { describe, it } from 'mocha';

import genFuzzStrings from '../genFuzzStrings';

function expectFuzzStrings(options: {|
allowedChars: Array<string>,
maxLength: number,
|}) {
function expectFuzzStrings(options: {
allowedChars: Array<string>;
maxLength: number;
}) {
return expect(Array.from(genFuzzStrings(options)));
}

Expand Down
4 changes: 2 additions & 2 deletions src/__testUtils__/dedent.js → src/__testUtils__/dedent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* str === "{\n test\n}\n";
*/
export default function dedent(
strings: $ReadOnlyArray<string>,
...values: $ReadOnlyArray<string>
strings: ReadonlyArray<string>,
...values: ReadonlyArray<string>
): string {
let str = '';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Generator that produces all possible combinations of allowed characters.
*/
export default function* genFuzzStrings(options: {|
allowedChars: Array<string>,
maxLength: number,
|}): Generator<string, void, void> {
export default function* genFuzzStrings(options: {
allowedChars: Array<string>;
maxLength: number;
}): Generator<string, void, void> {
const { allowedChars, maxLength } = options;
const numAllowedChars = allowedChars.length;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Special inspect function to produce readable string literal for error messages in tests
*/
export default function inspectStr(str: ?string): string {
export default function inspectStr(str: string | null | undefined): string {
if (str == null) {
return 'null';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// $FlowFixMe[incompatible-call]
const kitchenSinkQuery: string = String.raw`
query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery {
whoever123is: node(id: [123, 456]) {
Expand Down
52 changes: 27 additions & 25 deletions src/__tests__/starWarsData.js → src/__tests__/starWarsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
* They represent the shape of the data visited during field resolution.
*/
export type Character = {
id: string,
name: string,
friends: Array<string>,
appearsIn: Array<number>,
...
id: string;
name: string;
friends: Array<string>;
appearsIn: Array<number>;
};

export type Human = {|
type: 'Human',
id: string,
name: string,
friends: Array<string>,
appearsIn: Array<number>,
homePlanet?: string,
|};

export type Droid = {|
type: 'Droid',
id: string,
name: string,
friends: Array<string>,
appearsIn: Array<number>,
primaryFunction: string,
|};
export type Human = {
type: 'Human';
id: string;
name: string;
friends: Array<string>;
appearsIn: Array<number>;
homePlanet?: string;
};

export type Droid = {
type: 'Droid';
id: string;
name: string;
friends: Array<string>;
appearsIn: Array<number>;
primaryFunction: string;
};

/**
* This defines a basic set of data for our Star Wars Schema.
Expand All @@ -35,7 +34,6 @@ export type Droid = {|
* fetching this data from a backend service rather than from hardcoded
* JSON objects in a more complex demo.
*/

const luke: Human = {
type: 'Human',
id: '1000',
Expand Down Expand Up @@ -79,7 +77,9 @@ const tarkin: Human = {
appearsIn: [4],
};

const humanData: {| [id: string]: Human |} = {
const humanData: {
[id: string]: Human;
} = {
[luke.id]: luke,
[vader.id]: vader,
[han.id]: han,
Expand All @@ -105,7 +105,9 @@ const artoo: Droid = {
primaryFunction: 'Astromech',
};

const droidData: {| [id: string]: Droid |} = {
const droidData: {
[id: string]: Droid;
} = {
[threepio.id]: threepio,
[artoo.id]: artoo,
};
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ describe('Version', () => {
}

expect(
`${major}.${minor}.${patch}` +
// istanbul ignore next (Can't be verified on all versions)
`${major}.${minor}.${patch}` + // istanbul ignore next (Can't be verified on all versions)
(preReleaseTag !== null ? '-' + preReleaseTag : ''),
).to.equal(version);
});
Expand Down
Loading