Fix code quality violations and add VS Code extension features

Fix VS Code extension storage paths for new directory structure
Fix jqhtml compiled files missing from bundle
Fix bundle babel transformation and add rsxrealpath() function

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-10-22 00:43:05 +00:00
parent 53d359bc91
commit 37a6183eb4
80 changed files with 1066 additions and 255 deletions

View File

@@ -51,13 +51,20 @@ class JQueryVariableNaming_CodeQualityRule extends CodeQualityRule_Abstract
];
/**
* jQuery methods that return scalar values (not jQuery objects)
* jQuery methods that return scalar values ONLY when called as getters (no arguments)
* When called with arguments, these return jQuery object for chaining
*/
private const SCALAR_METHODS = [
private const GETTER_METHODS = [
'data', 'attr', 'val', 'text', 'html', 'prop', 'css',
'offset', 'position', 'scrollTop', 'scrollLeft',
'width', 'height', 'innerWidth', 'innerHeight',
'outerWidth', 'outerHeight',
];
/**
* jQuery methods that ALWAYS return scalar values
*/
private const SCALAR_METHODS = [
'index', 'size', 'length', 'get', 'toArray',
'serialize', 'serializeArray',
'is', 'hasClass', 'is_visible' // Custom RSpade methods
@@ -155,7 +162,23 @@ class JQueryVariableNaming_CodeQualityRule extends CodeQualityRule_Abstract
// Direct jQuery selector: $(...)
if (preg_match('/^\$\s*\(/', $expr)) {
// Check if followed by method chain
// Check if it's creating an element: $('<element>')
if (preg_match('/^\$\s*\(\s*[\'"]</', $expr)) {
// Creating jQuery element - always returns jQuery object
// Even with method chains like .text() or .attr(), the chaining continues
// We only care about method chains that END with scalar methods
if (preg_match('/^\$\s*\([^)]*\)(.*)/', $expr, $matches)) {
$chain = trim($matches[1]);
if ($chain === '') {
return 'jquery'; // Just $('<element>') with no methods
}
// Only check if chain ENDS with a scalar method
return $this->analyze_method_chain($chain);
}
return 'jquery';
}
// Regular selector or other jQuery call
if (preg_match('/^\$\s*\([^)]*\)(.*)/', $expr, $matches)) {
$chain = trim($matches[1]);
if ($chain === '') {
@@ -201,25 +224,57 @@ class JQueryVariableNaming_CodeQualityRule extends CodeQualityRule_Abstract
// Find the last method call in the chain
// Match patterns like .method() or .method(args)
// Also capture what's inside the parentheses
$methods = [];
preg_match_all('/\.([a-zA-Z_][a-zA-Z0-9_]*)\s*\([^)]*\)/', $chain, $methods);
if (empty($methods[1])) {
preg_match_all('/\.([a-zA-Z_][a-zA-Z0-9_]*)\s*\(([^)]*)\)/', $chain, $methods, PREG_SET_ORDER);
if (empty($methods)) {
// No method calls found
return 'unknown';
}
// Check the last method to determine return type
$last_method = end($methods[1]);
$last_method_data = end($methods);
$last_method = $last_method_data[1];
$last_args = trim($last_method_data[2] ?? '');
if (in_array($last_method, self::JQUERY_OBJECT_METHODS, true)) {
return 'jquery';
}
if (in_array($last_method, self::SCALAR_METHODS, true)) {
return 'scalar';
}
// Check getter methods - return scalar for getters, jQuery for setters
if (in_array($last_method, self::GETTER_METHODS, true)) {
// Count arguments by splitting on commas (simple heuristic)
// Note: This won't handle nested function calls perfectly, but works for common cases
$arg_count = $last_args === '' ? 0 : (substr_count($last_args, ',') + 1);
// Special handling for methods that take a key parameter
// .data('key') - 1 arg = getter (returns value)
// .data('key', value) - 2 args = setter (returns jQuery)
// .attr('name') - 1 arg = getter (returns attribute value)
// .attr('name', value) - 2 args = setter (returns jQuery)
if (in_array($last_method, ['data', 'attr', 'prop', 'css'], true)) {
if ($arg_count <= 1) {
return 'scalar'; // Getter with key - returns scalar value
} else {
return 'jquery'; // Setter with key and value - returns jQuery for chaining
}
}
// For other getter methods (text, html, val, etc.)
// .text() - no args = getter (returns text)
// .text('value') - 1 arg = setter (returns jQuery)
if ($last_args === '') {
return 'scalar'; // Getter mode - returns scalar
} else {
return 'jquery'; // Setter mode - returns jQuery object for chaining
}
}
// Unknown method - could be custom plugin
return 'unknown';
}