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

Commit 7ecf63b

Browse files
committed
Working Lua Linter
Doesn't look for suspicious globals
1 parent bfcdacf commit 7ecf63b

File tree

4 files changed

+72
-4
lines changed

4 files changed

+72
-4
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1-
# linter-lua package
1+
linter-lua
2+
===========
23

3-
This package no yet ready.
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. **It will lint on edit and/or save**, so you'll see instantly if your code has errors.
7+
8+
Due to the way that luac works it will only notify you of the first error found in the file.
9+
10+
## Linter Installation
11+
Before using this package, you must ensure that `luac` is installed on your system.
12+
13+
## Installation
14+
15+
* `$ apm install linter` (if you don't have [AtomLinter/Linter](https://github.com/AtomLinter/Linter) installed).
16+
* `$ apm install linter-lua`
17+
18+
19+
## Other available linters
20+
- [linter-php](https://atom.io/packages/linter-php), for PHP using `php -l`
21+
- [linter-phpcs](https://atom.io/packages/linter-phpcs) - Linter plugin for PHP, using phpcs.
22+
- [linter-phpmd](https://atom.io/packages/linter-phpmd) - Linter plugin for PHP, using phpmd.
23+
- [linter-jshint](https://atom.io/packages/linter-jshint) - Linter plugin for JavaScript, using jshint.
24+
- [linter-scss-lint](https://atom.io/packages/linter-scss-lint) - Sass Linter plugin for SCSS, using scss-lint.
25+
- [linter-coffeelint](https://atom.io/packages/linter-coffeelint) Linter plugin for CoffeeScript, using coffeelint.
26+
- [linter-csslint](https://atom.io/packages/linter-csslint) Linter plugin for CSS, using csslint.
27+
- [linter-rubocop](https://atom.io/packages/linter-rubocop) - Linter plugin for Ruby, using rubocop.
28+
- [linter-tslint](https://atom.io/packages/linter-tslint) Linter plugin for JavaScript, using tslint.

lib/init.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports =
2+
configDefaults:
3+
luacExecutablePath: null
4+
5+
activate: ->
6+
console.log 'activate linter-lua'

lib/linter-lua.coffee

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
linterPath = atom.packages.getLoadedPackage("linter").path
2+
Linter = require "#{linterPath}/lib/linter"
3+
4+
class LinterLua extends Linter
5+
# The syntax that the linter handles. May be a string or
6+
# list/tuple of strings. Names should be all lowercase.
7+
@syntax: 'source.lua'
8+
9+
# A string, list, tuple or callable that returns a string, list or tuple,
10+
# containing the command line (with arguments) used to lint.
11+
cmd: 'luac -p'
12+
13+
linterName: 'luac'
14+
15+
# A regex pattern used to extract information from the executable's output.
16+
regex:
17+
'.+?:.+?:' +
18+
'(?<line>\\d+):\\s+' +
19+
'(?<message>.*)'
20+
21+
errorStream: 'stderr'
22+
23+
regexFlags: 's'
24+
25+
constructor: (editor) ->
26+
super(editor)
27+
28+
atom.config.observe 'linter-lua.luacExecutablePath', =>
29+
@executablePath = atom.config.get 'linter-lua.luacExecutablePath'
30+
31+
destroy: ->
32+
atom.config.unobserve 'linter-lua.luacExecutablePath'
33+
34+
module.exports = LinterLua

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
"activationEvents": [],
55
"main": "./lib/init",
66
"version": "0.0.1",
7-
"description": "Lint Lua on the fly, using luac -p (not yet ready)",
8-
"repository": "https://github.com/AtomLinter/linter-lua",
7+
"description": "Lint Lua on the fly, using luac -p",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/AtomLinter/linter-lua"
11+
},
912
"license": "MIT",
1013
"engines": {
1114
"atom": ">0.50.0"

0 commit comments

Comments
 (0)