How to know if I have a syntax error in my code


Hi, I’m new in atom, and I’d like to know how to configure atom for mark the syntax error in my code. Thanks


Hi there, You’ll have to give us some more details if you want us to help you. Like the language you’re using. Some linters may help you for that, but only if there’s a linter for the language you’re using and if it can detect syntax errors.


Sorry, I did not explain well. Before I used to use Komodo Edit, and when I had a syntax error like does not close a brace properly, komodo warning me the line and the column in the code. Can Atom warning me if I have a syntax error in any language.


As @abe eluded to, there is a package called Linter, which provides this as a service. You install the Linter and e.g. linter-jshint packages (depending on your language of choice) and off you go.


The short answer is no.

The long is that you can’t have a unified validation model that fits every known languages. There’s certainly some rules that are common to many languages, like braces that should always be closed, but you’ll always find a language that have some idioms that breaks these rules. I don’t know how komodo achieve that but I highly doubt that it can detect syntax errors for every languages. It probably supports a wide sets of widely used languages but that doesn’t make it know every languages. What if someone want to write some brainfuck?


It’ll be on a language-by-language basis, is what he’s saying. :stuck_out_tongue:


Thanks for all the answers. Linter is what I was searching.


Thanks for the answer, and you are right, I was reading in komodo that it has some templates like html, php, js, and it detects the syntax error for each language. Thanks for you time.


Is there support for C#?


JSHint looks nice, but it doesn’t support async / await - and it requires that I setup a local .jshintrc file. Isn’t there a package that does it globally or something? Perhaps something that hooks into acorn on npm?

…maybe I’ll have to investigate creating a linter provider. I’ve already writteen a bash script for this purpose, so a litner shouldn’t be too much of a stretch.


JSHint is deprecated (or at least strongly discouraged to be used). ESLint is what I’ve seen recommended these days, and there is already a linter-eslint package for it to interface with Atom.

Plus it supports await/async.


Hrm, I see. Doesn’t ESLint still require a config file though?


There is a tick box for “disabling when none is found” (I don’t know what it does if it can’t find one & is enabled), and there is a place to specify the global config file to fall back on if one cannot be found in the project.

I still highly recommend a local config though; it makes it easier for other people working on the project to have consistent lint settings.


Ah, ok.

Yeah, I do understand the values of a local config file, but right now I just want basic syntax error detection for random files that I open that aren’t part of any particular project.

Thanks! I’ll look into it.


could anyone tell me which linter ui is being used in the image above? i am unable to find its name even after searching for hours!


@thecyberguy That image is over 3 years old, I’m afraid. I haven’t used Atom in quite while, so can’t say what the preferred linter is package is these days, sorry.


Thanks! i got a solution for it. Reference:
Don’t see nice UI suggested by “Linter in action!” #169