Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit a042258

Browse files
committed
[README] Link to tslint rules
1 parent 7ee04dc commit a042258

File tree

1 file changed

+43
-21
lines changed

1 file changed

+43
-21
lines changed

README.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[![Build Status](https://travis-ci.org/relay-tools/relay-compiler-language-typescript.svg?branch=master)](https://travis-ci.org/relay-tools/relay-compiler-language-typescript)
44

5-
A language plugin for [Relay](https://facebook.github.io/relay/) that adds TypeScript support, including emitting type
6-
definitions.
5+
A language plugin for [Relay](https://facebook.github.io/relay/) that adds
6+
TypeScript support, including emitting type definitions.
77

88
## Installation
99

@@ -23,24 +23,26 @@ Then configure your `relay-compiler` script to use it, like so:
2323
```json
2424
{
2525
"scripts": {
26-
"relay": "relay-compiler --src ./src --schema data/schema.graphql --language typescript --artifactDirectory ./src/__generated__"
26+
"relay":
27+
"relay-compiler --src ./src --schema data/schema.graphql --language typescript --artifactDirectory ./src/__generated__"
2728
}
2829
}
2930
```
3031

31-
This is going to store all artifacts in a single directory, which you also need to instruct `babel-plugin-relay` to use in your `.babelrc`:
32+
This is going to store all artifacts in a single directory, which you also need
33+
to instruct `babel-plugin-relay` to use in your `.babelrc`:
3234

3335
```json
3436
{
35-
"plugins": [
36-
["relay", { "artifactDirectory": "./src/__generated__" }]
37-
]
37+
"plugins": [["relay", { "artifactDirectory": "./src/__generated__" }]]
3838
}
3939
```
4040

4141
### TypeScript
4242

43-
Also be sure to configure the TypeScript compiler to transpile to `es2015` modules and leave transpilation to `commonjs` modules up to Babel with the following `tsconfig.json` settings:
43+
Also be sure to configure the TypeScript compiler to transpile to `es2015`
44+
modules and leave transpilation to `commonjs` modules up to Babel with the
45+
following `tsconfig.json` settings:
4446

4547
```json
4648
{
@@ -51,34 +53,54 @@ Also be sure to configure the TypeScript compiler to transpile to `es2015` modul
5153
}
5254
```
5355

54-
The reason for this is that `tsc` would otherwise generate code where the imported `graphql` function is being namespaced (`react_relay_1` in this example):
56+
The reason for this is that `tsc` would otherwise generate code where the
57+
imported `graphql` function is being namespaced (`react_relay_1` in this
58+
example):
5559

5660
```js
57-
react_relay_1.createFragmentContainer(MyComponent, react_relay_1.graphql `
61+
react_relay_1.createFragmentContainer(
62+
MyComponent,
63+
react_relay_1.graphql`
5864
...
59-
`);
65+
`
66+
);
6067
```
6168

62-
…and this makes it impossible for `babel-plugin-relay` to find the locations where the `graphql` function is being used.
69+
…and this makes it impossible for `babel-plugin-relay` to find the locations
70+
where the `graphql` function is being used.
6371

64-
Note that this does mean you need to configure Babel to transform the ES module `import` and `export` statements, by using the [`babel-plugin-transform-es2015-modules-commonjs`](https://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/) transform plugin, if you’re not already.
72+
Note that this does mean you need to configure Babel to transform the ES module
73+
`import` and `export` statements, by using the
74+
[`babel-plugin-transform-es2015-modules-commonjs`](https://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/)
75+
transform plugin, if you’re not already.
6576

6677
## Problems
6778

6879
### React Hot Loader
6980

70-
React Hot Loader is known to not always work well with generated code such as our typing artefacts, which will lead to loading modules _with_ TypeScript types into the browser and break. As a maintainer of RHL [pointed out](https://github.com/gaearon/react-hot-loader/issues/1032) in a similar issue:
81+
React Hot Loader is known to not always work well with generated code such as
82+
our typing artefacts, which will lead to loading modules _with_ TypeScript types
83+
into the browser and break. As a maintainer of RHL
84+
[pointed out](https://github.com/gaearon/react-hot-loader/issues/1032) in a
85+
similar issue:
7186

72-
> The problem - hot reloading is not "complete"
87+
> The problem - hot reloading is not "complete"
7388
74-
So [until RHL will be made “complete”](https://github.com/gaearon/react-hot-loader/issues/1024) this project can’t gurantee to always work well with it, nor is it our control to do anything about that.
89+
So
90+
[until RHL will be made “complete”](https://github.com/gaearon/react-hot-loader/issues/1024)
91+
this project can’t gurantee to always work well with it, nor is it our control
92+
to do anything about that.
7593

76-
## Examples
94+
## Also see
7795

78-
You can find a copy of the Relay
79-
[example TODO app](https://github.com/kastermester/relay-compiler-language-typescript/tree/master/example) inside this
80-
repository or you can take a look at the [Artsy React Native app](https://github.com/artsy/emission).
96+
* You can find a copy of the Relay
97+
[example TODO app](https://github.com/kastermester/relay-compiler-language-typescript/tree/master/example)
98+
inside this repository or you can take a look at the
99+
[Artsy React Native app](https://github.com/artsy/emission).
100+
* There are Relay tslint rules available
101+
[here](https://github.com/relay-tools/tslint-plugin-relay).
81102

82103
## License
83104

84-
This package is available under the MIT license. See the included LICENSE file for details.
105+
This package is available under the MIT license. See the included LICENSE file
106+
for details.

0 commit comments

Comments
 (0)