Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Update to support new linter APIs #16

Merged
merged 7 commits into from
Oct 15, 2015
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@ linter-gjslint

This linter plugin for [Linter](https://github.com/AtomLinter/Linter) provides an interface to [gjslint](https://developers.google.com/closure/utilities/). It will be used with files that have the “JavaScript” syntax.

## Installation
Linter package must be installed in order to use this plugin. If Linter is not installed, please follow the instructions [here](https://github.com/AtomLinter/Linter).

### gjslint installation
Before using this plugin, you must ensure that `gjslint` is installed on your system. To install `gjslint`, read [this](https://developers.google.com/closure/utilities/docs/linter_howto).

### Plugin installation
```
$ apm install linter-gjslint
```
## Installation
Run `amp install linter-gjslint` or search for `linter-gjslint` in Atom package manager.

## Settings
You can configure linter-gjslint by editing ~/.atom/config.cson (choose Open Your Config in Atom menu):
```
'linter-gjslint':
'gjslintExecutablePath': '' #gjslint path. run 'which gjslint' to find the path
'gjslintIgnoreList': [] #gjslint ignore codes from http://goo.gl/OhYHYl
'executablePath': '' #gjslint path. run 'which gjslint' to find the path
'gjslintIgnoreList': [] # Currently not implemented: gjslint ignore codes from http://goo.gl/OhYHYl
```

## Contributing
Expand Down
49 changes: 46 additions & 3 deletions lib/init.coffee
Original file line number Diff line number Diff line change
@@ -1,13 +1,56 @@
{CompositeDisposable} = require 'atom'
{findFile, exec, tempFile} = helpers = require 'atom-linter'
path = require 'path'

module.exports =
config:
gjslintExecutablePath:
executablePath:
type: 'string'
default: ''
title: 'gjslint executable path'
default: 'gjslint'
gjslintIgnoreList:
type: 'array'
default: []
items:
type: 'string'

activate: ->
console.log 'activate linter-gjslint'
@subscriptions = new CompositeDisposable
@subscriptions.add atom.config.observe 'linter-gjslint.executablePath',
(executablePath) =>
@executablePath = executablePath

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Install deps using atom-package-deps here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by the example - shouldn't require('atom-package-deps').install() take an optional callback instead of a string?
https://github.com/travs/atom-package-dependencies/blob/master/index.js#L6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atom-package-dependencies vs atom-package-deps.

deactivate: ->
@subscriptions.dispose()
provideLinter: ->
helpers = require('atom-linter')
provider =
name: 'gjslint'
grammarScopes: ['source.js', 'source.js.jquery', 'text.html.basic']
scope: 'file'
lintOnFly: true
lint: (editor) =>
filePath = editor.getPath()
cwd = path.dirname(filePath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path hasn't been imported, so it crashes on this line currently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why it's not on my local setup :) anyway - fixing now

tempFile path.basename(filePath), editor.getText(), (tmpFilePath) =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is tempfile really necessary? I mean does it not support stdin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK no,
cat test.js | gjslint gives

0 files checked, no errors found.

So, I suspect no :(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

google/closure-linter#96
We don't have to wait for it

params = [
'--nobeep',
'--quiet',
tmpFilePath
]
return helpers.exec(@executablePath, params, {cwd}).then (stdout) ->
regex = /Line\s(\d+), E:(\d+):\s(.+)/
lines = stdout.split('\n').filter (line) ->
line.indexOf('Line') is 0

return [] unless lines.length
return lines.map (msg) ->
res = regex.exec(msg)
[all, line, code, text] = res
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to include the code in your message, to make looking up the error simpler if the user is unfamiliar with it or it is not showing results they are expecting.

line = parseInt(line, 10)
text = 'E:' + code + ' - ' + text
return {
text: text,
type: 'error',
filePath: filePath,
range: helpers.rangeFromLineNumber(editor, line - 1)
}
44 changes: 0 additions & 44 deletions lib/linter-gjslint.coffee

This file was deleted.

16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
{
"name": "linter-gjslint",
"main": "./lib/init",
"linter-package": true,
"version": "0.0.5",
"description": "Linter plugin for JavaScript, using gjslint (Google Closure Linter)",
"repository": "https://github.com/AtomLinter/linter-gjslint",
"license": "MIT",
"engines": {
"atom": ">0.50.0"
},
"dependencies": {}
"dependencies": {
"atom-linter": "^3.2.0",
"atom-package-deps": "^2.0.2"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the package-deps section of the manifest? 😃

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disregard, just saw it a few lines below this one.

},
"package-deps": [
"linter"
],
"providedServices": {
"linter": {
"versions": {
"1.1.0": "provideLinter"
}
}
}
}