Bug 36374: Ensure js/modals/*.js files are tidy

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2024-03-20 16:18:14 +00:00 committed by Katrin Fischer
parent 362167adea
commit f196f3cb70
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 38 additions and 0 deletions

38
xt/js_tidy.t Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/perl
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use File::Slurp qw( read_file );
use File::Find;
use FindBin();
use Data::Dumper qw( Dumper );
use Test::More tests => 1;
my @js_files;
push @js_files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js'`;
my @not_tidy;
foreach my $filepath (@js_files) {
chomp $filepath;
my $tidy = qx{yarn --silent run prettier --trailing-comma es5 --arrow-parens avoid $filepath};
my $content = read_file $filepath;
if ( $content ne $tidy ) {
push @not_tidy, $filepath;
}
}
is(scalar(@not_tidy), 0, 'No .js file should be messy') or diag Dumper \@not_tidy;