Skip to content

Commit 50ef843

Browse files
committed
Finishes TSLint config, fixes lint errors.
1 parent 4186854 commit 50ef843

6 files changed

+76
-64
lines changed

package.json

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
{
22
"name": "relay-compiler-language-typescript",
33
"version": "1.1.0",
4-
"description": "A language plugin for Relay that adds TypeScript support, including emitting type definitions.",
4+
"description":
5+
"A language plugin for Relay that adds TypeScript support, including emitting type definitions.",
56
"license": "MIT",
6-
"keywords": [
7-
"relay",
8-
"graphql",
9-
"react",
10-
"typescript"
11-
],
7+
"keywords": ["relay", "graphql", "react", "typescript"],
128
"contributors": [
139
{
1410
"name": "Kaare Hoff Skovgaard",
@@ -19,27 +15,30 @@
1915
"email": "[email protected]"
2016
}
2117
],
22-
"homepage": "https://github.com/relay-tools/relay-compiler-language-typescript",
18+
"homepage":
19+
"https://github.com/relay-tools/relay-compiler-language-typescript",
2320
"repository": {
2421
"type": "git",
25-
"url": "https://github.com/relay-tools/relay-compiler-language-typescript.git"
22+
"url":
23+
"https://github.com/relay-tools/relay-compiler-language-typescript.git"
2624
},
2725
"bugs": {
28-
"url": "https://github.com/relay-tools/relay-compiler-language-typescript/issues"
26+
"url":
27+
"https://github.com/relay-tools/relay-compiler-language-typescript/issues"
2928
},
3029
"main": "lib/index.js",
31-
"files": [
32-
"lib"
33-
],
30+
"files": ["lib"],
3431
"scripts": {
3532
"prepublish": "npm run build",
3633
"build": "rm -rf lib && tsc",
37-
"relay": "node bin/relay-compiler.js --schema test/schema.graphql --src test/ --outputDir __generated__",
34+
"relay":
35+
"node bin/relay-compiler.js --schema test/schema.graphql --src test/ --outputDir __generated__",
3836
"lint": "tslint -c tslint.json --project tsconfig.json",
3937
"test": "npm run type-check && jest",
4038
"type-check": "tsc --noEmit --pretty",
4139
"prettier": "prettier --write '{src,types}/**/*.ts'",
42-
"sync-fixtures": "rsync -avh --delete --stats --progress ../relay/packages/relay-compiler/language/javascript/__tests__/fixtures/flow-generator/*.graphql test/fixtures/type-generator",
40+
"sync-fixtures":
41+
"rsync -avh --delete --stats --progress ../relay/packages/relay-compiler/language/javascript/__tests__/fixtures/flow-generator/*.graphql test/fixtures/type-generator",
4342
"precommit": "lint-staged"
4443
},
4544
"dependencies": {
@@ -67,31 +66,35 @@
6766
"jest": "^22.1.4",
6867
"lint-staged": "^7.3.0",
6968
"prettier": "^1.10.2",
70-
"relay-compiler": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-compiler-1.6.1-plugin.1.tgz",
71-
"relay-runtime": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-runtime-1.6.1-plugin.1.tgz",
72-
"relay-test-utils": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-test-utils-1.6.1-plugin.1.tgz",
69+
"relay-compiler":
70+
"https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-compiler-1.6.1-plugin.1.tgz",
71+
"relay-runtime":
72+
"https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-runtime-1.6.1-plugin.1.tgz",
73+
"relay-test-utils":
74+
"https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-test-utils-1.6.1-plugin.1.tgz",
7375
"ts-jest": "^22.0.1",
7476
"tslint-config-prettier": "^1.15.0",
7577
"typescript": "2.8.1"
7678
},
7779
"resolutions": {
78-
"graphql-compiler": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/graphql-compiler-1.6.1-plugin.1.tgz",
79-
"relay-compiler": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-compiler-1.6.1-plugin.1.tgz",
80-
"relay-runtime": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-runtime-1.6.1-plugin.1.tgz",
81-
"relay-test-utils": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-test-utils-1.6.1-plugin.1.tgz"
80+
"graphql-compiler":
81+
"https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/graphql-compiler-1.6.1-plugin.1.tgz",
82+
"relay-compiler":
83+
"https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-compiler-1.6.1-plugin.1.tgz",
84+
"relay-runtime":
85+
"https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-runtime-1.6.1-plugin.1.tgz",
86+
"relay-test-utils":
87+
"https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-test-utils-1.6.1-plugin.1.tgz"
8288
},
8389
"jest": {
8490
"transform": {
8591
"^.+\\.tsx?$": "ts-jest"
8692
},
8793
"testRegex": "test/.+?-test\\.tsx?$",
88-
"moduleFileExtensions": [
89-
"js",
90-
"ts",
91-
"tsx"
92-
]
94+
"moduleFileExtensions": ["js", "ts", "tsx"]
9395
},
9496
"lint-staged": {
97+
"**/*.json": ["prettier --write", "git add"],
9598
"{src,types}/**/*.ts": [
9699
"tslint -c tslint.json --fix",
97100
"prettier --write",

src/FindGraphQLTags.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import * as ts from "typescript";
21
import * as path from "path";
2+
import * as ts from "typescript";
33
import * as util from "util";
44

55
import { GraphQLTag, GraphQLTagFinder } from "relay-compiler";
6-
import { callbackify } from "util";
76
import { isPropertyAccessOrQualifiedName } from "typescript";
7+
import { callbackify } from "util";
88

99
interface Location {
1010
line: number;

src/TypeScriptGenerator.ts

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { TypeGenerator, IRTransforms } from "relay-compiler";
1+
import { IRTransforms, TypeGenerator } from "relay-compiler";
22

3-
import * as ts from "typescript";
43
import * as path from "path";
4+
import * as ts from "typescript";
55

66
import {
7-
transformScalarType,
8-
transformInputType,
9-
ScalarTypeMapping,
10-
State
11-
} from "./TypeScriptTypeTransformers";
12-
import {
13-
GraphQLNonNull,
147
GraphQLEnumType,
15-
GraphQLType,
8+
GraphQLNamedType,
9+
GraphQLNonNull,
1610
GraphQLScalarType,
17-
GraphQLNamedType
11+
GraphQLType
1812
} from "graphql";
13+
import {
14+
ScalarTypeMapping,
15+
State,
16+
transformInputType,
17+
transformScalarType
18+
} from "./TypeScriptTypeTransformers";
1919

2020
// Get the types
2121
import * as GraphQLCompilerTypes from "graphql-compiler";
@@ -75,14 +75,8 @@ function makeProp(
7575
state: State,
7676
concreteType?: string
7777
): ts.PropertySignature {
78-
let {
79-
key,
80-
schemaName,
81-
value,
82-
conditional,
83-
nodeType,
84-
nodeSelections
85-
} = selection;
78+
let { value } = selection;
79+
const { key, schemaName, conditional, nodeType, nodeSelections } = selection;
8680
if (nodeType) {
8781
value = transformScalarType(
8882
nodeType,
@@ -353,7 +347,7 @@ function createVisitor(options: TypeGeneratorOptions) {
353347
});
354348
state.generatedFragments.add(node.name);
355349
const refTypeName = getRefTypeName(node.name);
356-
const refTypeNodes: ts.Node[] = []
350+
const refTypeNodes: ts.Node[] = [];
357351
if (options.useSingleArtifactDirectory) {
358352
const _refTypeName = `_${refTypeName}`;
359353
const _refType = ts.createVariableStatement(
@@ -375,14 +369,14 @@ function createVisitor(options: TypeGeneratorOptions) {
375369
refTypeName,
376370
ts.createTypeQueryNode(ts.createIdentifier(_refTypeName))
377371
);
378-
refTypeNodes.push(_refType)
379-
refTypeNodes.push(refType)
372+
refTypeNodes.push(_refType);
373+
refTypeNodes.push(refType);
380374
} else {
381375
const refType = exportType(
382376
refTypeName,
383377
ts.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)
384-
)
385-
refTypeNodes.push(refType)
378+
);
379+
refTypeNodes.push(refType);
386380
}
387381
const baseType = selectionsToAST(selections, state, refTypeName);
388382
const type = isPlural(node)
@@ -452,7 +446,7 @@ function createVisitor(options: TypeGeneratorOptions) {
452446
};
453447
}
454448

455-
function selectionsToMap(selections: Array<Selection>): SelectionMap {
449+
function selectionsToMap(selections: Selection[]): SelectionMap {
456450
const map = new Map();
457451
selections.forEach(selection => {
458452
const previousSel = map.get(selection.key);

src/TypeScriptTypeTransformers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as ts from "typescript";
22

33
import {
44
GraphQLEnumType,
5-
GraphQLInputType,
65
GraphQLInputObjectType,
6+
GraphQLInputType,
77
GraphQLInterfaceType,
88
GraphQLList,
99
GraphQLNonNull,

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PluginInterface } from "relay-compiler";
22

3-
import { formatGeneratedModule } from "./formatGeneratedModule";
43
import { find } from "./FindGraphQLTags";
4+
import { formatGeneratedModule } from "./formatGeneratedModule";
55
import * as TypeScriptGenerator from "./TypeScriptGenerator";
66

77
export default function plugin(): PluginInterface {

tslint.json

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
{
2-
"defaultSeverity": "error",
3-
"extends": [
4-
"tslint:recommended",
5-
"tslint-config-prettier"
6-
],
7-
"jsRules": {},
8-
"rules": {},
9-
"rulesDirectory": []
2+
"defaultSeverity": "error",
3+
"extends": ["tslint:recommended", "tslint-config-prettier"],
4+
"jsRules": {},
5+
"rules": {
6+
"curly": false,
7+
"interface-name": [true, "never-prefix"],
8+
"max-classes-per-file": false,
9+
"member-access": [false],
10+
"no-shadowed-variable": false,
11+
"member-ordering": false,
12+
"forin": false,
13+
"no-console": false,
14+
"no-namespace": [true, "allow-declarations"],
15+
"no-unused-expression": false,
16+
"no-var-requires": false,
17+
"object-literal-sort-keys": false,
18+
"ordered-imports": true,
19+
"trailing-comma": false,
20+
"interface-over-type-literal": false,
21+
"variable-name": [true, "ban-keywords", "allow-leading-underscore"],
22+
"jsdoc-format": false
23+
},
24+
"rulesDirectory": []
1025
}

0 commit comments

Comments
 (0)