babel / babel-sublime-snippets

Next generation JavaScript and React snippets for Sublime
https://babeljs.io
262 stars 47 forks source link

Snippets stop working if a PropTypes definition exists #22

Open rvazarkar opened 8 years ago

rvazarkar commented 8 years ago

Snippets will only work if your cursor is above the propTypes definition in a jsx file.

Apparently the propTypes syntax breaks the scope for the snippet parser, my guess is because of the colon + curly braces. Removing the propTypes definition will allow snippets to work anywhere in the class again

As a note, this is in ES6 class syntax

chocobuckle commented 7 years ago

I'm seeing the same behaviour.

lilrogalski commented 7 years ago

I"m also having this issue

codeninja commented 5 years ago

Anything with this format will break the scope.

state = { 
}

I believe it's the equals sign which is causing the issue.

Scope above the state={} Screen Shot 2019-05-11 at 1 25 51 PM

Scope below the state={} Screen Shot 2019-05-11 at 1 26 09 PM

My source test:

class Root extends R.Component {  

  propTypes = {}

  state = {}

  constructor(props) {
    super(props)

  }

  render() {
    return (
      <div>

      </div>
    )
  }
}

export default Root

Changing the scope to meta.class.js will allow the commands to work properly. And I think this is happening because we're defining a class property, so TM thinks we're looking to assign more meta.class.property.js.

This syntax works and allows me to add above and below the propTypes assignments, but not inside braces or parentheses.

<scope>source.js meta.class.js -meta.group.braces.round -meta.group.braces.curly </scope>