Commit a3c68e7
committed
AG-49411 Add
Squashed commit of the following:
commit 0fe65db
Merge: b0351f3 1228808
Author: scripthunter7 <d.tota@adguard.com>
Date: Mon Dec 22 11:25:54 2025 +0100
Merge branch 'release/v4.0' into fix/AG-49411
commit b0351f3
Author: scripthunter7 <d.tota@adguard.com>
Date: Fri Dec 19 09:48:45 2025 +0100
Add early return when offset range is unavailable in `no-invalid-scriptlets` rule fuzzy matching
- Added null check for `context.getOffsetRangeForNode(node)` before processing fuzzy match suggestions
- Moved range calculation before fuzzy matching logic to avoid unnecessary processing
- Changed `fixer.replaceWithText` to use validated range instead of `[node.start!, node.end!]`
- Prevents potential errors when node offset range cannot be determined
commit 2d21efc
Author: scripthunter7 <d.tota@adguard.com>
Date: Fri Dec 19 09:42:30 2025 +0100
Fix off-by-one error in parameter count validation for scriptlets without parameters in `no-invalid-scriptlets` rule
- Changed condition from `parameterIndex > 1` to `parameterIndex > 0` when checking for extra parameters
- Ensures scriptlets with no defined parameters correctly reject any parameters beyond scriptlet name
- Fixes duplicate error reporting where first parameter was incorrectly validated twice
- Updated documentation example to show correct single error for missing 'property' parameter
commit 52f58d3
Author: scripthunter7 <d.tota@adguard.com>
Date: Fri Dec 19 09:41:18 2025 +0100
Fix off-by-one error in parameter validation loop in `no-invalid-scriptlets` rule
- Moved `i += 1` before `nextParameterData = scriptletData.parameters[i]` assignment
- Ensures nextParameterData correctly references the next parameter after incrementing index
- Prevents accessing wrong parameter data when validating scriptlet parameters
commit 28ec229
Author: scripthunter7 <d.tota@adguard.com>
Date: Thu Dec 18 23:37:09 2025 +0100
Add quote preservation to fuzzy matching suggestions in `no-invalid-scriptlets` rule
- Modified changeScriptlet fix to preserve original quote type from scriptlet name
- Added actualQuote variable to capture quote type using QuoteUtils.getStringQuoteType
- Updated fixer.replaceWithText to apply original quote type to suggested scriptlet name using QuoteUtils.setStringQuoteType
- Ensures suggested scriptlet replacements maintain consistent quote style with original code
commit 3ed095a
Author: scripthunter7 <d.tota@adguard.com>
Date: Thu Dec 18 14:42:16 2025 +0100
Add scriptlet alias support to fuzzy matching in `no-invalid-scriptlets` rule
- Modified getScriptletNames to include both scriptlet names and their aliases when building name cache
- Changed from simple map to flatMap to handle scriptlets with and without aliases
- Ensures fuzzy matching suggestions include scriptlet aliases as valid alternatives
- Maintains Set deduplication to prevent duplicate names in cache
commit ab5ab6e
Author: scripthunter7 <d.tota@adguard.com>
Date: Thu Dec 18 13:58:03 2025 +0100
Add cache cleanup for nameCache in `no-invalid-scriptlets` rule to prevent memory leaks
- Added nameCache.clear() call in FilterList:exit handler alongside existing regexCache.clear()
- Ensures scriptlet name cache is properly cleared after processing each filter list
- Prevents potential memory accumulation when linting multiple files
commit 559e365
Author: scripthunter7 <d.tota@adguard.com>
Date: Thu Dec 18 13:52:03 2025 +0100
Add fuzzy matching suggestions for unknown scriptlets in `no-invalid-scriptlets` rule
- Implemented fuzzy matching using fast-fuzzy library to suggest similar scriptlet names when unknown scriptlet is detected
- Added configurable `fuzzyThreshold` option (default 0.6) to control minimum similarity threshold for suggestions
- Added `changeScriptlet` message ID and suggestion fixes that replace unknown scriptlet with suggested alternatives
- Cached scriptlet names per platform to optimize fuzzy search
commit 9054078
Author: scripthunter7 <d.tota@adguard.com>
Date: Thu Dec 18 13:28:41 2025 +0100
Add `no-invalid-scriptlets` linter rule to validate scriptlet calls against compatibility tables
- Created new rule that checks scriptlet validity based on scriptletsCompatibilityTable from @adguard/agtree
- Validates scriptlet names exist for target platform (AdGuard/uBlock Origin/Adblock Plus)
- Checks required parameters are present and validates parameter values against regex patterns when defined
- Reports errors for unknown scriptlets, missing required parameters, extra parameters, and invalino-invalid-scriptlets linter rule to validate scriptlet calls against compatibility tables1 parent 1228808 commit a3c68e7
File tree
7 files changed
+1123
-0
lines changed- config-presets
- docs/rules
- src/rules
- test/rules
7 files changed
+1123
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
0 commit comments