Created
December 22, 2017 08:01
-
-
Save fand/594993a9ec0f59e1979e73d37a66b8ef to your computer and use it in GitHub Desktop.
anylint sample
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
{ | |
".pl": { | |
"~/bin/anylint/blank.pl": 2, | |
}, | |
} |
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
# anylint使い方 | |
1. Atomで [linter-anylint](https://github.com/fand/linter-anylint) をインストール | |
2. .anylintrc を `~/.anylintrc` に配置 | |
3. blank.pl を `~/bin/anylint/blank.pl` に配置 | |
4. `chmod +x ~/bin/anylint/blank.pl` | |
これで `.pl` ファイルで連続する改行がハイライトされます |
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
#!/usr/bin/env perl | |
# This rule disallows more than 2 blank lines | |
use strict; | |
use warnings; | |
use JSON; | |
use v5.010; | |
my $errors = []; | |
my $linenum = 1; | |
my $lastline = 'DUMMY'; | |
while (<>) { | |
my $line = $_; | |
if ($line =~ /^\s*$/ && $lastline =~ /^\s*$/) { | |
push @$errors, { | |
line => $linenum, | |
column => 1, | |
message => 'Too many blank lines!', | |
ruleId => 'no-multiple-blank-lines', | |
} | |
} | |
$linenum++; | |
$lastline = $line; | |
} | |
say encode_json($errors); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment