From f13e27e08b28f8938cf8db6e77874d15c0262367 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 22:07:55 +0900 Subject: [PATCH 01/10] Add .yas-setup.el for rjsx-mode --- .../rjsx-mode/{.yasparents => .yas-parents} | 0 snippets/rjsx-mode/yas-setup.el | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+) rename snippets/rjsx-mode/{.yasparents => .yas-parents} (100%) create mode 100644 snippets/rjsx-mode/yas-setup.el diff --git a/snippets/rjsx-mode/.yasparents b/snippets/rjsx-mode/.yas-parents similarity index 100% rename from snippets/rjsx-mode/.yasparents rename to snippets/rjsx-mode/.yas-parents diff --git a/snippets/rjsx-mode/yas-setup.el b/snippets/rjsx-mode/yas-setup.el new file mode 100644 index 0000000..db0fd3a --- /dev/null +++ b/snippets/rjsx-mode/yas-setup.el @@ -0,0 +1,20 @@ +;;; .yas-setup.el --- Yasnippet helper functions for JSX snippets + +;;; Commentary: + +;;; Code: + +(require 'yasnippet) + +(defun yas-jsx-get-class-name-by-file-name () + "Return name of class-like construct by `file-name'." + (if buffer-file-name + (let ((class-name (file-name-nondirectory + (file-name-sans-extension buffer-file-name)))) + (if (equal class-name "index") + (file-name-nondirectory + (directory-file-name (file-name-directory buffer-file-name))) + class-name)) + "")) + +;;; .yas-setup.el ends here From 92a161cadc04ffe574ee66603d95b3f1e507da13 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 22:23:47 +0900 Subject: [PATCH 02/10] Remove snippets of unsafe React methods --- snippets/rjsx-mode/React/cwm | 10 ---------- snippets/rjsx-mode/React/cwr | 10 ---------- snippets/rjsx-mode/React/cwup | 10 ---------- 3 files changed, 30 deletions(-) delete mode 100644 snippets/rjsx-mode/React/cwm delete mode 100644 snippets/rjsx-mode/React/cwr delete mode 100644 snippets/rjsx-mode/React/cwup diff --git a/snippets/rjsx-mode/React/cwm b/snippets/rjsx-mode/React/cwm deleted file mode 100644 index 2291ee1..0000000 --- a/snippets/rjsx-mode/React/cwm +++ /dev/null @@ -1,10 +0,0 @@ -# -*- mode: snippet -*- -# uuid: dba0d644-e837-40ad-8082-bbe583fa444f -# contributor: Jimmy Yuen Ho Wong -# name: componentWillMount -# key: cwm -# -- - -componentWillMount = () => { - $0 -} \ No newline at end of file diff --git a/snippets/rjsx-mode/React/cwr b/snippets/rjsx-mode/React/cwr deleted file mode 100644 index b206bc9..0000000 --- a/snippets/rjsx-mode/React/cwr +++ /dev/null @@ -1,10 +0,0 @@ -# -*- mode: snippet -*- -# uuid: 59e0e0d0-6efb-475f-a482-3d76f2f561a0 -# contributor: Jimmy Yuen Ho Wong -# name: componentWillReceiveProps -# key: cwr -# -- - -componentWillReceiveProps = (nextProps) => { - $0 -} \ No newline at end of file diff --git a/snippets/rjsx-mode/React/cwup b/snippets/rjsx-mode/React/cwup deleted file mode 100644 index c083e67..0000000 --- a/snippets/rjsx-mode/React/cwup +++ /dev/null @@ -1,10 +0,0 @@ -# -*- mode: snippet -*- -# uuid: cd9a8917-1ad1-4de8-a382-cdf0c2e72943 -# contributor: Jimmy Yuen Ho Wong -# name: componentWillUpdate -# key: cwup -# -- - -componentWillUpdate = (nextProps, nextState) => { - $0 -} \ No newline at end of file From f1ed0bf495768d4596bb8849bea6d41a181183f9 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 22:24:08 +0900 Subject: [PATCH 03/10] Remove snippets of SFC without arrow function --- snippets/rjsx-mode/React/rfc | 16 ---------------- snippets/rjsx-mode/React/rfce | 18 ------------------ snippets/rjsx-mode/React/rfcp | 23 ----------------------- 3 files changed, 57 deletions(-) delete mode 100644 snippets/rjsx-mode/React/rfc delete mode 100644 snippets/rjsx-mode/React/rfce delete mode 100644 snippets/rjsx-mode/React/rfcp diff --git a/snippets/rjsx-mode/React/rfc b/snippets/rjsx-mode/React/rfc deleted file mode 100644 index 9bc4c1e..0000000 --- a/snippets/rjsx-mode/React/rfc +++ /dev/null @@ -1,16 +0,0 @@ -# -*- mode: snippet -*- -# uuid: 65bc7baa-3368-4398-a208-fb1d92694183 -# contributor: Jimmy Yuen Ho Wong -# name: reactFunctionalComponent -# key: rfc -# -- - -import React from 'react' - -export default function ${1:${TM_FILENAME_BASE}}() { - return ( -
- $0 -
- ) -} \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rfce b/snippets/rjsx-mode/React/rfce deleted file mode 100644 index a046dac..0000000 --- a/snippets/rjsx-mode/React/rfce +++ /dev/null @@ -1,18 +0,0 @@ -# -*- mode: snippet -*- -# uuid: 48f9521a-2b4e-4f71-850e-ecd47261a7a6 -# contributor: Jimmy Yuen Ho Wong -# name: reactFunctionalExportComponent -# key: rfce -# -- - -import React from 'react' - -function ${1:${TM_FILENAME_BASE}}() { - return ( -
- $0 -
- ) -} - -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rfcp b/snippets/rjsx-mode/React/rfcp deleted file mode 100644 index 69aea19..0000000 --- a/snippets/rjsx-mode/React/rfcp +++ /dev/null @@ -1,23 +0,0 @@ -# -*- mode: snippet -*- -# uuid: f24b6de3-135e-4da0-81d9-0f479f3b11dd -# contributor: Jimmy Yuen Ho Wong -# name: reactFunctionalComponentWithPropTypes -# key: rfcp -# -- - -import React from 'react' -import PropTypes from 'prop-types' - -function ${1:${TM_FILENAME_BASE}}(props) { - return ( -
- $0 -
- ) -} - -${1:${TM_FILENAME_BASE}}.propTypes = { - -} - -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file From a7226e786195986bf0fa88ee5fd5430c2846bc02 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 22:26:20 +0900 Subject: [PATCH 04/10] Update snippets of React component methods --- snippets/rjsx-mode/React/cdm | 2 +- snippets/rjsx-mode/React/cdup | 2 +- snippets/rjsx-mode/React/cwun | 2 +- snippets/rjsx-mode/React/gdsfp | 4 ++-- snippets/rjsx-mode/React/gsbu | 2 +- snippets/rjsx-mode/React/scu | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/snippets/rjsx-mode/React/cdm b/snippets/rjsx-mode/React/cdm index 60cfe41..56f55cf 100644 --- a/snippets/rjsx-mode/React/cdm +++ b/snippets/rjsx-mode/React/cdm @@ -5,6 +5,6 @@ # key: cdm # -- -componentDidMount = () => { +componentDidMount() { $0 } \ No newline at end of file diff --git a/snippets/rjsx-mode/React/cdup b/snippets/rjsx-mode/React/cdup index 2b17378..0ef2bf7 100644 --- a/snippets/rjsx-mode/React/cdup +++ b/snippets/rjsx-mode/React/cdup @@ -5,6 +5,6 @@ # key: cdup # -- -componentDidUpdate = (prevProps, prevState) => { +componentDidUpdate(prevProps, prevState, snapshot) { $0 } \ No newline at end of file diff --git a/snippets/rjsx-mode/React/cwun b/snippets/rjsx-mode/React/cwun index e592627..a89790b 100644 --- a/snippets/rjsx-mode/React/cwun +++ b/snippets/rjsx-mode/React/cwun @@ -5,6 +5,6 @@ # key: cwun # -- -componentWillUnmount = () => { +componentWillUnmount() { $0 } \ No newline at end of file diff --git a/snippets/rjsx-mode/React/gdsfp b/snippets/rjsx-mode/React/gdsfp index 217f9ea..603969f 100644 --- a/snippets/rjsx-mode/React/gdsfp +++ b/snippets/rjsx-mode/React/gdsfp @@ -5,6 +5,6 @@ # key: gdsfp # -- -static getDerivedStateFromProps(props, state) { - ${1} +static getDerivedStateFromProps(nextProps, prevState) { + $0 } \ No newline at end of file diff --git a/snippets/rjsx-mode/React/gsbu b/snippets/rjsx-mode/React/gsbu index dc25673..83c29c8 100644 --- a/snippets/rjsx-mode/React/gsbu +++ b/snippets/rjsx-mode/React/gsbu @@ -5,6 +5,6 @@ # key: gsbu # -- -getSnapshotBeforeUpdate = (prevProps, prevState) => { +getSnapshotBeforeUpdate(prevProps, prevState) { $0 } \ No newline at end of file diff --git a/snippets/rjsx-mode/React/scu b/snippets/rjsx-mode/React/scu index 19062dc..314b079 100644 --- a/snippets/rjsx-mode/React/scu +++ b/snippets/rjsx-mode/React/scu @@ -5,6 +5,6 @@ # key: scu # -- -shouldComponentUpdate = (nextProps, nextState) => { +shouldComponentUpdate(nextProps, nextState) { $0 } \ No newline at end of file From 52f2eb5a47cc337948799cdf0278ed085f432023 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 22:32:38 +0900 Subject: [PATCH 05/10] Fix TM_FILENAME_BASE in some React snippets --- snippets/rjsx-mode/React/rafc | 4 ++-- snippets/rjsx-mode/React/rafce | 4 ++-- snippets/rjsx-mode/React/rafcp | 6 +++--- snippets/rjsx-mode/React/rcc | 2 +- snippets/rjsx-mode/React/rccp | 2 +- snippets/rjsx-mode/React/rce | 4 ++-- snippets/rjsx-mode/React/rcep | 4 ++-- snippets/rjsx-mode/React/rmc | 12 +++++------- snippets/rjsx-mode/React/rmcp | 16 +++++++--------- snippets/rjsx-mode/React/rpc | 2 +- snippets/rjsx-mode/React/rpce | 4 ++-- snippets/rjsx-mode/React/rpcp | 2 +- 12 files changed, 29 insertions(+), 33 deletions(-) diff --git a/snippets/rjsx-mode/React/rafc b/snippets/rjsx-mode/React/rafc index 009798d..990ecc4 100644 --- a/snippets/rjsx-mode/React/rafc +++ b/snippets/rjsx-mode/React/rafc @@ -7,7 +7,7 @@ import React from 'react' -const ${1:${TM_FILENAME_BASE}} = () => { +const ${1:`(yas-jsx-get-class-name-by-file-name)`} = (props) => { return (
$0 @@ -15,4 +15,4 @@ const ${1:${TM_FILENAME_BASE}} = () => { ) } -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file +export default $1 \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rafce b/snippets/rjsx-mode/React/rafce index 3ec7d15..f92fdc2 100644 --- a/snippets/rjsx-mode/React/rafce +++ b/snippets/rjsx-mode/React/rafce @@ -7,7 +7,7 @@ import React from 'react' -const ${1:${TM_FILENAME_BASE}} = () => { +const ${1:`(yas-jsx-get-class-name-by-file-name)`} = (props) => { return (
$0 @@ -15,4 +15,4 @@ const ${1:${TM_FILENAME_BASE}} = () => { ) } -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file +export default $1 \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rafcp b/snippets/rjsx-mode/React/rafcp index 7983913..7ab41c6 100644 --- a/snippets/rjsx-mode/React/rafcp +++ b/snippets/rjsx-mode/React/rafcp @@ -8,7 +8,7 @@ import React from 'react' import PropTypes from 'prop-types' -const ${1:${TM_FILENAME_BASE}} = props => { +const ${1:`(yas-jsx-get-class-name-by-file-name)`} = (props) => { return (
$0 @@ -16,8 +16,8 @@ const ${1:${TM_FILENAME_BASE}} = props => { ) } -${1:${TM_FILENAME_BASE}}.propTypes = { +$1.propTypes = { } -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file +export default $1 \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rcc b/snippets/rjsx-mode/React/rcc index b334078..eb677ca 100644 --- a/snippets/rjsx-mode/React/rcc +++ b/snippets/rjsx-mode/React/rcc @@ -7,7 +7,7 @@ import React, { Component } from 'react' -export default class ${1:${TM_FILENAME_BASE}} extends Component { +export default class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component { render() { return (
diff --git a/snippets/rjsx-mode/React/rccp b/snippets/rjsx-mode/React/rccp index 6dbd65b..74ae638 100644 --- a/snippets/rjsx-mode/React/rccp +++ b/snippets/rjsx-mode/React/rccp @@ -8,7 +8,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' -export default class ${1:${TM_FILENAME_BASE}} extends Component { +export default class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component { static propTypes = { ${2:prop}: ${3:PropTypes} } diff --git a/snippets/rjsx-mode/React/rce b/snippets/rjsx-mode/React/rce index ee9f981..cdb21ad 100644 --- a/snippets/rjsx-mode/React/rce +++ b/snippets/rjsx-mode/React/rce @@ -7,7 +7,7 @@ import React, { Component } from 'react' -export class ${1:${TM_FILENAME_BASE}} extends Component { +export class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component { render() { return (
@@ -17,4 +17,4 @@ export class ${1:${TM_FILENAME_BASE}} extends Component { } } -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file +export default $1 \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rcep b/snippets/rjsx-mode/React/rcep index 542f645..ce9a681 100644 --- a/snippets/rjsx-mode/React/rcep +++ b/snippets/rjsx-mode/React/rcep @@ -8,7 +8,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' -export class ${1:${TM_FILENAME_BASE}} extends Component { +export class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component { static propTypes = { } @@ -22,4 +22,4 @@ export class ${1:${TM_FILENAME_BASE}} extends Component { } } -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file +export default $1 \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rmc b/snippets/rjsx-mode/React/rmc index 2fe6a41..f4d7d83 100644 --- a/snippets/rjsx-mode/React/rmc +++ b/snippets/rjsx-mode/React/rmc @@ -7,10 +7,8 @@ import React, { memo } from 'react' -export default memo(function ${1:${TM_FILENAME_BASE}}() { - return ( -
- $0 -
- ) -}) \ No newline at end of file +export default memo((props) => ( +
+ $0 +
+)) \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rmcp b/snippets/rjsx-mode/React/rmcp index 71861b8..bc83f7a 100644 --- a/snippets/rjsx-mode/React/rmcp +++ b/snippets/rjsx-mode/React/rmcp @@ -8,16 +8,14 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -const ${1:${TM_FILENAME_BASE}} = memo(function ${1:${TM_FILENAME_BASE}}(props) { - return ( -
- $0 -
- ) -}) +const ${1:`(yas-jsx-get-class-name-by-file-name)`} = memo((props) => ( +
+ $0 +
+)) -${1:${TM_FILENAME_BASE}}.propTypes = { +$1.propTypes = { } -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file +export default $1 \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rpc b/snippets/rjsx-mode/React/rpc index dd8e884..9bac4c2 100644 --- a/snippets/rjsx-mode/React/rpc +++ b/snippets/rjsx-mode/React/rpc @@ -7,7 +7,7 @@ import React, { PureComponent } from 'react' -export default class ${1:${TM_FILENAME_BASE}} extends PureComponent { +export default class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends PureComponent { render() { return (
diff --git a/snippets/rjsx-mode/React/rpce b/snippets/rjsx-mode/React/rpce index 08f5598..a1a2c32 100644 --- a/snippets/rjsx-mode/React/rpce +++ b/snippets/rjsx-mode/React/rpce @@ -7,7 +7,7 @@ import React, { PureComponent } from 'react' -export class ${1:${TM_FILENAME_BASE}} extends PureComponent { +export class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends PureComponent { render() { return (
@@ -17,4 +17,4 @@ export class ${1:${TM_FILENAME_BASE}} extends PureComponent { } } -export default ${1:$TM_FILENAME_BASE} \ No newline at end of file +export default $1 \ No newline at end of file diff --git a/snippets/rjsx-mode/React/rpcp b/snippets/rjsx-mode/React/rpcp index d74a310..d9fe8f5 100644 --- a/snippets/rjsx-mode/React/rpcp +++ b/snippets/rjsx-mode/React/rpcp @@ -8,7 +8,7 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' -export default class ${1:${TM_FILENAME_BASE}} extends PureComponent { +export default class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends PureComponent { static propTypes = { } From d76f3afdf2e3ab525b1fee2254da27d677769c11 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 22:46:48 +0900 Subject: [PATCH 06/10] Improve some Redux snippets --- snippets/rjsx-mode/Redux/hocredux | 18 +++++++++--------- snippets/rjsx-mode/Redux/rcredux | 6 +++--- snippets/rjsx-mode/Redux/reduxmap | 16 +++++++++++----- snippets/rjsx-mode/Redux/rncredux | 12 ++++++------ snippets/rjsx-mode/Redux/rxreducer | 9 ++++----- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/snippets/rjsx-mode/Redux/hocredux b/snippets/rjsx-mode/Redux/hocredux index 41dfd35..b1e455a 100644 --- a/snippets/rjsx-mode/Redux/hocredux +++ b/snippets/rjsx-mode/Redux/hocredux @@ -9,16 +9,8 @@ import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' -export const mapStateToProps = state => ({ - -}) - -export const mapDispatchToProps = { - -} - export const ${1:hocComponentName} = (WrappedComponent) => { - const hocComponent = ({ ...props }) => + const hocComponent = (props) => hocComponent.propTypes = { } @@ -26,4 +18,12 @@ export const ${1:hocComponentName} = (WrappedComponent) => { return hocComponent } +const mapStateToProps = (state, ownProps) => ({ + +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + +}) + export default WrapperComponent => connect(mapStateToProps, mapDispatchToProps)(${1:hocComponentName}(WrapperComponent)) \ No newline at end of file diff --git a/snippets/rjsx-mode/Redux/rcredux b/snippets/rjsx-mode/Redux/rcredux index 497d5cb..83a6a10 100644 --- a/snippets/rjsx-mode/Redux/rcredux +++ b/snippets/rjsx-mode/Redux/rcredux @@ -23,12 +23,12 @@ export class ${1:${TM_FILENAME_BASE}} extends Component { } } -const mapStateToProps = (state) => ({ +const mapStateToProps = (state, ownProps) => ({ }) -const mapDispatchToProps = { +const mapDispatchToProps = (dispatch, ownProps) => ({ -} +}) export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}}) \ No newline at end of file diff --git a/snippets/rjsx-mode/Redux/reduxmap b/snippets/rjsx-mode/Redux/reduxmap index f9146f9..199bcdb 100644 --- a/snippets/rjsx-mode/Redux/reduxmap +++ b/snippets/rjsx-mode/Redux/reduxmap @@ -5,10 +5,16 @@ # key: reduxmap # -- -const mapStateToProps = (state) => ({ - ${1} +const mapStateToProps = (state, ownProps) => ({ + }) -const mapDispatchToProps = { - -} \ No newline at end of file +const mapDispatchToProps = (dispatch, ownProps) => ({ + +}) + +const mergeProps = (stateProps, dispatchProps, ownProps) => ({ + ...ownProps, + ...dispatchProps, + ...stateProps, +}) \ No newline at end of file diff --git a/snippets/rjsx-mode/Redux/rncredux b/snippets/rjsx-mode/Redux/rncredux index 78dedf3..4cb3321 100644 --- a/snippets/rjsx-mode/Redux/rncredux +++ b/snippets/rjsx-mode/Redux/rncredux @@ -18,18 +18,18 @@ export class ${1:${TM_FILENAME_BASE}} extends Component { render() { return ( - ${2:textInComponent} + ${2:textInComponent} ) } } -const mapStateToProps = (state) => ({ - +const mapStateToProps = (state, ownProps) => ({ + }) -const mapDispatchToProps = { - -} +const mapDispatchToProps = (dispatch, ownProps) => ({ + +}) export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}}) \ No newline at end of file diff --git a/snippets/rjsx-mode/Redux/rxreducer b/snippets/rjsx-mode/Redux/rxreducer index fe7e476..951f5e4 100644 --- a/snippets/rjsx-mode/Redux/rxreducer +++ b/snippets/rjsx-mode/Redux/rxreducer @@ -11,11 +11,10 @@ const initialState = { export default (state = initialState, { type, payload }) => { switch (type) { + case ${1:typeName}: + return { ...state, ...payload } - case ${1:typeName}: - return { ...state, ...payload } - - default: - return state + default: + return state } } \ No newline at end of file From 6c96332341f6d6c58e3f9ea5fd288fa22ca7fa46 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 22:49:11 +0900 Subject: [PATCH 07/10] Fix TM_FILENAME_BASE in some Redux snippets --- snippets/rjsx-mode/Redux/rcredux | 4 ++-- snippets/rjsx-mode/Redux/rncredux | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/rjsx-mode/Redux/rcredux b/snippets/rjsx-mode/Redux/rcredux index 83a6a10..903dd92 100644 --- a/snippets/rjsx-mode/Redux/rcredux +++ b/snippets/rjsx-mode/Redux/rcredux @@ -9,7 +9,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' -export class ${1:${TM_FILENAME_BASE}} extends Component { +export class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component { static propTypes = { ${2:prop}: ${3:PropTypes} } @@ -31,4 +31,4 @@ const mapDispatchToProps = (dispatch, ownProps) => ({ }) -export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}}) \ No newline at end of file +export default connect(mapStateToProps, mapDispatchToProps)($1) \ No newline at end of file diff --git a/snippets/rjsx-mode/Redux/rncredux b/snippets/rjsx-mode/Redux/rncredux index 4cb3321..66fea00 100644 --- a/snippets/rjsx-mode/Redux/rncredux +++ b/snippets/rjsx-mode/Redux/rncredux @@ -10,7 +10,7 @@ import { View, Text } from 'react-native' import PropTypes from 'prop-types' import { connect } from 'react-redux' -export class ${1:${TM_FILENAME_BASE}} extends Component { +export class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component { static propTypes = { ${2:prop}: ${3:PropTypes} } @@ -32,4 +32,4 @@ const mapDispatchToProps = (dispatch, ownProps) => ({ }) -export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}}) \ No newline at end of file +export default connect(mapStateToProps, mapDispatchToProps)($1) \ No newline at end of file From f52190f3e4d3b8359cfae7ebb6b6328f47fbfbd5 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 22:54:25 +0900 Subject: [PATCH 08/10] Improve a Redux snippet rxaction --- snippets/rjsx-mode/Redux/rxaction | 2 +- snippets/rjsx-mode/yas-setup.el | 1 + yasnippet-snippets.el | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/snippets/rjsx-mode/Redux/rxaction b/snippets/rjsx-mode/Redux/rxaction index a1994bb..4a0eef3 100644 --- a/snippets/rjsx-mode/Redux/rxaction +++ b/snippets/rjsx-mode/Redux/rxaction @@ -6,6 +6,6 @@ # -- export const ${1:actionName} = (payload) => ({ - type: ${3:type}, + type: ${1:$((upcase (s-snake-case yas-text)))}, payload }) \ No newline at end of file diff --git a/snippets/rjsx-mode/yas-setup.el b/snippets/rjsx-mode/yas-setup.el index db0fd3a..c685e1c 100644 --- a/snippets/rjsx-mode/yas-setup.el +++ b/snippets/rjsx-mode/yas-setup.el @@ -5,6 +5,7 @@ ;;; Code: (require 'yasnippet) +(require 's) (defun yas-jsx-get-class-name-by-file-name () "Return name of class-like construct by `file-name'." diff --git a/yasnippet-snippets.el b/yasnippet-snippets.el index 1a14367..bc6bd7b 100644 --- a/yasnippet-snippets.el +++ b/yasnippet-snippets.el @@ -5,7 +5,7 @@ ;; Author: Andrea Crotti ;; Keywords: snippets ;; Version: 0.2 -;; Package-Requires: ((yasnippet "0.8.0")) +;; Package-Requires: ((yasnippet "0.8.0") (s "1.12.0")) ;; Keywords: convenience, snippets ;;; Commentary: From 582d0a8d7ce3939d18d1e6523184d0729dc0c5af Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 22:58:21 +0900 Subject: [PATCH 09/10] Fix some React Native snippets --- snippets/rjsx-mode/React-Native/rnc | 4 ++-- snippets/rjsx-mode/React-Native/rnce | 6 +++--- snippets/rjsx-mode/React-Native/rncs | 4 ++-- snippets/rjsx-mode/React-Native/rnpc | 4 ++-- snippets/rjsx-mode/React-Native/rnpce | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/snippets/rjsx-mode/React-Native/rnc b/snippets/rjsx-mode/React-Native/rnc index 7d82314..32bbdd4 100644 --- a/snippets/rjsx-mode/React-Native/rnc +++ b/snippets/rjsx-mode/React-Native/rnc @@ -8,11 +8,11 @@ import React, { Component } from 'react' import { Text, View } from 'react-native' -export default class ${1:${TM_FILENAME_BASE}} extends Component { +export default class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component { render() { return ( - ${2:textInComponent} + ${2:textInComponent} ) } diff --git a/snippets/rjsx-mode/React-Native/rnce b/snippets/rjsx-mode/React-Native/rnce index c13e598..b94e095 100644 --- a/snippets/rjsx-mode/React-Native/rnce +++ b/snippets/rjsx-mode/React-Native/rnce @@ -8,14 +8,14 @@ import React, { Component } from 'react' import { Text, View } from 'react-native' -export class ${1:${TM_FILENAME_BASE}} extends Component { +export class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component { render() { return ( - ${2:textInComponent} + ${2:textInComponent} ) } } -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file +export default $1 \ No newline at end of file diff --git a/snippets/rjsx-mode/React-Native/rncs b/snippets/rjsx-mode/React-Native/rncs index 32b0508..080ef24 100644 --- a/snippets/rjsx-mode/React-Native/rncs +++ b/snippets/rjsx-mode/React-Native/rncs @@ -8,11 +8,11 @@ import React, { Component } from 'react' import { Text, StyleSheet, View } from 'react-native' -export default class ${1:${TM_FILENAME_BASE}} extends Component { +export default class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component { render() { return ( - ${2:textInComponent} + ${2:textInComponent} ) } diff --git a/snippets/rjsx-mode/React-Native/rnpc b/snippets/rjsx-mode/React-Native/rnpc index 55b6eb7..6d7d562 100644 --- a/snippets/rjsx-mode/React-Native/rnpc +++ b/snippets/rjsx-mode/React-Native/rnpc @@ -8,11 +8,11 @@ import React, { PureComponent } from 'react' import { Text, View } from 'react-native' -export default class ${1:${TM_FILENAME_BASE}} extends PureComponent { +export default class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends PureComponent { render() { return ( - ${2:textInComponent} + ${2:textInComponent} ) } diff --git a/snippets/rjsx-mode/React-Native/rnpce b/snippets/rjsx-mode/React-Native/rnpce index 461a1e6..49c2b56 100644 --- a/snippets/rjsx-mode/React-Native/rnpce +++ b/snippets/rjsx-mode/React-Native/rnpce @@ -8,14 +8,14 @@ import React, { PureComponent } from 'react' import { Text, View } from 'react-native' -export class ${1:${TM_FILENAME_BASE}} extends PureComponent { +export class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends PureComponent { render() { return ( - ${2:textInComponent} + ${2:textInComponent} ) } } -export default ${1:${TM_FILENAME_BASE}} \ No newline at end of file +export default $1 \ No newline at end of file From 1eb351b2cdbd5d95c9fb8b64b8733cbe596f95f9 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Wed, 25 Dec 2019 23:10:18 +0900 Subject: [PATCH 10/10] Rename yas-setup.el -> .yas-setup.el in rjsx-mode --- snippets/rjsx-mode/{yas-setup.el => .yas-setup.el} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename snippets/rjsx-mode/{yas-setup.el => .yas-setup.el} (100%) diff --git a/snippets/rjsx-mode/yas-setup.el b/snippets/rjsx-mode/.yas-setup.el similarity index 100% rename from snippets/rjsx-mode/yas-setup.el rename to snippets/rjsx-mode/.yas-setup.el