From eb498f636ee8ac155f7698aa28f86b056983df2b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 21 Mar 2024 08:45:11 +0100 Subject: [PATCH] Bug 36374: flag JS files to keep tidy Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- .../prog/js/modals/add_catalog_concern.js | 1 + .../intranet-tmpl/prog/js/modals/display_ticket.js | 1 + .../intranet-tmpl/prog/js/modals/place_booking.js | 1 + xt/js_tidy.t | 11 ++++++----- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/add_catalog_concern.js b/koha-tmpl/intranet-tmpl/prog/js/modals/add_catalog_concern.js index d7db5f6a3b..61cb26d8c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/add_catalog_concern.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/add_catalog_concern.js @@ -1,3 +1,4 @@ +/* keep tidy */ $(document).ready(function() { // Pre-populate empty message with template diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js index b35a3a7557..0812d7fccb 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js @@ -1,3 +1,4 @@ +/* keep tidy */ $(document).ready(function() { $('#ticketDetailsModal').on('show.bs.modal', function(event) { let modal = $(this); diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js index 363dedf592..20f493873b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js @@ -1,3 +1,4 @@ +/* keep tidy */ let dataFetched = false; let bookable_items, bookings, diff --git a/xt/js_tidy.t b/xt/js_tidy.t index d9a4555279..4fc2bff95f 100755 --- a/xt/js_tidy.t +++ b/xt/js_tidy.t @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#/usr/bin/perl # This file is part of Koha. # @@ -22,17 +22,18 @@ 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 $cmd = q{git grep -l '/\* keep tidy \*/' -- '*.js'}; +my @js_files = qx{$cmd}; 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 $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; +is( scalar(@not_tidy), 0, sprintf( 'No .js file should be messy %s/%s', scalar(@not_tidy), scalar(@js_files) ) ) + or diag Dumper \@not_tidy; -- 2.20.1