entity.name.function.js scope not applied to arrow functions inside class definitions
See original GitHub issueEnv
Running Sublime Text build 3176 on OSX, version v1.0.22 of this package.
Steps to repro
Paste this code into the editor.
import React from 'react'
const Test = ({ a, b }) => {
f1 = (e) => {
e.preventDefault()
}
return null
}
export default Test
class TestComponent extends React.Component {
f2 = (e) => {
e.preventDefault()
}
render() {
return null
}
}
Set the syntax to JS Custom - React or JS Custom - Default and hit <kbd>cmd+R</kbd>. The function identifier f2 isn’t indexed, because the entity.name.function.js
scope isn’t applied to it.
If you set the syntax on the view to JavaScript and hit <kbd>cmd+R</kbd>, f2 is indexed, which is correct, but so are other symbols which are neither function nor class definitions.
Also, if you save the file and hit <kbd>shift+cmd+R</kbd> to see all indexed symbols in the project, f2 is indexed correctly.
Other observations
It seems that the base JavaScript syntax applies the correct scope to arrow functions defined inside class definitions, while the JS Custom syntaxes do not.
@Thom1729
I’m really happy you’re working on this plugin. babel-sublime
dev has been inactive for most of the last two years, so I’m hoping this plugin is the way forward for writing JS in Sublime Text. If there’s anything you’d like help with, let me know.
Finally, great decision to piggyback as much as possible on the new JavaScript syntax. Reading about why you decided to do that is what made me switch to this package from Babel Sublime.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
I’m seeing the same behavior between the core JavaScript syntax and JS Custom.
f2
is not indexed because the class property code doesn’t check for function assignments. This should be addressed in core; I’ll see if I can write a PR in the next couple of days.You’re seeing that the core syntax is indexing
f2
?@Thom1729
Hmmm… I installed ST build 3182, which includes the upstream fixes you mentioned, and am running JS Custom v1.0.23.
If I set the syntax to plain JavaScript,
method
is indexed, which means the upstream fix works.However, if I set the syntax to JS Custom - Default or JS Custom - React,
method
is not indexed.I tried removing the User/JS Custom folder and rebuilding the syntaxes to no avail. I also tried uninstalling JS Custom and reinstalling it.
I am using the default
JS Custom.sublime-settings
that ships with the plugin.Maybe I’m doing something stupid, but I’ve looked at the README and I can’t figure out what!