Giter Club home page Giter Club logo

babel-sublime's Introduction

babel-sublime

Language definition for modern JavaScript with JSX syntax, Flow typing, and Styled Components.

Installation

Find it as Babel through Package Control.

Setting as the default syntax

To set it as the default syntax for a particular extension:

  1. Open a file with that extension,
  2. From the View menu, select SyntaxOpen all with current extension as…BabelJavaScript (Babel)
  3. Repeat this for each extension (e.g.: .js and .jsx).

Setting a Color Scheme

Babel comes bundled with Next from Benvie/JavaScriptNext.tmLanguage. From the command palette, select UI: Select Color Scheme and select Next.

Screenshots

babel-sublime-vs-built-in-jsx

Snippets

Find them separately at babel/babel-sublime-snippets or as Babel Snippets through Package Control.

About

Under the hood, babel-sublime's syntax definition is built using JS Custom. JS Custom is based on Sublime's core JavaScript syntax, which is in turn descended from Benvie/JavaScriptNext.tmLanguage. Special thanks go to @jgebhardt and @zpao.

Contributing

The JavaScript (Babel).sublime-syntax file itself is generated by JS Custom and should not be manually modified — any bug fixes or enhancements to the syntax itself should go through JS Custom.

If you modify the commenting rules or Next theme, make sure to do so by editing the appropriate YAML-tmPreferences or YAML-tmTheme file and converting that file using PackageDev. Then, commit both the source (YAML) file and the converted (XML) file.

babel-sublime's People

Contributors

arcanis avatar aritheelk avatar aziz avatar dashdashzako avatar devsnek avatar gpbl avatar hawkrives avatar jlc467 avatar jlhwung avatar jzelenkov avatar ljharb avatar michaelbeil avatar sindresorhus avatar thom1729 avatar voronianski avatar zaynali53 avatar zertosh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

babel-sublime's Issues

Bug with jquery.js sourcecode.

jQuery version: 1.11.2(didn't check other versions)
Line #: 2356
Screenshot of the problem: http://i.imgur.com/H5eQJ70.png
It stumbles on this whole line(doesn't highlight any syntax for some reason) AND it doesn't highlight syntax in the subsequent lines unless you remove the ternary operator in the end(question mark and further till the closing curly bracket).

If you remove this whole line it also fixes the problem.

It works fine with regular Javascript Syntax. Any ideas as to what causes it?

"Await" miscategorized?

Could be wrong about this, but my gut says 'await' belongs in keyword.control.flow alongside return and yield (the latter being a close relation) rather than in keyword.operator.

Coffeescript?

sublime-react syntax highlighting supported cjsx, i.e. coffeescript with jsx. Any plans for babel to do the same? I can't get the deprecated sublime-react syntax highlighting to work anymore.

Breaking Syntax

The following code loses all syntax highlighting after { //first comment.

The issue looks to be because of i<p -- using spaces as in i < p fixes it.

function foo() {
    let i = 0, p = 2, a = true, b = false;
    let next = i<p ? a : b;
    if (!next) { //first comment
        console.log("test")
    } else { //second comment
        console.log("test B")
    }
}

Apologies if this is the wrong repo for this ticket.

goto definition for es6 methods

goto definitions doesn't seem work for es6 methods, however they do work for standard es5 methods. Is there anything that I can look at to make it work?

Thanks!

syntax highlighting of HTML/XML snippets

I'd like to have syntax highlighting of multiline HTML and XML strings, as that is something that is available with the default JavaScript view. Here's the default view for JavaScript files:

image

And here's the same content with babel highlighting:

image

Any thoughts on adding support for HTML/XML highlighting?

Scope for class names

Currently the following rules apply in most cases:

  • A lowercase identifier is variable.other.readwrite
  • An all-uppercase identifier is variable.other.constant

It seems reasonable also to recognize that variables which begin with a capital are constructors. The only time constructors become targettable is when they are being invoked to create an instance:

new Foo(): meta.instance.constructor entity.name.type.new

How about entity.name.class or entity.name.constructor? Even in class declarations, the name does not get a targettable scope currently.

Slashes break template string highlighting

Hey,
while template strings in general are highlighted correctly, it seems like when they contain slashes everything following these is treated as a comment.

bildschirmfoto 2015-03-19 um 11 22 51

Thank you!

Use of a < with no whitespace near it results in weird colors

screen shot 2015-02-12 at 10 44 32 pm

function tableToJson(table) {
    // from http://johndyer.name/html-table-to-json/
    var data = []; // first row needs to be headers
    var headers = [];
    for (var i=0; i < table.rows[0].cells.length; i++) {
        headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'')
    }
    // go through cells
    for (var i=1; i<table.rows.length; i++) {
        var tableRow = table.rows[i]
        var rowData = {}
        for (var j=0; j < tableRow.cells.length; j++) {
            rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
        }
        data.push(rowData)
    }
    return data
}

or even as little code as

screen shot 2015-02-12 at 10 45 50 pm

i<table
return data

If I add a space to the right side of the <, all is well.

Because it's a <, I'm thinking it has something to do with the JSX highlighting, maybe?

Let me know if you need any more information.

Missing support identifiers

support.class.builtin.js is missing WeakSet and Symbol (I think Symbol is not a class, technically, but I'm not sure where else it should go).

support.type.object.node is missing require (could be grouped with support functions I suppose, but it does also have properties)

support.module.node.js is missing querystring

support.class.builtin.js is missing all of the typed arrays plus ArrayBuffer and DataView -- Babel doesn't (can't, at least meaningifully, I imagine) implement typed arrays though, so this may be intentional. On the other hand, Proxy is there and not in Babel either. I think this regex should cover the typed arrays plus Array collectively:

(Float(32|64)|(Ui|I)nt(8|16|32)|Uint8Clamped)?Array

Also absent: JSON, Reflect, and Intl.

And: setTimeout, clearTimeout, setInterval, clearInterval, setImmediate and clearImmediate (didn't even know that last one existed till just now!).

es6 functions not showing up in goto symbol in project

Just noticed that es6 functions aren't showing up in the goto symbol in project command palette - they show up just fine in the goto symbol (in the current file) palette. Is there some symbol re-indexing that I need to do? Or is there something else that needs to happen?

meta.group.braces.round.function.arguments

This scope applies correctly for bare function invocations and method invocations:

foo();
bar.foo();

But it's missing when the function is or appears to be a constructor, with or without new:

Foobar();

Whose parens instead receive meta.group.braces.round.js meta.brace.round.js

Names of static functions aren't scoped

In the following:

Deck.get = function get(keyPath) {
//...
};

get in function get(keyPath) isn't scoped to entity.name.function.js (and thus not colorized).

It's only scoped to meta.function.static.js.

Regexp delimiters

Given a regexp:

/hello/

The opening slash only has the scope string.regexp.js while the closing slash has the scope string.regexp.js punctuation.definition.string.end.js. It seems like both should be targettable.

Colour scheme seems to be inconsistent with screenshots

A small difference I can't really wrap my head around.

My object keys seem to be in yellow, and every dot is highlighted red. In the screenshots below I'm editing a .jsx file set to use the JavaScript(Babel) syntax in sublime.

screen shot 2015-04-15 at 16 39 32
screen shot 2015-04-15 at 16 39 48

Currently I'm only using it for .jsx files (I haven't fully started using es6 syntax in my normal .js files) and am moving over from sublime-react. Ideally I'd like to retain the normal colour matching with jsx support. Am I able to revert back to the highlighting shown in the readme screenshots?

Scoping JSX snippets to HTML?

Just started thinking about this, but I wanted to get a conversation going.

It should be possible to scope React's JSX blocks to HTML, most likely named text.html.jsx. If that worked, wouldn't we suddenly gain access to all of the HTML tools available to Sublime? At very least, this should enable Sublime's build-in Expand Selection to Tag. Formatters/Tidy would be welcome.

I haven't looked into what they're doing, but Allan Hortle's JSX package does allow Expand Selection to Tag to function correctly.

Suggestion: Colorize `this`

I did this in my custom Atom user stylesheet while test driving the editor, and found it to be a very good visual cue.

Move snippets to separate repo?

Not a fan of having snippets automatically included :(. Could we move em to a separate repo?

I have my own set of personal JS snippets, and since you can't disable package-specific snippets my only choice would be to fork 6to5-sublime and keep it up-to-date manually everywhere I have a sublime text installation.

Rename syntax name

Then Syntax -> Open all with current extension as... -> JavaScript JSX.

IMO, I think JavaScript JSX should be renamed to something else (maybe JavaScript 6to5?). JSX isn't the only thing that has highlighting support, but generally/ideally anything that 6to5 supports syntactically (e.g. ES7+).

React component skeleton

I've been using different 'flavor' of React.createClass

'use strict';

import React from 'react';

export default React.createClass({
    render() {
        return ();
    }
})

I'd like to update the snippets with this minimalistic approach of exporting the component + adding the 'use strict'; statement. What do you think?

Odd scope encountered -- correct behavior?

I'm not sure what's going on here with the maxLogs identifier (yellow):

image

The scope on maxLogs is:

(...) constant.other.object.key.js string.unquoted.label.js

If I enclose it in parentheses, the scope changes to variable.other.readwrite, which is how it gets identified everywhere else it appears. To replicate this, the pattern seems to be:

In any ternary, if the expression between ? and : is not enclosed in parentheses, and the last value is an identifier, and the total expression is not just a single identifier, then that last value will get this odd scope.

Ternaries with spaces before colon breaks highlighting.

For example:

Imgur

This appears to be caused by the space in the ternary.

Copy-paste this snippet to your editor:

'use strict';
var React = require('react');
function test() {
  var a = "bar";
  return (
    <div foo="bar" className={"foo" + (a ? 'foo' :'bar')} herp="derp">
      <div foo="bar" className={"foo" + (a ? 'foo':'bar')} herp="derp" />
    </div>
  );
}

Play with spaces before/after the :.

Storage type differentiation

Currently, the following are all under storage.type:

  • async
  • var
  • let
  • constant
  • static

Contrast with function, arrow function, class, accessor (get/set), and extends, which all have unique scopes (aside: is "extends" really a "storage type"? I'm no grammar buff, so I could be totally wrong, but isn't it almost more of an operator? scratch that, no ... I have no idea what it should be).

It would be helpful to be able to target more specific scopes for the items above. In particular, async and static seem categorically different from var, let and constant to me.

Move snippets to separate plugin

How about an idea to create separate ST plugin with snippets from SNIPPETS.md, something like react-es6-snippets? These snippets are useful and it is not fun to copy them by hands. I can do it by myself, just look for approval, hope there is no any scary legal stuff.

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.