Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/prado.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ jobs:
run: |
composer functionaltest

prado-js:
name: Prado JS (ESLint + Vitest)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Install npm dependencies
run: npm install

- name: Lint JavaScript (ESLint)
run: npm run lint

- name: Run JavaScript unit tests (Vitest)
run: npm test

prado-macos:
name: Prado (macOS)
runs-on: macos-latest
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ atlassian-ide-plugin.xml
.claude/
tests/FunctionalTests/results.dat
tests/unit/Data/db/
/node_modules
/package-lock.json

# Composer stuff
vendor/*
Expand All @@ -24,3 +26,6 @@ vendor/*

sauce_connect.log
tests/unit/Data/SqlMap/sqlite/tests.db

# Vitest cache artefacts
vitest.config.js.timestamp-*
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude('agents/')
->exclude('build/')
->exclude('docs/')
->exclude('node_modules/')
->exclude('tests/')
->exclude('vendor/')
->in(__DIR__);
Expand Down
25 changes: 18 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,31 @@
"devtools": [
"composer require --dev friendsofphp/php-cs-fixer",
"composer require --dev phpstan/phpstan",
"composer require --dev phpunit/phpunit"
"composer require --dev phpunit/phpunit",
"npm install"
],
"gendoc": "phpdoc --template=./vendor/pradosoft/prado-phpdoc-template",
"csfix": "php-cs-fixer fix",
"stan": "phpstan analyse --memory-limit=512M",
"unittest": "phpunit --testsuite unit",
"functionaltest": [
"Composer\\Config::disableProcessTimeout",
"phpunit --testsuite functional"
],
"stantest": "vendor/bin/phpunit --testsuite phpstan",
"fulltest": [
"php-cs-fixer fix",
"phpstan analyse --memory-limit=512M",
"phpunit --testsuite unit"
]
],
"jslint": "npm run lint",
"jsfix": "npm run lint:fix",
"jstest": "npm run test",
"jswatch": "npm run test:watch",
"jsfull": [
"npm run lint:fix",
"npm run test"
],
"functionaltest": [
"Composer\\Config::disableProcessTimeout",
"phpunit --testsuite functional"
],
"stantest": "vendor/bin/phpunit --testsuite phpstan"
},
"bin" : [
"bin/prado-cli"
Expand Down
79 changes: 79 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import js from '@eslint/js';
import globals from 'globals';

export default [
{
// Lint all PRADO client-side source scripts.
files: ['framework/Web/Javascripts/source/**/*.js'],

languageOptions: {
// Current source targets ES5+ with some ES6 idioms.
ecmaVersion: 2015,

// Scripts are concatenated / loaded as <script> tags — not modules.
// When ESM conversion happens, change this to 'module'.
sourceType: 'script',

globals: {
// Standard browser globals — spread first so our overrides win.
...globals.browser,

// PRADO-specific globals.
jQuery: 'readonly', // loaded before any PRADO script
$: 'readonly', // jQuery shorthand alias used in ratings.js
Prado: 'writable', // defined in prado.js, extended by others
// Logger is declared/initialised by prado.js — must be writable.
Logger: 'writable',
tinyMCE: 'readonly', // optional TinyMCE editor
grecaptcha: 'readonly', // optional reCAPTCHA
// Rico is defined by colorpicker.js (bundled copy of ricoColor.js).
Rico: 'writable',
// CustomEvent is polyfilled by prado.js for older browsers.
CustomEvent: 'writable',
},
},

rules: {
// Pull in eslint's safe defaults.
...js.configs.recommended.rules,

// Legacy codebase intentionally uses var everywhere.
'no-var': 'off',

// eval() appears in setAttribute for inline event handlers.
// Warn so we can track and eliminate instances over time.
'no-eval': 'warn',

// Some variables are declared but used only conditionally.
'no-unused-vars': 'warn',

// Loose equality is used intentionally in several places (value == false, etc.).
'eqeqeq': 'off',

// Legacy code has many undeclared-variable usages (implicit globals, library
// references, etc.). Downgrade to warn so CI surface the issues without
// blocking. Promote back to 'error' once the codebase is cleaned up.
'no-undef': 'warn',

// var-in-switch-case redeclarations are common in the legacy code; warn only.
'no-redeclare': 'warn',

// debugger statements remaining in legacy code; warn so they appear in
// the lint report but do not block CI.
'no-debugger': 'warn',

// Some switch fall-throughs are intentional in the legacy validators.
'no-fallthrough': 'warn',

// Legacy regexes contain unnecessary escape characters.
'no-useless-escape': 'warn',

// Assignment-in-condition (e.g. `if (x = getX())`) is used
// intentionally in several places.
'no-cond-assign': 'warn',

// Empty catch/finally blocks exist in legacy code.
'no-empty': 'warn',
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker,


//which element to trigger to show the calendar
var triggerEvent;
if(this.options.Trigger)
{
this.trigger = jQuery('#'+this.options.Trigger).get(0) ;
var triggerEvent = this.options.TriggerEvent || "click";
triggerEvent = this.options.TriggerEvent || "click";
}
else
{
this.trigger = this.control;
var triggerEvent = this.options.TriggerEvent || "focus";
triggerEvent = this.options.TriggerEvent || "focus";
}

// Popup position
Expand Down
15 changes: 12 additions & 3 deletions framework/Web/Javascripts/source/prado/activecontrols/ajax3.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@

if(this.options.PostInputs != false)
{
var form = this.getForm();

Check warning on line 362 in framework/Web/Javascripts/source/prado/activecontrols/ajax3.js

View workflow job for this annotation

GitHub Actions / Prado JS (ESLint + Vitest)

'form' is assigned a value but never used
return jQuery('input, select, textarea').serialize() + '&' + jQuery.param(data);
} else {
var pagestate = jQuery("#"+Prado.CallbackRequestManager.FIELD_CALLBACK_PAGESTATE);
Expand Down Expand Up @@ -406,8 +406,9 @@
return null;
},

errorHandler: function(request, textStatus, errorThrown)

Check warning on line 409 in framework/Web/Javascripts/source/prado/activecontrols/ajax3.js

View workflow job for this annotation

GitHub Actions / Prado JS (ESLint + Vitest)

'errorThrown' is defined but never used
{
var log;
this.data = request.responseText;

if(Prado.CallbackRequestManager.LOG_ERROR && (log = this.getLogger()))
Expand Down Expand Up @@ -452,12 +453,11 @@
*/
exceptionHandler: function(e)
{
var log;
if(Prado.CallbackRequestManager.LOG_ERROR && (log = this.getLogger()))
{
log.error("Uncaught Callback Client Exception:", e.message);
log.info('Stack:', e.stack);
} else {
debugger;
}

if (this.options.onException)
Expand All @@ -469,6 +469,7 @@
*/
successHandler: function(data, textStatus, request)
{
var log;
this.data = data;

if(Prado.CallbackRequestManager.LOG_SUCCESS && (log = this.getLogger()))
Expand Down Expand Up @@ -524,8 +525,9 @@
/**
* Updates the page state. It will update only if EnablePageStateUpdate is true.
*/
updatePageState : function(request, datain)

Check warning on line 528 in framework/Web/Javascripts/source/prado/activecontrols/ajax3.js

View workflow job for this annotation

GitHub Actions / Prado JS (ESLint + Vitest)

'datain' is defined but never used
{
var log;
var pagestate = jQuery("#"+Prado.CallbackRequestManager.FIELD_CALLBACK_PAGESTATE);
var enabled = request.options.EnablePageStateUpdate;
var aborted = false; //typeof(self.currentRequest) == 'undefined' || self.currentRequest == null;
Expand Down Expand Up @@ -564,8 +566,9 @@
}
},

checkHiddenFields : function(request, datain)

Check warning on line 569 in framework/Web/Javascripts/source/prado/activecontrols/ajax3.js

View workflow job for this annotation

GitHub Actions / Prado JS (ESLint + Vitest)

'datain' is defined but never used

Check warning on line 569 in framework/Web/Javascripts/source/prado/activecontrols/ajax3.js

View workflow job for this annotation

GitHub Actions / Prado JS (ESLint + Vitest)

'request' is defined but never used
{
var log, json;
var data = this.extractContent(Prado.CallbackRequestManager.HIDDENFIELDLIST_HEADER);
if (typeof(data) == "string" && data.length > 0)
{
Expand Down Expand Up @@ -617,6 +620,7 @@
*/
loadScripts : function(request, datain, callback)
{
var log, json;
var data = this.extractContent(Prado.CallbackRequestManager.SCRIPTLIST_HEADER);
if (!this.ScriptsToLoad) this.ScriptsToLoad = new Array();
this.ScriptLoadFinishedCallback = callback;
Expand Down Expand Up @@ -666,8 +670,9 @@
}
},

loadStyleSheetsCode : function(request, datain)

Check warning on line 673 in framework/Web/Javascripts/source/prado/activecontrols/ajax3.js

View workflow job for this annotation

GitHub Actions / Prado JS (ESLint + Vitest)

'datain' is defined but never used

Check warning on line 673 in framework/Web/Javascripts/source/prado/activecontrols/ajax3.js

View workflow job for this annotation

GitHub Actions / Prado JS (ESLint + Vitest)

'request' is defined but never used
{
var log, json;
var data = this.extractContent(Prado.CallbackRequestManager.STYLESHEET_HEADER);
if (typeof(data) == "string" && data.length > 0)
{
Expand All @@ -684,8 +689,9 @@
}
},

loadStyleSheetsAsync : function(request, datain)

Check warning on line 692 in framework/Web/Javascripts/source/prado/activecontrols/ajax3.js

View workflow job for this annotation

GitHub Actions / Prado JS (ESLint + Vitest)

'datain' is defined but never used

Check warning on line 692 in framework/Web/Javascripts/source/prado/activecontrols/ajax3.js

View workflow job for this annotation

GitHub Actions / Prado JS (ESLint + Vitest)

'request' is defined but never used
{
var log, json;
var data = this.extractContent(Prado.CallbackRequestManager.STYLESHEETLIST_HEADER);
if (typeof(data) == "string" && data.length > 0)
{
Expand All @@ -704,6 +710,7 @@

loadStyleSheets : function(request, datain, callback)
{
var log, json;
var data = this.extractContent(Prado.CallbackRequestManager.STYLESHEETLIST_HEADER);
if (!this.StyleSheetsToLoad) this.StyleSheetsToLoad = new Array();
this.StyleSheetLoadFinishedCallback = callback;
Expand Down Expand Up @@ -756,6 +763,7 @@
*/
dispatchActions : function(request, datain)
{
var log, json;
var data = this.extractContent(Prado.CallbackRequestManager.ACTION_HEADER);
if (typeof(data) == "string" && data.length > 0)
{
Expand All @@ -778,6 +786,7 @@
*/
outputDebug : function(request, datain)
{
var log, json;
var data = this.extractContent(Prado.CallbackRequestManager.DEBUG_HEADER);
if (typeof(data) == "string" && data.length > 0 && (log = this.getLogger()))
{
Expand Down Expand Up @@ -950,7 +959,7 @@
},

assetLoadFailed: function(url, element, callback) {
debugger;
var log;
element.assetCallbackFired = true;
if(Prado.CallbackRequestManager.LOG_ERROR && (log = this.getLogger()))
log.error("Failed to load asset: "+url, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control,
this.editField.value = this.getText();
jQuery(this.editField).focus();
if(typeof(this.options.onSuccess)=="function")
this.options.onSuccess(sender,parameter);
this.options.onSuccess(request, parameter);
},

onloadExternalTextFailure : function(request, parameter)
Expand All @@ -241,7 +241,7 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control,
this.isEditing = false;
this.showLabel();
if(typeof(this.options.onFailure)=="function")
this.options.onFailure(sender,parameter);
this.options.onFailure(request, parameter);
},

/**
Expand Down
2 changes: 2 additions & 0 deletions framework/Web/Javascripts/source/prado/prado.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,8 @@ jQuery.extend(String.prototype, {
var m = this.match(exp);
if (m == null)
return null;
m[1] = m[1] || "";
m[2] = m[2] || "";
var intermed = m[2] + m[5] ;
var cleanInput = m[1] + intermed.replace(
new RegExp("(\\" + groupchar + ")", "g"), "")
Expand Down
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "prado",
"version": "4.3.3",
"description": "PRADO PHP Framework — JavaScript assets",
"private": true,
"type": "module",
"scripts": {
"test": "vitest run",
"test:watch": "vitest",
"lint": "eslint 'framework/Web/Javascripts/source/**/*.js'",
"lint:fix": "eslint 'framework/Web/Javascripts/source/**/*.js' --fix"
},
"devDependencies": {
"@eslint/js": "^9.14.0",
"eslint": "^9.14.0",
"globals": "^15.12.0",
"jquery": "^3.7.1",
"jsdom": "^25.0.0",
"vitest": "^4.1.5"
}
}
Loading
Loading