Skip to content

Commit a4f4375

Browse files
author
minwe
committed
add import react-dom template; add trailing comma to PropTypes
1 parent 8249a47 commit a4f4375

File tree

7 files changed

+232
-178
lines changed

7 files changed

+232
-178
lines changed

README.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# jetbrains-react
22

3-
React snippets([live templates](https://www.jetbrains.com/help/idea/2016.1/live-templates.html)) for JetBrains series editors (e.g. WebStorm, PHPStorm, IntelliJ IDEA, etc.), stolen from [sublime-react](https://github.com/reactjs/sublime-react) and [phpstorm-reactjs](https://github.com/Minwe/phpstorm-reactjs).
4-
5-
- [Working with ReactJS in WebStorm: Coding Assistance](http://blog.jetbrains.com/webstorm/2015/10/working-with-reactjs-in-webstorm-coding-assistance/)
3+
React snippets([live templates](https://www.jetbrains.com/help/idea/2016.1/live-templates.html)) for JetBrains series editors (e.g. WebStorm, PHPStorm, IntelliJ IDEA, etc.), stolen from [sublime-react](https://github.com/reactjs/sublime-react) and [phpstorm-reactjs](https://github.com/geochatz/phpstorm-reactjs).
64

75
## Installation
86

9-
### Importing
7+
### Import Automatically
108

11-
1. Download `jetbrains-react.jar`;
12-
2. Click `File` -> `Importing Settings...` on your IDE menubar, select `jetbrains-react.jar`, then click `OK`.
9+
1. Download [`settings.jar`](https://github.com/minwe/jetbrains-react/raw/master/settings.jar);
10+
2. Click `File` -> `Importing Settings...` on your IDE menu, select `settings.jar`, then click `OK`.
1311

1412
### Install Manually
1513

@@ -28,11 +26,15 @@ React snippets([live templates](https://www.jetbrains.com/help/idea/2016.1/live-
2826

2927
## Usage
3028

31-
It's hard to remember shortcuts when there are a large number of options. A more efficient way is to take advantage of editor's Insert Live Template shortcut. Press `Cmd + J` and type as many letters as you want to filter the resulates.
29+
It's hard to remember shortcuts when there are a large number of options. A more efficient way is to take advantage of editor's Insert Live Template shortcut. Press `Cmd + J` and type as many letters as you want to filter the results.
3230

3331
For example, to create a new React class, type `rcc` and press `Tab` or press `Cmd + J` and write `rcc` or `React`.
3432

35-
**Documentation of available snippets (JSX):**
33+
**The WebStorm official blog post**:
34+
35+
- [Working with ReactJS in WebStorm: Coding Assistance](http://blog.jetbrains.com/webstorm/2015/10/working-with-reactjs-in-webstorm-coding-assistance/)
36+
37+
**Documentation of available snippets:**
3638

3739
<!--DOC_START-->
3840
### `rcc`
@@ -97,6 +99,22 @@ export default $class$;
9799

98100
```
99101

102+
### `rdom`
103+
104+
```js
105+
import ReactDOM from 'react-dom';
106+
$END$
107+
108+
```
109+
110+
### `rdom5`
111+
112+
```js
113+
var ReactDOM = require('react-dom');
114+
$END$
115+
116+
```
117+
100118
### `rccc`
101119

102120
```js
@@ -327,15 +345,15 @@ dangerouslySetInnerHTML={{__html: '$END$'}}
327345

328346
```js
329347
propTypes: {
330-
$START$: PropTypes.$END$
348+
$START$: PropTypes.$END$,
331349
},
332350

333351
```
334352

335353
### `pt`
336354

337355
```js
338-
$START$: PropTypes.$END$
356+
$START$: PropTypes.$END$,
339357
```
340358

341359
### `refs`
@@ -388,7 +406,7 @@ shouldComponentUpdate: function(nextProps, nextState, nextContext) {
388406

389407
```js
390408
this.setState({
391-
$START$: $END$
409+
$START$: $END$,
392410
});
393411

394412
```
@@ -403,7 +421,7 @@ this.state.$END$
403421

404422
```js
405423
contextTypes: {
406-
$START$: PropTypes.$END$
424+
$START$: PropTypes.$END$,
407425
},
408426

409427
```
@@ -412,7 +430,7 @@ contextTypes: {
412430

413431
```js
414432
childContextTypes: {
415-
$START$: PropTypes.$END$
433+
$START$: PropTypes.$END$,
416434
},
417435

418436
```
@@ -455,7 +473,7 @@ static displayName = '$END$';
455473

456474
```js
457475
static propTypes = {
458-
$START$: PropTypes.$END$
476+
$START$: PropTypes.$END$,
459477
};
460478

461479
```
@@ -464,7 +482,7 @@ static propTypes = {
464482

465483
```js
466484
static defaultProps = {
467-
$START$: PropTypes.$END$
485+
$START$: PropTypes.$END$,
468486
};
469487

470488
```
@@ -473,7 +491,7 @@ static defaultProps = {
473491

474492
```js
475493
static contextTypes = {
476-
$START$: PropTypes.$END$
494+
$START$: PropTypes.$END$,
477495
};
478496

479497
```
@@ -482,7 +500,7 @@ static contextTypes = {
482500

483501
```js
484502
static childContextTypes = {
485-
$START$: PropTypes.$END$
503+
$START$: PropTypes.$END$,
486504
};
487505

488506
```

gulpfile.js renamed to build.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
'use strict';
22

33
const fs = require('fs');
4-
const gulp = require('gulp');
5-
const zip = require('gulp-zip');
64
const yaml = require('js-yaml');
75
const Handlebars = require('handlebars');
6+
const read = (file) => {
7+
return fs.readFileSync(file, 'utf8');
8+
};
89

9-
const template = Handlebars.compile(fs.readFileSync('src/ReactJS.hbs', 'utf8'));
10-
const docTpl = Handlebars.compile(fs.readFileSync('src/doc.hbs', 'utf8'));
11-
const readme = fs.readFileSync('README.md', 'utf8');
12-
const templates = yaml.safeLoad(fs.readFileSync('src/template.yaml', 'utf8'));
13-
const eventsTpl = yaml.safeLoad(fs.readFileSync('src/events.yaml', 'utf8'));
10+
const template = Handlebars.compile(read('src/ReactJS.hbs'));
11+
const docTpl = Handlebars.compile(read('src/doc.hbs'));
12+
const readme = read('README.md');
13+
const templates = yaml.safeLoad(read('src/template.yaml'));
14+
const eventsTpl = yaml.safeLoad(read('src/events.yaml'));
1415

1516
let escapeTpl = (tpl) => {
1617
tpl = tpl.replace(/\n/g, '&#10;')
@@ -35,7 +36,7 @@ Object.keys(templates).forEach((k) => {
3536

3637
var snippet = {
3738
name: k,
38-
description: t.description || t.tpl,
39+
description: `React: ${t.description || t.tpl}`,
3940
tpl: escapeTpl(tpl),
4041
variables: t.variables || [],
4142
tplRaw: tpl
@@ -49,7 +50,7 @@ Object.keys(templates).forEach((k) => {
4950
var tpl5 = t.tpl.es5 || t.tpl;
5051
var snippet5 = {
5152
name: k + '5',
52-
description: t.description || t.tpl,
53+
description: `React: ${t.description || t.tpl}`,
5354
tpl: escapeTpl(tpl5),
5455
variables: t.variables || [],
5556
tplRaw: tpl5
@@ -66,7 +67,7 @@ function processEventsTpl(eventsMap) {
6667

6768
data.push({
6869
name: tplName,
69-
description: key,
70+
description: `React: ${key}`,
7071
tpl: escapeTpl(tpl),
7172
tplRaw: tpl
7273
});
@@ -82,8 +83,5 @@ fs.writeFileSync('README.md', readme.replace(
8283
return $1 + '\n' + docTpl(data) + '\n' + $2;
8384
}));
8485

85-
gulp.task('default', () => {
86-
return gulp.src('jetbrains/**/*')
87-
.pipe(zip('jetbrains-react.jar'))
88-
.pipe(gulp.dest('.'));
89-
});
86+
// build jar
87+
// @see http://www.codejava.net/java-core/tools/using-jar-command-examples

jetbrains-react.jar

-2.92 KB
Binary file not shown.

0 commit comments

Comments
 (0)