From f44f953b4d93fa9515e6d990b1de3d929b5e8047 Mon Sep 17 00:00:00 2001 From: ydkulks Date: Thu, 2 Jan 2025 19:07:55 +0530 Subject: [PATCH 1/3] FIX: React snippets Fixed the issue where multiple ${1} was used in the same snippet which raised an error in Neovim --- snippets/javascript/react-es7.json | 272 ++++++++++++++--------------- snippets/javascript/react.json | 2 +- 2 files changed, 137 insertions(+), 137 deletions(-) diff --git a/snippets/javascript/react-es7.json b/snippets/javascript/react-es7.json index ee54f252..56f0cc8c 100644 --- a/snippets/javascript/react-es7.json +++ b/snippets/javascript/react-es7.json @@ -17,12 +17,12 @@ "", "type State = {}", "", - "export default class ${1:${TM_FILENAME_BASE}} extends Component {", + "export default class ${TM_FILENAME_BASE} extends Component {", " state = {}", "", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}" @@ -37,17 +37,17 @@ "", "type State = {}", "", - "class ${1:${TM_FILENAME_BASE}} extends Component {", + "class ${TM_FILENAME_BASE} extends Component {", " state = {}", "", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React component class with ES7 module system and TypeScript interfaces" }, @@ -58,13 +58,13 @@ "", "type Props = {}", "", - "function ${1:${TM_FILENAME_BASE}}({}: Props) {", + "function ${TM_FILENAME_BASE}({}: Props) {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React Functional Component with ES7 module system and TypeScript interface" }, @@ -75,9 +75,9 @@ "", "type Props = {}", "", - "export default function ${1:${TM_FILENAME_BASE}}({}: Props) {", + "export default function ${TM_FILENAME_BASE}({}: Props) {", " return (", - "
${1:first}
", + "
${0}
", " )", "}" ], @@ -90,13 +90,13 @@ "", "type Props = {}", "", - "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", + "const ${TM_FILENAME_BASE} = (props: Props) => {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React Arrow Function Component with ES7 module system and TypeScript interface" }, @@ -107,9 +107,9 @@ "", "type Props = {}", "", - "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", + "const ${TM_FILENAME_BASE} = (props: Props) => {", " return (", - "
${1:first}
", + "
${0}
", " )", "}" ], @@ -122,10 +122,10 @@ "", "type Props = {}", "", - "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", + "export default class ${TM_FILENAME_BASE} extends PureComponent {", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}" @@ -139,15 +139,15 @@ "", "type Props = {}", "", - "class ${1:${TM_FILENAME_BASE}} extends PureComponent {", + "class ${TM_FILENAME_BASE} extends PureComponent {", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React pure component class with ES7 module system and TypeScript interface" }, @@ -161,12 +161,12 @@ "", "type State = {}", "", - "export class ${1:${TM_FILENAME_BASE}} extends Component {", + "export class ${TM_FILENAME_BASE} extends Component {", " state = {}", "", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", @@ -175,7 +175,7 @@ "", "const mapDispatchToProps = {}", "", - "export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}})" + "export default connect(mapStateToProps, mapDispatchToProps)(${TM_FILENAME_BASE})" ], "description": "Creates a React component class with connected redux and ES7 module system and TypeScript interfaces" }, @@ -187,15 +187,15 @@ "", "type Props = {}", "", - "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", + "const ${TM_FILENAME_BASE} = (props: Props) => {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React Native Arrow Function Component with ES7 module system in TypeScript" }, @@ -207,15 +207,15 @@ "", "type Props = {}", "", - "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", + "const ${TM_FILENAME_BASE} = (props: Props) => {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", "}", "", - "export default ${1:${TM_FILENAME_BASE}}", + "export default ${TM_FILENAME_BASE}", "", "const styles = StyleSheet.create({})" ], @@ -226,9 +226,9 @@ "body": [ "import React from 'react'", "", - "export const ${1:${TM_FILENAME_BASE}} = () => {", + "export const ${TM_FILENAME_BASE} = () => {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "" @@ -241,15 +241,15 @@ "import React from 'react'", "import PropTypes from 'prop-types'", "", - "const ${1:${TM_FILENAME_BASE}} = props => {", + "const ${TM_FILENAME_BASE} = props => {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "", - "${1:${TM_FILENAME_BASE}}.propTypes = {}", + "${TM_FILENAME_BASE}.propTypes = {}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React Arrow Function Component with ES7 module system with PropTypes" }, @@ -258,13 +258,13 @@ "body": [ "import React from 'react'", "", - "const ${1:${TM_FILENAME_BASE}} = () => {", + "const ${TM_FILENAME_BASE} = () => {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React Arrow Function Component with ES7 module system" }, @@ -273,10 +273,10 @@ "body": [ "import React, { Component } from 'react'", "", - "export default class ${1:${TM_FILENAME_BASE}} extends Component {", + "export default class ${TM_FILENAME_BASE} extends Component {", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", @@ -290,12 +290,12 @@ "import PropTypes from 'prop-types'", "import React, { Component } from 'react'", "", - "export default class ${1:${TM_FILENAME_BASE}} extends Component {", - " static propTypes = {${2:second}: ${3:third}}", + "export default class ${TM_FILENAME_BASE} extends Component {", + " static propTypes = {${1:first}: ${2:second}}", "", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", @@ -309,10 +309,10 @@ "import React, { Component } from 'react'", "import { connect } from 'react-redux'", "", - "export class ${1:${TM_FILENAME_BASE}} extends Component {", + "export class ${TM_FILENAME_BASE} extends Component {", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", @@ -321,7 +321,7 @@ "", "const mapDispatchToProps = {}", "", - "export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}})" + "export default connect(mapStateToProps, mapDispatchToProps)(${TM_FILENAME_BASE})" ], "description": "Creates a React component class with connected redux and ES7 module system" }, @@ -332,14 +332,14 @@ "import React, { Component } from 'react'", "import { connect } from 'react-redux'", "", - "export class ${1:${TM_FILENAME_BASE}} extends Component {", + "export class ${TM_FILENAME_BASE} extends Component {", " static propTypes = {", - " ${2:second}: ${3:third}", + " ${1:first}: ${2:second}", " }", "", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", @@ -348,7 +348,7 @@ "", "const mapDispatchToProps = {}", "", - "export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}})" + "export default connect(mapStateToProps, mapDispatchToProps)(${TM_FILENAME_BASE})" ], "description": "Creates a React component class with PropTypes with connected redux and ES7 module system" }, @@ -357,15 +357,15 @@ "body": [ "import React, { Component } from 'react'", "", - "export class ${1:${TM_FILENAME_BASE}} extends Component {", + "export class ${TM_FILENAME_BASE} extends Component {", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React component class with ES7 module system" }, @@ -375,17 +375,17 @@ "import PropTypes from 'prop-types'", "import React, { Component } from 'react'", "", - "export class ${1:${TM_FILENAME_BASE}} extends Component {", + "export class ${TM_FILENAME_BASE} extends Component {", " static propTypes = {}", "", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React component class with ES7 module system" }, @@ -394,15 +394,15 @@ "body": [ "import React, { PureComponent } from 'react'", "", - "export class ${1:${TM_FILENAME_BASE}} extends PureComponent {", + "export class ${TM_FILENAME_BASE} extends PureComponent {", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React pure component class with ES7 module system export" }, @@ -411,10 +411,10 @@ "body": [ "import React, { PureComponent } from 'react'", "", - "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", + "export default class ${TM_FILENAME_BASE} extends PureComponent {", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", @@ -428,12 +428,12 @@ "import PropTypes from 'prop-types'", "import React, { PureComponent } from 'react'", "", - "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", + "export default class ${TM_FILENAME_BASE} extends PureComponent {", " static propTypes = {}", "", " render() {", " return (", - "
${1:first}
", + "
${0}
", " )", " }", "}", @@ -446,13 +446,13 @@ "body": [ "import React, { memo } from 'react'", "", - "const ${1:${TM_FILENAME_BASE}} = memo(() => {", + "const ${TM_FILENAME_BASE} = memo(() => {", " return (", - "
${1:first}
", + "
${0}
", " )", "})", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React Memo Function Component with ES7 module system" }, @@ -462,15 +462,15 @@ "import PropTypes from 'prop-types'", "import React, { memo } from 'react'", "", - "const ${1:${TM_FILENAME_BASE}} = memo((props) => {", + "const ${TM_FILENAME_BASE} = memo((props) => {", " return (", - "
${1:first}
", + "
${0}
", " )", "})", "", - "${1:${TM_FILENAME_BASE}}.propTypes = {}", + "${TM_FILENAME_BASE}.propTypes = {}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React Memo Function Component with ES7 module system with PropTypes" }, @@ -479,9 +479,9 @@ "body": [ "import React from 'react'", "", - "export default function ${1:${TM_FILENAME_BASE}}() {", + "export default function ${TM_FILENAME_BASE}() {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "" @@ -491,9 +491,9 @@ "reactFunctionalViteComponent": { "prefix": "rfcv", "body": [ - "export default function ${1:${TM_FILENAME_BASE}}() {", + "export default function ${TM_FILENAME_BASE}() {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "" @@ -506,9 +506,9 @@ "import React from 'react'", "import { connect } from 'react-redux'", "", - "export const ${1:${TM_FILENAME_BASE}} = (props) => {", + "export const ${TM_FILENAME_BASE} = (props) => {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "", @@ -516,7 +516,7 @@ "", "const mapDispatchToProps = {}", "", - "export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}})" + "export default connect(mapStateToProps, mapDispatchToProps)(${TM_FILENAME_BASE})" ], "description": "Creates a React functional component with connected redux and ES7 module system" }, @@ -527,21 +527,21 @@ "import React from 'react'", "import { connect } from 'react-redux'", "", - "export const ${1:${TM_FILENAME_BASE}} = (props) => {", + "export const ${TM_FILENAME_BASE} = (props) => {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "", - "${1:${TM_FILENAME_BASE}}.propTypes = {", - " ${2:second}: PropTypes.${3:third}", + "${TM_FILENAME_BASE}.propTypes = {", + " ${1:first}: PropTypes.${2:second}", "}", "", "const mapStateToProps = (state) => ({})", "", "const mapDispatchToProps = {}", "", - "export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}})" + "export default connect(mapStateToProps, mapDispatchToProps)(${TM_FILENAME_BASE})" ], "description": "DEPRECATED: Creates a React functional component with PropTypes with connected redux and ES7 module system" }, @@ -551,15 +551,15 @@ "import React from 'react'", "import PropTypes from 'prop-types'", "", - "function ${1:${TM_FILENAME_BASE}}(props) {", + "function ${TM_FILENAME_BASE}(props) {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "", - "${1:${TM_FILENAME_BASE}}.propTypes = {}", + "${TM_FILENAME_BASE}.propTypes = {}", "", - "export default ${1:${TM_FILENAME_BASE}}", + "export default ${TM_FILENAME_BASE}", "" ], "description": "Creates a React Functional Component with ES7 module system with PropTypes" @@ -569,13 +569,13 @@ "body": [ "import React from 'react'", "", - "function ${1:${TM_FILENAME_BASE}}() {", + "function ${TM_FILENAME_BASE}() {", " return (", - "
${1:first}
", + "
${0}
", " )", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ], "description": "Creates a React Functional Component with ES7 module system" }, @@ -626,13 +626,13 @@ }, "consoleLogObject": { "prefix": "clo", - "body": ["console.log('${1:first}', ${1:first})"], + "body": ["console.log('${1:first}', ${2:second})"], "description": "Logs property with name." }, "consoleLogJson": { "prefix": "clj", "body": [ - "console.log('${1:first}', JSON.stringify(${1:first}, null, 2))" + "console.log('${1:first}', JSON.stringify(${2:second}, null, 2))" ], "description": "Logs stringified JSON property with name." }, @@ -681,12 +681,12 @@ "prefix": "useEffectSnippet", "body": [ "useEffect(() => {", - " ${1:first}", + " ${1:setup}", "", " return () => {", - " ${2:second}", + " ${2:return}", " }", - "}, [${3:third}])", + "}, [${3:dependencies?}])", "" ] }, @@ -731,7 +731,7 @@ "useState": { "prefix": "useStateSnippet", "body": [ - "const [${1:first}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:second})" + "const [${1:state}, set${2:State}] = useState(${3:initValue})" ] }, "importAs": { @@ -992,11 +992,11 @@ "import { Text, View } from 'react-native'", "import React, { Component } from 'react'", "", - "export default class ${1:${TM_FILENAME_BASE}} extends Component {", + "export default class ${TM_FILENAME_BASE} extends Component {", " render() {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", " }", @@ -1009,17 +1009,17 @@ "import { Text, View } from 'react-native'", "import React, { Component } from 'react'", "", - "export class ${1:${TM_FILENAME_BASE}} extends Component {", + "export class ${TM_FILENAME_BASE} extends Component {", " render() {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", " }", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ] }, "reactNativeComponentWithStyles": { @@ -1028,11 +1028,11 @@ "import { Text, StyleSheet, View } from 'react-native'", "import React, { Component } from 'react'", "", - "export default class ${1:${TM_FILENAME_BASE}} extends Component {", + "export default class ${TM_FILENAME_BASE} extends Component {", " render() {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", " }", @@ -1047,10 +1047,10 @@ "import { View, Text } from 'react-native'", "import React from 'react'", "", - "export default function ${1:${TM_FILENAME_BASE}}() {", + "export default function ${TM_FILENAME_BASE}() {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", "}" @@ -1062,10 +1062,10 @@ "import { StyleSheet, Text, View } from 'react-native'", "import React from 'react'", "", - "export default function ${1:${TM_FILENAME_BASE}}() {", + "export default function ${TM_FILENAME_BASE}() {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", "}", @@ -1079,15 +1079,15 @@ "import { View, Text } from 'react-native'", "import React from 'react'", "", - "const ${1:${TM_FILENAME_BASE}} = () => {", + "const ${TM_FILENAME_BASE} = () => {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ] }, "reactNativeFunctionalExportComponentWithStyles": { @@ -1096,15 +1096,15 @@ "import { StyleSheet, Text, View } from 'react-native'", "import React from 'react'", "", - "const ${1:${TM_FILENAME_BASE}} = () => {", + "const ${TM_FILENAME_BASE} = () => {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", "}", "", - "export default ${1:${TM_FILENAME_BASE}}", + "export default ${TM_FILENAME_BASE}", "", "const styles = StyleSheet.create({})" ] @@ -1119,11 +1119,11 @@ "import { Text, View } from 'react-native'", "import React, { PureComponent } from 'react'", "", - "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", + "export default class ${TM_FILENAME_BASE} extends PureComponent {", " render() {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", " }", @@ -1136,17 +1136,17 @@ "import { Text, View } from 'react-native'", "import React, { PureComponent } from 'react'", "", - "export class ${1:${TM_FILENAME_BASE}} extends PureComponent {", + "export class ${TM_FILENAME_BASE} extends PureComponent {", " render() {", " return (", " ", - " ${1:first}", + " ${0}", " ", " )", " }", "}", "", - "export default ${1:${TM_FILENAME_BASE}}" + "export default ${TM_FILENAME_BASE}" ] }, "reactNativeStyles": { @@ -1169,7 +1169,7 @@ }, "reduxConst": { "prefix": "rxconst", - "body": ["export const ${1:first} = '${1:first}'"] + "body": ["export const ${1:first} = '${2:second}'"] }, "reduxReducer": { "prefix": "rxreducer", @@ -1206,15 +1206,15 @@ "", "}", "", - "const ${1:${TM_FILENAME_BASE}} = createSlice({", - " name: ${2:second},", + "const ${TM_FILENAME_BASE} = createSlice({", + " name: ${0},", " initialState,", " reducers: {}", "});", "", - "export const {} = ${1:${TM_FILENAME_BASE}}.actions", + "export const {} = ${TM_FILENAME_BASE}.actions", "", - "export default ${1:${TM_FILENAME_BASE}}.reducer" + "export default ${TM_FILENAME_BASE}.reducer" ] }, "mappingToProps": { @@ -1248,13 +1248,13 @@ "import { Provider } from 'react-redux'", "", "import store from '~/store'", - "import { ${1:${TM_FILENAME_BASE}} } from '../${1:${TM_FILENAME_BASE}}'", + "import { ${TM_FILENAME_BASE} } from '../${TM_FILENAME_BASE}'", "", - "describe('<${1:${TM_FILENAME_BASE}} />', () => {", + "describe('<${TM_FILENAME_BASE} />', () => {", " const defaultProps = {}", " const wrapper = renderer.create(", " ", - " <${1:${TM_FILENAME_BASE}} {...defaultProps} />", + " <${TM_FILENAME_BASE} {...defaultProps} />", " ,", " )", "", @@ -1272,11 +1272,11 @@ "import React from 'react'", "import renderer from 'react-test-renderer'", "", - "import ${1:${TM_FILENAME_BASE}} from '../${1:${TM_FILENAME_BASE}}'", + "import ${TM_FILENAME_BASE} from '../${TM_FILENAME_BASE}'", "", - "describe('<${1:${TM_FILENAME_BASE}} />', () => {", + "describe('<${TM_FILENAME_BASE} />', () => {", " const defaultProps = {}", - " const wrapper = renderer.create(<${1:${TM_FILENAME_BASE}} {...defaultProps} />)", + " const wrapper = renderer.create(<${TM_FILENAME_BASE} {...defaultProps} />)", "", " test('render', () => {", " expect(wrapper).toMatchSnapshot()", @@ -1293,13 +1293,13 @@ "import { Provider } from 'react-redux'", "", "import store from '~/store'", - "import ${1:${TM_FILENAME_BASE}} from '../${1:${TM_FILENAME_BASE}}'", + "import ${TM_FILENAME_BASE} from '../${TM_FILENAME_BASE}'", "", - "describe('<${1:${TM_FILENAME_BASE}} />', () => {", + "describe('<${TM_FILENAME_BASE} />', () => {", " const defaultProps = {}", " const wrapper = renderer.create(", " ", - " <${1:${TM_FILENAME_BASE}} {...defaultProps} />", + " <${TM_FILENAME_BASE} {...defaultProps} />", " ,", " )", "", @@ -1315,11 +1315,11 @@ "import React from 'react'", "import renderer from 'react-test-renderer'", "", - "import { ${1:${TM_FILENAME_BASE}} } from '../${1:${TM_FILENAME_BASE}}'", + "import { ${TM_FILENAME_BASE} } from '../${TM_FILENAME_BASE}'", "", - "describe('<${1:${TM_FILENAME_BASE}} />', () => {", + "describe('<${TM_FILENAME_BASE} />', () => {", " const defaultProps = {}", - " const wrapper = renderer.create(<${1:${TM_FILENAME_BASE}} {...defaultProps} />)", + " const wrapper = renderer.create(<${TM_FILENAME_BASE} {...defaultProps} />)", "", " test('render', () => {", " expect(wrapper).toMatchSnapshot()", @@ -1522,7 +1522,7 @@ }, "bindThis": { "prefix": "bnd", - "body": ["this.${1:first} = this.${1:first}.bind(this)"], + "body": ["this.${1:first} = this.${2:second}.bind(this)"], "description": "Binds this to a method" }, "commentBigBlock": { @@ -1548,7 +1548,7 @@ " return hocComponent", "}", "", - "export default WrapperComponent => connect(mapStateToProps, mapDispatchToProps)(${1:first}(WrapperComponent))", + "export default WrapperComponent => connect(mapStateToProps, mapDispatchToProps)(${2:second}(WrapperComponent))", "" ] }, diff --git a/snippets/javascript/react.json b/snippets/javascript/react.json index b51c5847..1b603021 100644 --- a/snippets/javascript/react.json +++ b/snippets/javascript/react.json @@ -298,7 +298,7 @@ }, "useState": { "prefix": "us", - "body": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:initValue})$0", + "body": "const [${1:state}, set${2:State}] = useState(${3:initValue})$0", "description": "React useState() hook" }, "useEffect": { From 443fb1ff22c2f34a28d2a7a6c5e1a634cfa20c09 Mon Sep 17 00:00:00 2001 From: ydkulks Date: Thu, 9 Jan 2025 13:43:17 +0530 Subject: [PATCH 2/3] FIX: Java public class Corrected snippet syntax to of Java public class --- snippets/java/java.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/java/java.json b/snippets/java/java.json index 4fab7155..25b87123 100644 --- a/snippets/java/java.json +++ b/snippets/java/java.json @@ -6,7 +6,7 @@ }, "class": { "prefix": "class", - "body": ["public class ${TM_FILENAME_BASE} {", "\t$0", "}"], + "body": ["public class ${1:TM_FILENAME_BASE} {", "\t$0", "}"], "description": "Public class" }, "sysout": { From 3783832138d3e35532c63e3660744fc6583fd2ca Mon Sep 17 00:00:00 2001 From: ydkulks Date: Mon, 28 Apr 2025 12:47:46 +0530 Subject: [PATCH 3/3] Resolve merge conflict in react-es7 and react files 1. Retained the changes which removed import statement of react in react-es7.json file 2. Retained the changes with 2 space indents in react.json file --- snippets/javascript/react-es7.json | 52 ---- snippets/javascript/react.json | 371 ----------------------------- 2 files changed, 423 deletions(-) diff --git a/snippets/javascript/react-es7.json b/snippets/javascript/react-es7.json index ac5164d5..27424330 100644 --- a/snippets/javascript/react-es7.json +++ b/snippets/javascript/react-es7.json @@ -218,14 +218,7 @@ "reactArrowFunctionComponent": { "prefix": "rafc", "body": [ -<<<<<<< HEAD - "import React from 'react'", - "", - "export const ${TM_FILENAME_BASE} = () => {", -======= - "export const ${1:${TM_FILENAME_BASE}} = () => {", ->>>>>>> upstream/main " return (", "
${0}
", " )", @@ -255,14 +248,7 @@ "reactArrowFunctionExportComponent": { "prefix": "rafce", "body": [ -<<<<<<< HEAD - "import React from 'react'", - "", - "const ${TM_FILENAME_BASE} = () => {", -======= - "const ${1:${TM_FILENAME_BASE}} = () => {", ->>>>>>> upstream/main " return (", "
${0}
", " )", @@ -481,14 +467,7 @@ "reactFunctionalComponent": { "prefix": "rfc", "body": [ -<<<<<<< HEAD - "import React from 'react'", - "", - "export default function ${TM_FILENAME_BASE}() {", -======= - "export default function ${1:${TM_FILENAME_BASE}}() {", ->>>>>>> upstream/main " return (", "
${0}
", " )", @@ -576,14 +555,7 @@ "reactFunctionalExportComponent": { "prefix": "rfce", "body": [ -<<<<<<< HEAD - "import React from 'react'", - "", - "function ${TM_FILENAME_BASE}() {", -======= - "function ${1:${TM_FILENAME_BASE}}() {", ->>>>>>> upstream/main " return (", "
${0}
", " )", @@ -1059,14 +1031,8 @@ "prefix": "rnf", "body": [ "import { View, Text } from 'react-native'", -<<<<<<< HEAD - "import React from 'react'", "", - "export default function ${TM_FILENAME_BASE}() {", -======= - "export default function ${1:${TM_FILENAME_BASE}}() {", ->>>>>>> upstream/main " return (", " ", " ${0}", @@ -1079,14 +1045,8 @@ "prefix": "rnfs", "body": [ "import { StyleSheet, Text, View } from 'react-native'", -<<<<<<< HEAD - "import React from 'react'", "", - "export default function ${TM_FILENAME_BASE}() {", -======= - "export default function ${1:${TM_FILENAME_BASE}}() {", ->>>>>>> upstream/main " return (", " ", " ${0}", @@ -1101,14 +1061,8 @@ "prefix": "rnfe", "body": [ "import { View, Text } from 'react-native'", -<<<<<<< HEAD - "import React from 'react'", "", - "const ${TM_FILENAME_BASE} = () => {", -======= - "const ${1:${TM_FILENAME_BASE}} = () => {", ->>>>>>> upstream/main " return (", " ", " ${0}", @@ -1123,14 +1077,8 @@ "prefix": "rnfes", "body": [ "import { StyleSheet, Text, View } from 'react-native'", -<<<<<<< HEAD - "import React from 'react'", "", - "const ${TM_FILENAME_BASE} = () => {", -======= - "const ${1:${TM_FILENAME_BASE}} = () => {", ->>>>>>> upstream/main " return (", " ", " ${0}", diff --git a/snippets/javascript/react.json b/snippets/javascript/react.json index 7d15625b..a41e83d9 100644 --- a/snippets/javascript/react.json +++ b/snippets/javascript/react.json @@ -1,374 +1,4 @@ { -<<<<<<< HEAD - "destructuring of props": { - "prefix": "dp", - "body": ["const { ${1:name} } = this.props"] - }, - "destructuring of state": { - "prefix": "ds", - "body": ["const { ${1:name} } = this.state"] - }, - "if falsy return null": { - "prefix": "ifr", - "body": "if (!${1:condition}) {\n\treturn null\n}" - }, - "reactClassCompoment": { - "prefix": "rcc", - "body": "import { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\nexport default ${1}", - "description": "Creates a React component class" - }, - "reactJustClassCompoment": { - "prefix": "rcjc", - "body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n", - "description": "Creates a React component class" - }, - "reactClassCompomentPropTypes": { - "prefix": "rccp", - "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes" - }, - "reactClassCompomentWithMethods": { - "prefix": "rcfc", - "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t
\n\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes and all lifecycle methods" - }, - "reactFunctionComponent": { - "prefix": "rfc", - "body": "\nconst ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${TM_FILENAME_BASE}", - "description": "Creates a React function component without PropTypes" - }, - "reactFunctionComponentWithCustomName": { - "prefix": "rfcn", - "body": "\nconst ${1:functionname} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${1:functionname}", - "description": "Creates a React function component with custom name" - }, - "reactFunctionComponentWithEmotion": { - "prefix": "rfce", - "body": "import { css } from '@emotion/core'\n\nexport const ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "Creates a React functional component with emotion" - }, - "reactStatelessProps": { - "prefix": "rfcp", - "body": "import { PropTypes } from 'react'\n\nconst ${TM_FILENAME_BASE} = props => {\n\treturn (\n\t\t
\n\t\t\t\n\t\t
\n\t)\n}\n\n${1}.propTypes = {\n\t$0\n}\n\nexport default ${1}", - "description": "Creates a React function component with PropTypes" - }, - "classConstructor": { - "prefix": "con", - "body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props as arguments" - }, - "classConstructorContext": { - "prefix": "conc", - "body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props and context as arguments" - }, - "componentWillMount": { - "prefix": "cwm", - "body": "\ncomponentWillMount () {\n\t$0\n}\n", - "description": "Invoked once, both on the client and server, immediately before the initial rendering occurs" - }, - "componentDidMount": { - "prefix": "cdm", - "body": "componentDidMount () {\n\t$0\n}\n", - "description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs." - }, - "componentWillReceiveProps": { - "prefix": "cwr", - "body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n", - "description": "Invoked when a component is receiving new props. This method is not called for the initial render." - }, - "componentGetDerivedStateFromProps": { - "prefix": "cgd", - "body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n", - "description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates." - }, - "shouldComponentUpdate": { - "prefix": "scu", - "body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked before rendering when new props or state are being received. " - }, - "componentWillUpdate": { - "prefix": "cwup", - "body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked immediately before rendering when new props or state are being received." - }, - "componentDidUpdate": { - "prefix": "cdup", - "body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n", - "description": "Invoked immediately after the component's updates are flushed to the DOM." - }, - "componentWillUnmount": { - "prefix": "cwun", - "body": "componentWillUnmount () {\n\t$0\n}\n", - "description": "Invoked immediately before a component is unmounted from the DOM." - }, - "componentRender": { - "prefix": "ren", - "body": "render () {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "When called, it should examine this.props and this.state and return a single child element." - }, - "componentSetStateObject": { - "prefix": "sst", - "body": "this.setState($0)", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentSetStateFunc": { - "prefix": "ssf", - "body": "this.setState((state, props) => { return { $0 }})\n", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentProps": { - "prefix": "tp", - "body": "this.props.$0", - "description": "Access component's props" - }, - "componentState": { - "prefix": "ts", - "body": "this.state.$0", - "description": "Access component's state" - }, - "propTypes": { - "prefix": "rpt", - "body": "$1.propTypes = {\n\t$2\n}", - "description": "Creates empty propTypes declaration" - }, - "propTypeArray": { - "prefix": "pta", - "body": "PropTypes.array,", - "description": "Array prop type" - }, - "propTypeArrayRequired": { - "prefix": "ptar", - "body": "PropTypes.array.isRequired,", - "description": "Array prop type required" - }, - "propTypeBool": { - "prefix": "ptb", - "body": "PropTypes.bool,", - "description": "Bool prop type" - }, - "propTypeBoolRequired": { - "prefix": "ptbr", - "body": "PropTypes.bool.isRequired,", - "description": "Bool prop type required" - }, - "propTypeFunc": { - "prefix": "ptf", - "body": "PropTypes.func,", - "description": "Func prop type" - }, - "propTypeFuncRequired": { - "prefix": "ptfr", - "body": "PropTypes.func.isRequired,", - "description": "Func prop type required" - }, - "propTypeNumber": { - "prefix": "ptn", - "body": "PropTypes.number,", - "description": "Number prop type" - }, - "propTypeNumberRequired": { - "prefix": "ptnr", - "body": "PropTypes.number.isRequired,", - "description": "Number prop type required" - }, - "propTypeObject": { - "prefix": "pto", - "body": "PropTypes.object,", - "description": "Object prop type" - }, - "propTypeObjectRequired": { - "prefix": "ptor", - "body": "PropTypes.object.isRequired,", - "description": "Object prop type required" - }, - "propTypeString": { - "prefix": "pts", - "body": "PropTypes.string,", - "description": "String prop type" - }, - "propTypeStringRequired": { - "prefix": "ptsr", - "body": "PropTypes.string.isRequired,", - "description": "String prop type required" - }, - "propTypeNode": { - "prefix": "ptnd", - "body": "PropTypes.node,", - "description": "Anything that can be rendered: numbers, strings, elements or an array" - }, - "propTypeNodeRequired": { - "prefix": "ptndr", - "body": "PropTypes.node.isRequired,", - "description": "Anything that can be rendered: numbers, strings, elements or an array required" - }, - "propTypeElement": { - "prefix": "ptel", - "body": "PropTypes.element,", - "description": "React element prop type" - }, - "propTypeElementRequired": { - "prefix": "ptelr", - "body": "PropTypes.element.isRequired,", - "description": "React element prop type required" - }, - "propTypeInstanceOf": { - "prefix": "pti", - "body": "PropTypes.instanceOf($0),", - "description": "Is an instance of a class prop type" - }, - "propTypeInstanceOfRequired": { - "prefix": "ptir", - "body": "PropTypes.instanceOf($0).isRequired,", - "description": "Is an instance of a class prop type required" - }, - "propTypeEnum": { - "prefix": "pte", - "body": "PropTypes.oneOf(['$0']),", - "description": "Prop type limited to specific values by treating it as an enum" - }, - "propTypeEnumRequired": { - "prefix": "pter", - "body": "PropTypes.oneOf(['$0']).isRequired,", - "description": "Prop type limited to specific values by treating it as an enum required" - }, - "propTypeOneOfType": { - "prefix": "ptet", - "body": "PropTypes.oneOfType([\n\t$0\n]),", - "description": "An object that could be one of many types" - }, - "propTypeOneOfTypeRequired": { - "prefix": "ptetr", - "body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,", - "description": "An object that could be one of many types required" - }, - "propTypeArrayOf": { - "prefix": "ptao", - "body": "PropTypes.arrayOf($0),", - "description": "An array of a certain type" - }, - "propTypeArrayOfRequired": { - "prefix": "ptaor", - "body": "PropTypes.arrayOf($0).isRequired,", - "description": "An array of a certain type required" - }, - "propTypeObjectOf": { - "prefix": "ptoo", - "body": "PropTypes.objectOf($0),", - "description": "An object with property values of a certain type" - }, - "propTypeObjectOfRequired": { - "prefix": "ptoor", - "body": "PropTypes.objectOf($0).isRequired,", - "description": "An object with property values of a certain type required" - }, - "propTypeShape": { - "prefix": "ptsh", - "body": "PropTypes.shape({\n\t$0\n}),", - "description": "An object taking on a particular shape" - }, - "propTypeShapeRequired": { - "prefix": "ptshr", - "body": "PropTypes.shape({\n\t$0\n}).isRequired,", - "description": "An object taking on a particular shape required" - }, - "jsx element": { - "prefix": "j", - "body": "<${1:elementName}>\n\t$0\n", - "description": "an element" - }, - "jsx element self closed": { - "prefix": "jc", - "body": "<${1:elementName} />", - "description": "an element self closed" - }, - "jsx elements map": { - "prefix": "jm", - "body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n)}", - "description": "an element self closed" - }, - "jsx elements map with return": { - "prefix": "jmr", - "body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n\n})}", - "description": "an element self closed" - }, - "jsx element wrap selection": { - "prefix": "jsx wrap selection with element", - "body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n", - "description": "an element" - }, - "useState": { - "prefix": "us", - "body": "const [${1:state}, set${2:State}] = useState(${3:initValue})$0", - "description": "React useState() hook" - }, - "useEffect": { - "prefix": "ue", - "body": ["useEffect(() => {", "\t$1", "}, [${3:dependencies}])$0"], - "description": "React useEffect() hook" - }, - "useEffect with return": { - "prefix": "uer", - "body": [ - "useEffect(() => {", - "\t$1", - "\n\treturn () => {", - "\t\t$2", - "\t}", - "}, [${3:dependencies}])$0" - ], - "description": "React useEffect() hook with return statement" - }, - "useContext": { - "prefix": "uc", - "body": ["const $1 = useContext($2)$0"], - "description": "React useContext() hook" - }, - "useRef": { - "prefix": "ur", - "body": ["const ${1:elName}El = useRef(null)$0"], - "description": "React useContext() hook" - }, - "useCallback": { - "prefix": "ucb", - "body": [ - "const ${1:memoizedCallback} = useCallback(", - "\t() => {", - "\t\t${2:doSomething}(${3:a}, ${4:b})", - "\t},", - "\t[${5:a}, ${6:b}],", - ")$0" - ], - "description": "React useCallback() hook" - }, - "useMemo": { - "prefix": "ume", - "body": [ - "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0" - ], - "description": "React useMemo() hook" - }, - "describeBlock": { - "prefix": "desc", - "body": ["describe('$1', () => {", " $0", "})", ""], - "description": "Testing `describe` block" - }, - "testBlock": { - "prefix": "test", - "body": ["test('should $1', () => {", " $0", "})", ""], - "description": "Testing `test` block" - }, - "itBlock": { - "prefix": "tit", - "body": ["it('should $1', () => {", " $0", "})", ""], - "description": "Testing `it` block" - }, - "itAsyncBlock": { - "prefix": "tita", - "body": ["it('should $1', async () => {", " $0", "})", ""], - "description": "Testing async `it` block" - } -======= "destructuring of props": { "prefix": "dp", "body": ["const { ${1:name} } = this.props"] @@ -737,5 +367,4 @@ "body": ["it('should $1', async () => {", " $0", "})", ""], "description": "Testing async `it` block" } ->>>>>>> upstream/main }