The JSLint Errors API is a simple service that allows you to request explanations for JSLint, JSHint and ESLint error messages from your own applications. Potential uses include integrating error explanations into text editors, IDEs or related web UIs.
All API access is performed over HTTP and accessed from the
api.linterrors.com
domain. All data is sent and received as
JSON. All responses are sent with an Access-Control-Allow-Origin:
*
header. This means you can communicate with the API from client-
side JavaScript if you would like to.
There are no restrictions to using this API. Please just be sensible and let me know if you're planning on making thousands of requests in short periods of time. Otherwise you might find yourself throttled or banned.
This is the heart of the JSLint Errors API. It's a simple service that will attempt to return an explanation for the message you provide.
GET /explain
Name | Type | Description |
---|---|---|
message |
String |
The text of a single error message given by JSLint, JSHint or
ESLint. Aliased as m .
|
format |
String |
The format of the explanation in the response. Valid values are
md for Markdown and html for the
corresponding markup. Aliased as f .
|
Status: 200
Content-Type: application/json
Access-Control-Allow-Origin: *
{
"title": "Unexpected dangling '_' in '_x'.",
"explanation": "<markdown or html>",
"link": "http://linterrors.com/js/unexpected-dangling-_-in-a",
"codes": [
{
"linter": "jslint",
"version": "<linter version>"
}
],
"author": {
"name": "<display name>",
"twitter": "<twitter username>",
"gplus": "<google+ id>",
"gravatar": "<gravatar id>",
"bio": "<plain text>"
}
}
The response is fairly self-explanatory. The codes
property
is an array with one element for each
<pre><code>...</code></pre>
block in
the explanation. You can use this infomration if you want to generate
interactive examples as demonstrated on individual article pages on the
main site.
Author information is included and although it is not required it would be
appreciated if you could display at least the name. It would also be
appreciated if you could include the link
to the site
somewhere in your UI.
As well as providing explanations you can use the API to run a linter against some arbitrary code. This is useful is you don't want to bundle linters into your application or if you want to run code against an old or obscure version of a linter.
POST /lint
or GET /lint
Name | Type | Description |
---|---|---|
code |
String |
The code you want to validate. This can be of any length and in any
format you like. It will work best if you do not modify it at all (
by removing new lines for example) before submitting it. Aliased as
c .
|
linter |
String |
Optional. The linter to run against the code. Valid values are
jslint , jshint and eslint /
Aliased as l . Defaults to jslint .
|
version |
String |
Optional. The version of the linter. Valid values can be found in
the list of available versions or via the
/linters API route. Aliased as
v . Defaults to the latest available version of the
selected linter.
|
options |
Object |
Optional. A map of options and their values to pass on to the
selected linter. See the documentation of your chosen lint tool for
the available options. Aliased as o .
|
Status: 200
Content-Type: application/json
Access-Control-Allow-Origin: *
{
"errors": [
{
"message": "<plain text>",
"code": "<plain text>",
"line": 2
"character": 0
}
]
}
The response here is a normalised version of the response given by JSLint,
JSHint and ESLint. The code
property refers to the internal
identifier of the error if applicable.
If you want to determine the linters and versions available at run time you can use this endpoint to retrieve a list of the versions we host of each linter.
GET /linters
Name | Type | Description |
---|---|---|
linter |
String |
Optional. The name of the linter you're interested in. If specified
the response will be an array of available versions. If not
specified the response will be a map of available linters to their
versions. Aliased as l .
|
Status: 200
Content-Type: application/json
Access-Control-Allow-Origin: *
{
"jslint": [
"2014-02-06",
"2014-01-26"
],
"jshint": [
"2.4.4",
"2.4.3"
],
"eslint": [
"0.4.4"
]
}