This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use latest atom linter API * Use helpers from atom-linter * Refactor to use latest linter plugin conventions (main.coffee, etc.) Closes #52 #53 #51 #50 #49
- Loading branch information
SpainTrain
committed
Aug 13, 2015
1 parent
5bde93f
commit c3d7c95
Showing
4 changed files
with
72 additions
and
74 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{CompositeDisposable} = require 'atom' | ||
helpers = require 'atom-linter' | ||
path = require 'path' | ||
|
||
module.exports = | ||
config: | ||
executable: | ||
type: 'string' | ||
default: 'pylint' | ||
rcFile: | ||
type: 'string' | ||
default: '' | ||
messageFormat: | ||
type: 'string' | ||
default: '%i %m' | ||
description: | ||
'Format for Pylint messages where %m is the message, %i is the | ||
numeric mesasge ID (e.g. W0613) and %s is the human-readable | ||
message ID (e.g. unused-argument).' | ||
|
||
activate: -> | ||
@subscriptions = new CompositeDisposable | ||
@subscriptions.add atom.config.observe 'linter-pylint.executable', | ||
(newValue) => | ||
@executable = newValue | ||
@subscriptions.add atom.config.observe 'linter-pylint.rcFile', | ||
(newValue) => | ||
@rcFile = newValue | ||
@subscriptions.add atom.config.observe 'linter-pylint.messageFormat', | ||
(newValue) => | ||
@messageFormat = newValue | ||
|
||
@regex = '^(?<line>\\d+),(?<col>\\d+),\ | ||
(?<type>\\w+),\ | ||
(?<msg_id>\\w\\d+):(?<message>.*)$' | ||
|
||
deactivate: -> | ||
@subscriptions.dispose() | ||
|
||
provideLinter: -> | ||
provider = | ||
grammarScopes: ['source.python'] | ||
scope: 'file' | ||
lintOnFly: true | ||
lint: (activeEditor) => | ||
file = activeEditor.getPath() | ||
cwd = path.dirname(file) | ||
format = @messageFormat | ||
for pattern, value of {'%m': 'msg', '%i': 'msg_id', '%s': 'symbol'} | ||
format = format.replace(new RegExp(pattern, 'g'), "{#{value}}") | ||
args = [ | ||
"--msg-template='{line},{column},{category},{msg_id}:#{format}'" | ||
'--reports=n' | ||
'--output-format=text' | ||
] | ||
if @rcFile | ||
args.push "--rcfile=#{@rcFile}" | ||
args.push file | ||
return helpers.exec(@executable, args, {cwd: cwd, throwOnStdErr: no}).then (output) => | ||
helpers.parse(output, @regex, {filePath: file}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
{ | ||
"name": "linter-pylint", | ||
"linter-package": true, | ||
"main": "./lib/init", | ||
"main": "./lib/main", | ||
"version": "0.2.2", | ||
"description": "Lint python on the fly, using pylint", | ||
"repository": "https://github.com/AtomLinter/linter-pylint", | ||
"license": "MIT", | ||
"engines": { | ||
"atom": ">0.50.0" | ||
"atom": ">=1" | ||
}, | ||
"dependencies": {} | ||
"providedServices": { | ||
"linter": { | ||
"versions": { | ||
"1.0.0": "provideLinter" | ||
} | ||
} | ||
}, | ||
"dependencies": { | ||
"atom-linter": "^3.1.1" | ||
} | ||
} |