├── .gitignore ├── images ├── 1.jpg ├── 2.jpg └── 3.gif ├── src └── com │ └── jinsihou │ └── react │ └── snippets │ └── ReactTemplateProvider.java ├── LICENSE ├── resources ├── META-INF │ └── plugin.xml └── liveTemplates │ └── React.xml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | out 3 | *.jar 4 | -------------------------------------------------------------------------------- /images/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinsihou19/ReactSnippets/HEAD/images/1.jpg -------------------------------------------------------------------------------- /images/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinsihou19/ReactSnippets/HEAD/images/2.jpg -------------------------------------------------------------------------------- /images/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinsihou19/ReactSnippets/HEAD/images/3.gif -------------------------------------------------------------------------------- /src/com/jinsihou/react/snippets/ReactTemplateProvider.java: -------------------------------------------------------------------------------- 1 | package com.jinsihou.react.snippets; 2 | 3 | 4 | import com.intellij.codeInsight.template.TemplateActionContext; 5 | import com.intellij.codeInsight.template.TemplateContextType; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | /** 9 | * @author jinsihou 10 | * @date 2017/10/18 11 | */ 12 | public class ReactTemplateProvider extends TemplateContextType { 13 | protected ReactTemplateProvider() { 14 | super("REACT", "React"); 15 | } 16 | 17 | @Override 18 | public boolean isInContext(@NotNull TemplateActionContext templateActionContext) { 19 | String name = templateActionContext.getFile().getName(); 20 | return name.endsWith(".js") || name.endsWith(".jsx") || name.endsWith(".html") || name.endsWith(".ts"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 jinsihou19 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /resources/META-INF/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | com.jinsihou.react.snippets 3 | React snippets 4 | 1.1.1 5 | jinsihou 6 | 7 | 9 | Show details in Preferences -> Editor -> Live Templates -> React Group. 10 | ]]> 11 | 12 | v1.1.1
14 |
  • Migrate deprecated APIs to support hot deployment
  • 15 | v1.1.0
    16 |
  • Supported react 16.8.0 hooks
  • 17 |
  • add cref snippet
  • 18 |
  • add cctx snippet
  • 19 |
  • add hoc snippet
  • 20 |
    21 | v1.0.0
    22 |
  • Add all the snippets that can be used for prop types.
  • 23 | ]]> 24 |
    25 | 26 | 27 | 28 | 29 | 31 | 34 | com.intellij.modules.lang 35 | com.intellij.modules.platform 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
    -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReactSnippets 2 | Live Templates for React in IntelliJ products webstorm and idea. 3 | 4 | ![react_snippets](images/3.gif) 5 | 6 | ![react_snippets](images/1.jpg) 7 | 8 | ![react_snippets](images/2.jpg) 9 | 10 | | Trigger | Content | 11 | | --- | --- | 12 | | `rcc` | class component skeleton | 13 | | `rrc` | class component skeleton with react-redux connect | 14 | | `rccp` | class component skeleton with prop types after the class | 15 | | `rcfc` | class component skeleton that contains all the lifecycle methods | 16 | | `rsc` | stateless component skeleton | 17 | | `rscp` | stateless component with prop types skeleton | 18 | | `pt` | empty propTypes declaration | 19 | | `con` | class default constructor with props | 20 | | `conc` | class default constructor with props and context | 21 | | `cwm` | `componentWillMount` method | 22 | | `cdm` | `componentDidMount` method | 23 | | `cwr` | `componentWillReceiveProps` method | 24 | | `scu` | `shouldComponentUpdate` method | 25 | | `cwup` | `componentWillUpdate` method | 26 | | `cdup` | `componentDidUpdate` method | 27 | | `cwun` | `componentWillUnmount` method | 28 | | `ren` | `render` method | 29 | | `bind` | binds the `this` of method inside the constructor | 30 | | `hoc` | higher-order component | 31 | | `cref` | creates a ref. | 32 | | `cctx` | creates a context | 33 | 34 | Add all the snippets that can be used for prop types. 35 | 36 | | Trigger | Content | 37 | | --- | --- | 38 | | `pta` | `PropTypes.array,` | 39 | | `ptar` | `PropTypes.array.isRequired,` | 40 | | `ptb` | `PropTypes.bool,` | 41 | | `ptbr` | `PropTypes.bool.isRequired,` | 42 | | `ptf` | `PropTypes.func,` | 43 | | `ptfr` | `PropTypes.func.isRequired,` | 44 | | `ptn` | `PropTypes.number,` | 45 | | `ptnr` | `PropTypes.number.isRequired,` | 46 | | `pto` | `PropTypes.object,` | 47 | | `ptor` | `PropTypes.object.isRequired,` | 48 | | `pts` | `PropTypes.string,` | 49 | | `ptsr` | `PropTypes.string.isRequired,` | 50 | | `ptnd` | `PropTypes.node,` | 51 | | `ptndr` | `PropTypes.node.isRequired,` | 52 | | `ptel` | `PropTypes.element,` | 53 | | `ptelr` | `PropTypes.element.isRequired,` | 54 | | `pti` | `PropTypes.instanceOf(ClassName),` | 55 | | `ptir` | `PropTypes.instanceOf(ClassName).isRequired,` | 56 | | `pte` | `PropTypes.oneOf(['News', 'Photos']),` | 57 | | `pter` | `PropTypes.oneOf(['News', 'Photos']).isRequired,` | 58 | | `ptet` | `PropTypes.oneOfType([PropTypes.string, PropTypes.number]),` | 59 | | `ptetr` | `PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,` | 60 | | `ptao` | `PropTypes.arrayOf(PropTypes.number),` | 61 | | `ptaor` | `PropTypes.arrayOf(PropTypes.number).isRequired,` | 62 | | `ptoo` | `PropTypes.objectOf(PropTypes.number),` | 63 | | `ptoor` | `PropTypes.objectOf(PropTypes.number).isRequired,` | 64 | | `ptsh` | `PropTypes.shape({color: PropTypes.string, fontSize: PropTypes.number}),` | 65 | | `ptshr` | `PropTypes.shape({color: PropTypes.string, fontSize: PropTypes.number}).isRequired,` | 66 | 67 | Hooks 68 | 69 | All hooks from [official docs](https://reactjs.org/docs/hooks-reference.html) are supported with hook name prefix. 70 | -------------------------------------------------------------------------------- /resources/liveTemplates/React.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 18 | 25 | 32 | 39 | 44 | 49 | 54 | 59 | 64 | 72 | 77 | 82 | 87 | 93 | 102 | 110 | 116 | 123 | 130 | 137 | 144 | 151 | 158 | 165 | 172 | 179 | 186 | 193 | 197 | 205 | 213 | 220 | 227 | 234 | 241 | 249 | 257 | 265 | 273 | 280 | 287 | 294 | 302 | 309 | 313 | 320 | 330 | 340 | 349 | 359 | 370 | 380 | 389 | 398 | 408 | 416 | 424 | 431 | 441 | 442 | --------------------------------------------------------------------------------