Atom Snippets - Unexpected New Line Error
Asked Answered
O

2

5

I've been trying to add my first snippet in the Atom text editor and I keep getting the error that there's an unexpected newline.

'.source.css':
'setup CSS':
'prefix':'setup'
'body':"""
*, *:before, *:after{
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
.clearfix:after {
  visibility: hidden;
  display: block;
  font-size: 0;
  content: " ";
  clear: both;
  height: 0;
}
"""

I'm running on Ubuntu and Atom 1.0.2

Off answered 9/7, 2015 at 16:30 Comment(1)
I got rid of the error by having proper indentation. I know get no error from Atom however, the actual snippet doesn't work in a CSS file.Off
F
8

Like Haml, CSON uses indentation to define scope.

Simply indent after '.source.css': and after 'setup CSS':

'.source.css':
    'setup CSS':
        'prefix':'setup'
        'body':"""
*, *:before, *:after{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
"""

what is cson?

Filamentary answered 16/12, 2015 at 13:22 Comment(0)
P
7

This sort of error pisses me off to no end, too. My suggestion would be to install the linter-coffeelint package for Atom to at least make it easier to deal with. The package is at atom.io/packages/linter-coffeelint, and you can install it directly from the command line by apm install linter-coffeelint

It is an indentation problem, but from my perspective, unless you write in Coffeescript regularly (let alone at all), it's much harder to see the problem when the error message you get from Atom doesn't even specify which line the error is on.

Prosperous answered 17/12, 2015 at 22:53 Comment(2)
Thank you very much. This was able to help me find the problems (multiple times!).Glasgow
2 years later and still no sign of getting proper snippet feedback! Thanks for the package suggestion, it's very useful.Frizette

© 2022 - 2024 — McMap. All rights reserved.