Skip to content
Steel Brain edited this page Jun 28, 2015 · 49 revisions

The Linter API allows you to lint files of different specified scopes.

Defining a provider

You will need to add this to your package.json file

"providedServices": {
  "linter": {
    "versions": {
      "1.0.0": "provideLinter"
    }
  }
}

and You should return an object like this from your provideLinter function

Note: You can return more than one providers at once by wrapping them in an Array.

provider =
  grammarScopes: ['source.js', 'source.php']
  scope: 'file' # or 'project'
  lintOnFly: false # must be false for scope: 'project'
  lint: (textEditor)->
    return new Promise (resolve, reject)->
      message = {type: 'Error', text: 'Something went wrong', range:[[0,0], [0,1]]}
      resolve([message])

If you think that you don't need to be asynchronous, then You can return the direct results instead of returning a Promise.

Messages

{
  type: string,
  text?: string,
  html?: string,
  filePath?: string,
  range?: Range,
  trace?: Array<Trace>
}

Trace is an optional type that you embed inside an Error or Warning.

It can be used to provide backtraces or reference to other files or ranges. This is how it looks like. Also note that you can provide any type attribute in the trace object.

Screenshot

// Trace
{
  type: "Trace",
  text?: string,
  html?: string,
  filePath: string,
  range?: Range
}
Clone this wiki locally