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

Commit 59c0d09

Browse files
committed
Merge pull request #14 from AtomLinter/steelbrain/upgrade
Upgrade to the latest API
2 parents 1bd7c48 + 5485a66 commit 59c0d09

File tree

6 files changed

+52
-72
lines changed

6 files changed

+52
-72
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
node_modules

README.md

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,20 @@
11
linter-lua
22
===========
33

4-
> luac — The luac program parses lua files. It can be used for detecting errors in lua code. See [http://www.lua.org/manual/4.0/luac.html](http://www.lua.org/manual/4.0/luac.html) for more informations about luac.
5-
6-
This package will lint your `.lua` opened files in Atom through luac or [luajit](http://luajit.org/running.html). **It will lint on edit and/or save**, so you'll see instantly if your code has errors.
4+
linter-lua package will lint your `lua` in Atom through luac or [luajit](http://luajit.org/running.html).
75

86
Due to the way that luac works it will only notify you of the first error found in the file.
97

10-
## Linter Installation
8+
#### Linter Installation
119
Before using this package, you must ensure that `luac` or `luajit` is installed on your system.
1210

13-
## Installation
11+
#### Installation
1412

1513
* `$ apm install linter` (if you don't have [AtomLinter/Linter](https://github.com/AtomLinter/Linter) installed).
1614
* `$ apm install linter-lua`
1715

18-
## Configuration
16+
#### Configuration
1917

2018
Atom -> Preferences... -> Packages -> Linter lua -> Settings:
2119

2220
* **Executable** Path to your `luac` or `luajit` executable.
23-
24-
## Other available linters
25-
- [linter-luacheck](https://atom.io/packages/linter-luacheck), for lua using `luacheck`
26-
- [linter-php](https://atom.io/packages/linter-php), for PHP using `php -l`
27-
- [linter-phpcs](https://atom.io/packages/linter-phpcs) - Linter plugin for PHP, using phpcs.
28-
- [linter-phpmd](https://atom.io/packages/linter-phpmd) - Linter plugin for PHP, using phpmd.
29-
- [linter-jshint](https://atom.io/packages/linter-jshint) - Linter plugin for JavaScript, using jshint.
30-
- [linter-scss-lint](https://atom.io/packages/linter-scss-lint) - Sass Linter plugin for SCSS, using scss-lint.
31-
- [linter-coffeelint](https://atom.io/packages/linter-coffeelint) Linter plugin for CoffeeScript, using coffeelint.
32-
- [linter-csslint](https://atom.io/packages/linter-csslint) Linter plugin for CSS, using csslint.
33-
- [linter-rubocop](https://atom.io/packages/linter-rubocop) - Linter plugin for Ruby, using rubocop.
34-
- [linter-tslint](https://atom.io/packages/linter-tslint) Linter plugin for TypeScript, using tslint.
35-
36-
## Donation
37-
[![Share the love!](https://chewbacco-stuff.s3.amazonaws.com/donate.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KXUYS4ARNHCN8)

lib/init.coffee

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/linter-lua.coffee

Lines changed: 0 additions & 37 deletions
This file was deleted.

lib/main.coffee

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{CompositeDisposable} = require('atom')
2+
3+
module.exports =
4+
config:
5+
executablePath:
6+
type: 'string'
7+
default: 'luac'
8+
description: 'The executable path to luac or luajit.'
9+
activate: ->
10+
@subscriptions = new CompositeDisposable
11+
@subscriptions.add atom.config.observe 'linter-lua.executablePath', (executablePath) =>
12+
@executablePath = executablePath
13+
deactivate: ->
14+
@subscriptions.dispose()
15+
provideLinter: ->
16+
helpers = require('atom-linter')
17+
regex = \
18+
'^.+?:.+?:' +
19+
'(?<line>\\d+):\\s+' +
20+
'(?<message>.+?' +
21+
'(?:near (?<near>.+)|$))'
22+
provider =
23+
grammarScopes: ['source.lua']
24+
scope: 'file'
25+
lintOnFly: true
26+
lint: (textEditor) =>
27+
parameters = []
28+
if @executablePath.indexOf('luajit') isnt -1
29+
parameters.push('-bl')
30+
else
31+
parameters.push('-p')
32+
parameters.push('-') # to indicate that the input is in stdin
33+
return helpers.exec(@executablePath, parameters, {stdin: textEditor.getText(), stream: 'stderr'}).then (output) ->
34+
return helpers.parse(output, regex, filePath: textEditor.getPath()).map (error) ->
35+
error.type = 'Error'
36+
return error

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
22
"name": "linter-lua",
3-
"linter-package": true,
4-
"main": "./lib/init",
3+
"main": "./lib/main",
54
"version": "0.1.6",
65
"description": "Lint Lua on the fly, using luac -p or luajit -bl",
76
"repository": {
87
"type": "git",
98
"url": "https://github.com/AtomLinter/linter-lua"
109
},
1110
"license": "MIT",
12-
"engines": {
13-
"atom": ">0.50.0"
11+
"dependencies": {
12+
"atom-linter": "^2.0.0"
1413
},
15-
"dependencies": {}
14+
"providedServices": {
15+
"linter": {
16+
"versions": {
17+
"1.0.0": "provideLinter"
18+
}
19+
}
20+
}
1621
}

0 commit comments

Comments
 (0)