-
Notifications
You must be signed in to change notification settings - Fork 178
Linter API
The Linter API allows you to lint files of different specified scopes.
Note: Linter also supports PUSH style linters with a different API service. See Linter-Indie-API
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 provider at once by wrapping them in an Array
.
Note: You can make your provider get triggered on all scopes by using grammarScopes: ['*']
.
const provider = {
name: 'Some Linter',
grammarScopes: ['source.js', 'source.php'],
scope: 'file', // or 'project'
lintOnFly: false,
lint: function(textEditor) {
return new Promise(function(resolve, reject) {
// do something async or
return [{
type: 'Error',
text: 'Something went wrong',
range:[[0,0], [0,1]],
filePath: textEditor.getPath()
}]
})
}
}
If you think that you don't need to be asynchronous, then you can return the direct results instead of returning a Promise
.
{
type: string,
text?: string,
html?: string,
filePath?: string,
range?: Range,
trace?: Array<Trace>
}
Note: You must either provide text
or html
, providing both is an error.
Trace
is an optional type that you embed inside an Error
or Warning
.
It can be used to provide backtraces or references to other files or ranges. This is what it looks like. Also note that you can provide any type
attribute in the trace object.
// Trace
{
type: "Trace",
text?: string,
html?: string,
filePath: string,
range?: Range,
class?: string
}