gandm / language-babel Goto Github PK
View Code? Open in Web Editor NEWES2017, flow, React JSX and GraphQL grammar and transpilation for ATOM
Home Page: https://atom.io/packages/language-babel
License: MIT License
ES2017, flow, React JSX and GraphQL grammar and transpilation for ATOM
Home Page: https://atom.io/packages/language-babel
License: MIT License
It doesn't like the quotes around property keys.
{
"users.name": {
type: 'string',
required: true
}
}
This error pops up whenever babel will starting to transpile a file on save.
Atom Version: 1.0.2
System: Mac OS X 10.10.4
Thrown From: language-babel package, v0.10.3
Uncaught TypeError: Cannot read property 'version' of null
At /Users/furkantunali/.atom/packages/language-babel/lib/transpiler.coffee:79
TypeError: Cannot read property 'version' of null
at /Users/furkantunali/.atom/packages/language-babel/lib/transpiler.coffee:79:32
at /Users/furkantunali/.atom/packages/language-babel/node_modules/babel-core/lib/api/node.js:121:5
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:379:3)
-1:31.6.0 emmet:insert-formatted-line-break-only (atom-text-editor.editor.is-focused)
-1:31.6.0 docblockr:parse-enter (atom-text-editor.editor.is-focused)
-1:31.6.0 editor:newline (atom-text-editor.editor.is-focused)
-1:31.2.0 emmet:insert-formatted-line-break-only (atom-text-editor.editor.is-focused)
-1:31.2.0 docblockr:parse-enter (atom-text-editor.editor.is-focused)
-1:31.2.0 editor:newline (atom-text-editor.editor.is-focused)
-1:29.5.0 autocomplete-plus:confirm (atom-text-editor.editor.is-focused.autocomplete-active)
-1:29.5.0 snippets:expand (atom-text-editor.editor.is-focused.autocomplete-active)
-1:28.5.0 core:backspace (atom-text-editor.editor.is-focused)
-1:28.2.0 linter:set-bubble-transparent (atom-text-editor.editor.is-focused)
-1:26.5.0 core:save (atom-text-editor.editor.is-focused.autocomplete-active)
-1:25.2.0 script:run (atom-text-editor.editor.is-focused)
-0:10.1.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
-0:10.1.0 core:cancel (atom-text-editor.editor.is-focused)
-0:07.7.0 core:save (atom-text-editor.editor.is-focused)
-0:05.0 core:copy (atom-notification.fatal.icon.icon-bug.native-key-bindings.has-detail.has-close.has-stack)
{
"core": {
"projectHome": "/Users/furkantunali/Sites",
"disabledPackages": [
"deprecation-cop",
"recent-files",
"browser-refresh"
],
"excludeVcsIgnoredPaths": false,
"themes": [
"one-light-ui",
"one-light-syntax"
]
},
"language-babel": {
"createTranspiledCode": true,
"disableWhenNoBabelrcFileInPath": true,
"babelSourcePath": "src",
"babelTranspilePath": "dist",
"externalHelpers": true,
"suppressSourcePathMessages": true,
"babelMapsAddUrl": false,
"createMap": true
}
}
# User
atom-alignment, v0.12.1
atom-beautify, v0.28.8
atom-color-highlight, v3.0.9
autocomplete-paths, v1.0.2
autocomplete-phpunit, v1.0.2
browser-plus, v0.0.30
build, v0.42.0
docblockr, v0.7.3
editorconfig, v1.0.1
emmet, v2.3.12
file-icons, v1.5.8
file-types, v0.5.1
highlight-selected, v0.10.1
indentation-indicator, v0.6.0
language-SCSS, v0.4.0
language-apache, v1.3.0
language-babel, v0.10.3
language-css, v0.32.1
language-dotenv, v1.0.0
language-fish-shell, v1.0.2
language-generic-config, v0.2.0
language-gettext, v0.6.1
language-gitignore, v0.2.0
language-hosts, v0.1.2
language-ini, v1.11.0
language-javascript, v0.85.0
language-liquid, v0.4.0
language-mustache, v0.12.0
less-autocompile, v1.0.0
linter, v1.2.4
linter-bootlint, v0.0.6
linter-coffeelint, v1.0.0
linter-csslint, v0.0.14
linter-eslint, v3.0.1
linter-handlebars, v2.0.0
linter-htmlhint, v0.0.17
linter-jscs, v1.13.0
linter-jshint, vundefined
linter-jsonlint, v0.1.4
linter-less, v2.0.3
linter-php, v1.0.2
linter-phpcs, v1.0.6
linter-phpmd, v1.0.0
linter-pylint, v0.2.2
linter-recess, v0.0.1
linter-ruby, v0.1.6
linter-scss-lint, v2.0.0
linter-shellcheck, v0.0.8
local-history, v3.2.3
minimap, v4.12.1
minimap-color-highlight, v4.1.4
minimap-selection, v4.3.0
node-debugger, v1.1.6
pigments, v0.9.2
remote-atom, v1.2.6
sass-autocompile, v0.7.3
sass-compiler, v0.4.0
sass-watch, v0.3.1
script, v2.26.3
soft-wrap-indicator, v0.7.0
ssh-config, v0.10.1
tab-control, vundefined
tabs-to-spaces, v0.11.0
theme-switcher, v1.1.0
# Dev
No dev packages
Since 0.11.0, parentheses and the parameters themselves are displayed in different colors than before.
Was this an intended change? Here's how it looks on Sublime Text 3 with the babel package installed (also notice the import
and from
keywords):
I'm using the oceanic-next-syntax syntax theme, if that matters.
The function parameters do not have their own style anymore. And something happened some releases ago that this parameters had a different color from the blue one that you can see on let
and on @param
.
It was in v0.10.0:
Parameters where highlighted in their unique color but ES6 class functions were not getting highlighted and @param flags on docblockr were just gray. I'd like that orange parameter color back on ^0.13.3 pleasee
Disabled JSX attribute name highlighting. Shame, but seems impossible to fix unless I attack the whole grammar. Can't see it's worth it so I'm closing.
Here I want to type the instance where my sql server runs and it appears it's highlighting a javascript regex or escape character, the core javascript grammar behaves the same way.
I expected it would just highlight when it's one of those escape characters for e.g:
\n
\r
\'
In this code
export default class Cls {
static CONSTANT = 1;
}
class and static are not highlighted as keywords
The package allows to define the folder where the files will be transpiled filling in the setting the field Babel Transpile Path
. Is is possible to store this value in a config file? is is maybe in babelrc?
I haven't released support for typing a var. e.g. let a: string
I have experimented with quite complex types for vars as well as multiple vars in a single statement with assignments and the only way I can make it work well is if I can guarantee a statement termination. e.g. ;
I will take another look given time.
Admittedly this is probably an edge case that might not occur a lot. Flow doesn't have first-class support for immutable-js records, so a slightly redundant hack to make Flow understand the types of the getters is to make a class that extends the record and adds Flow types as properties. The immutable-js docs also explicitly mentions that immutable records can be extended to add custom methods.
In this snippet, all syntax highlighting from the line under foo: Immutable.List<string>
all the way to the end of the file is messed up:
class First extends Immutable.Record({
foo: null,
}) {
foo: string;
getStuff(): string {
return this.foo + '!';
}
}
class Second extends Immutable.Record({
foo: null,
}) {
foo: Immutable.List<string>;
getStuff(): string {
return this.foo + '!';
}
}
(notice different highlighting of second getStuff
and return
)
Modifying the Immutable.Record
call so it's on a single line fixes the syntax highlighting:
Splitting the creation of the record and the subclassing into two separate statements also works properly:
I've got a very small start towards this in this branch that only supports type annotations in argument lists. Return type annotations break things:
Should the return types be added to the end
patterns of all the varieties of function literals or is there a better way to accomplish that without so much repetition?
Would you restrict this scope just to be applied inside a class?
I want to give it another highlight color without overwriting variable declarations, imports, etc.
class {
constructor () {
super.foo();
}
}
e.g.
var play = async <a,t>(args: string): string => {}
<a,t> not working.
This is not really an issue, but I couldn't find a place for general discussion.
Do you have any suggested dark themes to use along with this package? The default Atom theme doesn't seem very nice, it has a lot of red in it. Seems like a lot of symbols are red.
Repro:
var Foo = {
first(): string {
return 'Hello first';
},
second(
ids: Array<number>,
mutateFn: (record: MyRecord) => MyRecord
): string {
return 'Hello second';
},
third(): string {
return 'Hello third';
}
};
Notice that mutateFn
is not highlighted at all, the return
keywords change colour, the braces are red, and third()
is not highlighted correctly.
This is how it looks when using language-javascript-jsx):
To prevent from trying to compile *.js
files, I added a .babelrc
file with the following contents:
{
"only": [ "*.es6" ]
}
This seems to be ignored, as I still get the error message "Transpiled file would overwrite source file. Aborted!" when editing a *.js
file (in my case the Gruntfile.js
).
In my setup I want all *.es6
files to be compiled to *.js
files located next to their according source file.
I had a look at your source code at differently tagged versions and I saw, that reading the babelrc file was dropped starting with version 0.8.0. How is it supposed to work now?
This grammar has certain limitations.
static a: number = 1;
Hi,
I just came to Atom world from Sublime and I'm trying to compile a .jsx component and when I try to save it always appears this message
Babel v5.6.15 Transpiler Error
/app/components/Lane.jsx: Unexpected token (35:18)
The line that is broking
const {i, name, ...props} = this.props;
Referring the spread operator.
Most linters I use have this option, which avoids having the plugin run in all projects which contain JS files.
Any occurrence of the word 'type' is colored like other storage keywords. It also seems to have weird effects for the rest of the line as well.
I poked around a bit and it looks like the pattern is here: https://github.com/gandm/language-babel/blob/master/grammars/Babel%20Language.json#L1696
Not super familiar with language grammars so please disregard if it is something with my setup/syntax theme.
Thanks!
Should I install anything else to activate flow grammar? I put /* @flow */
at the beginning of file but there is no check of the file
Hi,
Great package and pretty long awaited, thank you!
One thing is missing though. Most babel users use .babelrc containing babel configuration which can be different in different projects and even folders. So it would be great if language-babel could get that configuration from .babelrc about stage, blacklist transformers, optional transformers, etc. and apply it to corresponding scope this .babelrc is in.
Thanks again, great job!
statements like arg => {}
are tricky to parse well using current grammar. Use (arg) => {}
as a alternative.
When editing a .jsx
file, the symbols view (Cmd-R) is empty and displays the message "No symbols found". If I rename the same file to .js
, the symbols view displays all the symbols I would expect it to. I've tried a variety of files, and it doesn't seem to be related to the contents at all; just the extension.
(Other than this minor issue, I'm really loving this syntax! Thanks for putting it together.)
Love the Atom plugin. But I get success on Save so often when I'm really only interested in transpile failures. I'd love to see a preference for suppressing notification for successes.
Currently it looks like this:
mixins: [
Stores.CurrentUser.mixin,
Stores.CoachParticipants.mixin,
Stores.Errors.mixin,
Stores.LastViewed.mixin,
Stores.ParticipantConversations.mixin,
Stores.ParticipantGoal.mixin,
Stores.ParticipantSuggestions.mixin,
Stores.PendingUpdate.mixin,
RouteHandlerKey
],
I expect it to look like this (how https://github.com/atom/language-javascript indents them):
mixins: [
Stores.CurrentUser.mixin,
Stores.CoachParticipants.mixin,
Stores.Errors.mixin,
Stores.LastViewed.mixin,
Stores.ParticipantConversations.mixin,
Stores.ParticipantGoal.mixin,
Stores.ParticipantSuggestions.mixin,
Stores.PendingUpdate.mixin,
RouteHandlerKey
],
Using this with Atom, really liking it but the notifications are a little intrusive. I like them because they give me good feedback, but their position means I can't access tabs they cover, they also stay up for too long sometimes.
Would be great if changing their timing and position was configurable.
The grammars are still enabled, is it possible to have a disable for the grammars? It can conflict with other grammars that provide the same function through a different scope.
Hey,
I really like the indentation and syntax highlighting the only thing bugging me is the non existing indentation of switch statements.
Currently this is the indentation provided:
switch(foo) {
case 0:
bar = batz;
break;
I would love if you could make it like this:
switch(foo) {
case 0:
bar = batz;
break;
Would increase readability by a lot.
As soon as I reverted to 0.10.4, Script: Run worked properly again. No other changes were made (by me).
The space within JSX tags currently has a class string of .markup.raw.jsx
when rendered in Atom. This causes a problem for any theme expecting .markup.raw
to be used for raw HTML within a Markdown document (wesbos/cobalt2-atom#2).
.markup.raw
(and .markup
in general) seems to be mostly used for Markdown rather than XML/HTML. See atom/language-gfm/grammars/gfm.cson#L717. language-xml and language-html appear to have no reference to .markup
at all.
I'm not sure what class string would be best for your project (which is why this isn't a PR), but for what it's worth, language-html and language-xml both fall back to their base scope names (.text.html.basic
and .text.xml
) for content within tags.
When setting syntax to Babel ES6 Javascript, syntax highlighting from https://atom.io/packages/language-todo does not work.
Minimal case:
a(a ? b : this.foo.bar.baz || foo.bar())
Everything in the "else" condition of the ternary completely fails to get highlighted.
Since upgrading atom today I'm getting this error all the time.
Uncaught AssertionError: true === false
/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:774
Hide Stack Trace
AssertionError: true === false
at Def.Dp.bases (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/babel-core/node_modules/ast-types/lib/types.js:408:12)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/patch.js:45:26)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/util.js:21:1)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/transformation/file/options/parsers.js:16:13)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/transformation/file/options/index.js:13:16)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/transformation/file/index.js:15:16)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/transformation/plugin.js:37:13)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/transformation/transformer.js:11:15)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/transformation/file/plugin-manager.js:15:20)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/transformation/pipeline.js:11:26)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/transformation/index.js:11:17)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/lib/babel/api/node.js:22:23)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/Users/gbirman/.atom/packages/language-babel/node_modules/babel-core/index.js:1:80)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Transpiler.transpile (/Users/gbirman/.atom/packages/language-babel/lib/transpiler.coffee:37:15)
at /Users/gbirman/.atom/packages/language-babel/lib/babel-transpiler.coffee:17:21
at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
at TextBuffer.module.exports.TextBuffer.saveAs (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:996:20)
at TextBuffer.module.exports.TextBuffer.save (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:978:19)
at TextEditor.module.exports.TextEditor.save (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:579:26)
at Pane.module.exports.Pane.saveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:535:18)
at Pane.module.exports.Pane.saveActiveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:518:19)
at Workspace.module.exports.Workspace.saveActivePaneItem (/Applications/Atom.app/Contents/Resources/app.asar/src/workspace.js:592:35)
at atom-workspace.atom.commands.add.core:save (/Applications/Atom.app/Contents/Resources/app.asar/src/workspace-element.js:311:30)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:241:29)
at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:520:16)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:355:22)
at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:177:20)
The error was thrown from the language-babel package. You can help by creating an issue. Please explain what actions triggered this error.
Create issue on the language-babel package
Text that matches constant.other.object.key.js
is being matched and having the classes string.unquoted.label.js
applied. The .label
class applies Bootstrap's CSS which has bold, a different font size, and padding, which all contribute to making the rendered text a headache to edit because the visible location of the cursor does not match the actual cursor position, and therefore I end up editing the wrong characters.
Now the testWithLabel
is default syntax highlighting. ing
key is that is detected by another grammar pattern and correctly highlights. testWithoutLabel
is what I expect to see, and I was able to accomplish by manually removing the label
class from the element in the DOM.
let obj = {
testWithLabel: null,
testWithoutLabel: null,
ing: function() {
}
};
See https://github.com/gandm/language-babel/blob/master/grammars/Babel%20Language.json#L197
"literal-labels": {
"patterns": [
{
"begin": "(?<!\\?)(?<!\\?\\s)(?=(((')((?:[^']|\\\\')*)('))|((\")((?:[^\"]|\\\\\")*)(\")))\\s*:)",
"end": ":",
"endCaptures": {
"0": { "name": "punctuation.separator.key-value.js" }
},
"patterns": [
{ "include": "#literal-string" }
]
},
{
"name": "constant.other.object.key.js",
"match": "(?<!\\.|\\?|\\?\\s)([_$a-zA-Z][$\\w]*)\\s*(:)",
"captures": {
"1": { "name": "string.unquoted.label.js" },
"2": { "name": "punctuation.separator.key-value.js" }
}
}
]
},
I'm not sure if this is a language-babel issue or a package manager issue, but language-babel
does not appear in the package manager, and it seems to be the only package I have that's doing that. I'm using Atom 1.0.2 on OS X 10.11. Right now, the only way I can edit the package settings is by searching for the package on the "install" tab.
Just wanted to bring this up, but when using the babel plugin the indentation gets a bit off with text-to-cursor location. This is mostly problematic with maps, where keys that have no quotes around them cause the cursor to be a few characters behind where is should be:
The cursor (in the above image) is between the last double quote, but if I start typing characters appear after the comma.
If this is something that only i'm experiencing, let me know, but I'm only able to get it to work with the Babel plugin (but not the normal JS or JSX plugin). Also free to give any other info you might need!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.