Git Product home page Git Product logo

Comments (9)

bathos avatar bathos commented on May 23, 2024 2

@aziz I’m currently rewriting the JSX stuff from scratch. I’d worked originally off the published grammar, which in practice isn’t accurate (uses xml-style namespacing, for example). I’ve added tentative half-assed support for Styled JSX to the latest release, but am hoping to address it properly soon.

from ecmascript-sublime.

aziz avatar aziz commented on May 23, 2024 1

that's great to hear. BTW, JSX has got some additions last week, Fragments.
I hope you can add support for that as well

render() {
  return (
    <>
      <ChildA />
      <ChildB />
      <ChildC />
    </>
  );
}

from ecmascript-sublime.

bathos avatar bathos commented on May 23, 2024

We can add this to ES Sublime, but with the context limitations it will only be possible to add the extra annotation to classes that conform to the pattern class ws+ (name ws+)? extends ws+ React ws* dot ws* Component ws* leftBrace. Do you consider that good enough? Are there other patterns that you can think of that would be signals and are unlikely to generate false positives?

from ecmascript-sublime.

aziz avatar aziz commented on May 23, 2024

I don't think you understand me correctly. I asked to add a more specific scope to React component names when they're referenced in JSX.
Note the different color in the screenshot above between <BasketContent> and a normal html tag like <div>.
This is easy since inside JSX, all react component should always be capitalized and html tags are lower cased. I think this is what VSCode Syntax Highlighter is doing.

so inside JSX, <Div> is a react component but <div> is the normal html tag.

from ecmascript-sublime.

bathos avatar bathos commented on May 23, 2024

Ah, got it, when I saw the scope list in the screenshot I was thinking 'support.class.component' was an outer scope containing the entire class declaration. Yes, distinct scopes for html vs custom component names makes sense — and unless I’m mistaken about how JSX works today, I’m pretty sure it literally determines token type by casing (i.e. they don’t use a whitelist anymore, and it’s not merely convention but actually part of the syntax ... I think?).


BTW, I’m currently on a project that uses JSX at work, and now that I’m using it regularly myself I may look into further enhancements to how ES Sublime handles it — if you have more ideas for this I can hit them all at once.

from ecmascript-sublime.

aziz avatar aziz commented on May 23, 2024

it literally determines token type by casing

Yes

if you have more ideas for this I can hit them all at once.

I'll see what I can put on my wishlist

from ecmascript-sublime.

aziz avatar aziz commented on May 23, 2024

My biggest pain in working with JSX is that I lose all the nice features that sublime gives you when working with a normal HTML file.
Things like, Auto-completion or Auto closing tags or Auto indentation.
I know JSX is not HTML but it would be awesome if we could find a way to make those features work inside a JSX block as well.

from ecmascript-sublime.

bathos avatar bathos commented on May 23, 2024

We can probably lift this logic from the XML syntax def wholesale (JSX is slightly closer to XML than HTML as far as element logic goes).

from ecmascript-sublime.

aziz avatar aziz commented on May 23, 2024
  • JSX syntax highlighter is a bit aggressive and quickly mark half of the page as invalid

from ecmascript-sublime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.