[libcode-tidyall-perl] 224/374: add

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 22:26:24 UTC 2013


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libcode-tidyall-perl.

commit 397c5c5e82edd09f8cc3a1c47a03f726c1fef2fa
Author: Jonathan Swartz <swartz at pobox.com>
Date:   Wed Sep 12 17:21:25 2012 -0400

    add
---
 lib/Code/TidyAll/Plugin/JSLint.pm   |   57 +++++++++++++++++++++++++++++++++++
 lib/Code/TidyAll/t/Plugin/JSLint.pm |   28 +++++++++++++++++
 xt/author/Plugin-JSLint.t           |    3 ++
 3 files changed, 88 insertions(+)

diff --git a/lib/Code/TidyAll/Plugin/JSLint.pm b/lib/Code/TidyAll/Plugin/JSLint.pm
new file mode 100644
index 0000000..82afb0e
--- /dev/null
+++ b/lib/Code/TidyAll/Plugin/JSLint.pm
@@ -0,0 +1,57 @@
+package Code::TidyAll::Plugin::JSLint;
+use Capture::Tiny qw(capture_merged);
+use Moo;
+extends 'Code::TidyAll::Plugin';
+
+sub _build_cmd { 'jslint' }
+
+sub validate_file {
+    my ( $self, $file ) = @_;
+
+    my $cmd = sprintf( "%s %s %s", $self->cmd, $self->argv, $file );
+    my $output = capture_merged { system($cmd) };
+    die "$output\n" if $output !~ /is OK\./;
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Code::TidyAll::Plugin::JSLint - use jslint with tidyall
+
+=head1 SYNOPSIS
+
+   In tidyall.ini:
+
+   [JSLint]
+   select = static/**/*.js
+   argv = --white --vars --regex
+
+=head1 DESCRIPTION
+
+Runs L<jslint|http://www.jslint.com/>, a Javascript validator, and dies if any
+problems were found.
+
+=head1 INSTALLATION
+
+Install L<npm|https://npmjs.org/>, then run
+
+    npm install jslint
+
+=head1 CONFIGURATION
+
+=over
+
+=item argv
+
+Arguments to pass to jslint
+
+=item cmd
+
+Full path to jslint
+
+=back
diff --git a/lib/Code/TidyAll/t/Plugin/JSLint.pm b/lib/Code/TidyAll/t/Plugin/JSLint.pm
new file mode 100644
index 0000000..e334299
--- /dev/null
+++ b/lib/Code/TidyAll/t/Plugin/JSLint.pm
@@ -0,0 +1,28 @@
+package Code::TidyAll::t::Plugin::JSLint;
+use Code::TidyAll::Util qw(write_file);
+use Test::Class::Most parent => 'Code::TidyAll::t::Plugin';
+
+sub test_filename { 'foo.js' }
+
+sub test_main : Tests {
+    my $self = shift;
+
+    $self->tidyall(
+        source    => 'var my_object = {};',
+        expect_ok => 1,
+        desc      => 'ok',
+    );
+    $self->tidyall(
+        source       => 'while (true) {\nvar i = 5;\n}',
+        expect_error => qr/Expected 'var' at column 5/,
+        desc         => 'error - bad indentation'
+    );
+    $self->tidyall(
+        source    => 'while (true) {\nvar i = 5;\n}',
+        conf      => { argv => '--white' },
+        expect_ok => 1,
+        desc      => 'ok - bad indentation, --white'
+    );
+}
+
+1;
diff --git a/xt/author/Plugin-JSLint.t b/xt/author/Plugin-JSLint.t
new file mode 100644
index 0000000..b3150fa
--- /dev/null
+++ b/xt/author/Plugin-JSLint.t
@@ -0,0 +1,3 @@
+#!/usr/bin/perl
+use Code::TidyAll::t::Plugin::JSLint;
+Code::TidyAll::t::Plugin::JSLint->runtests;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcode-tidyall-perl.git



More information about the Pkg-perl-cvs-commits mailing list