NAME
Koha::QA::Tidy::JS - Centralized JavaScript/TypeScript tidiness checking using prettier
SYNOPSIS
use Koha::QA::Tidy::JS;
# With a file
my $checker = Koha::QA::Tidy::JS->new({file => $file, prettierrc => $prettierrc});
# Or with content directly
my $checker = Koha::QA::Tidy::JS->new({content => $file_content, prettierrc => $prettierrc});
my $is_tidy = $checker->check;
my @errors = $checker->errors;
# Return the tidy version
my $success = $checker->fix;
DESCRIPTION
This module provides centralized JavaScript/TypeScript/Vue tidiness checking and formatting using prettier.
METHODS
new
my $checker = Koha::QA::Tidy::JS->new({file => $file, prettierrc => $prettierrc});
Creates a new Tidy::JS instance.
Arguments: - prettierrc: Optional path to .prettierrc.js file (default: .prettierrc.js)
check
my $is_tidy = $checker->check;
Checks if a JavaScript file is tidy by comparing the original content with the output from prettier.
errors
my @errors = $checker->errors;
Returns array of error hashrefs, each with: - error: the error type (tidy_js, no_prettierrc)
fix
my $output = $checker->fix;
Runs prettier on the file and returns the tidied content without modifying the file.
Returns: - String with tidied content on success - undef on failure
AUTHORS
Jonathan Druart <jonathan.druart@bugs.koha-community.org>
COPYRIGHT
Copyright 2026 Koha Development Team
LICENSE
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.