Commit graph

16 commits

Author SHA1 Message Date
Ed Sanders e405992015 Move var declarations inline
Change-Id: Ie8046d24268be2d22ab115a466422e7e3dd9a8e2
2023-11-10 18:27:55 +00:00
Umherirrender e9a80335d3 build: Update eslint-config-wikimedia to 0.21.0
This includes the update of lockFile version

Bug: T225730
Change-Id: Iebef765120d24c2969251fc4985a383e21cb136b
2021-12-21 22:53:00 +01:00
Daimona Eaytoy 1b41a61cf2 ace: Add support for multiline strings
In the AF language,
```
foo := "abc
   def"
```

declares a valid string with a linebreak inside. This wasn't previously
highlighted by ace, since normal rules are scanned line-by-line. The
code added here is essentially copied from the PHP highlighter [1],
whose rules should be almost the same as AF.

This new syntax also highlights escape sequences inside strings, e.g. in
"foo\\bar" see how the backslashes have a different color.

[1] - https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/php_highlight_rules.js#L1058

Change-Id: Idb51001af00ff2ef118741cd686dc1adf19aebee
2021-10-03 16:24:51 +00:00
Daimona Eaytoy b9efb9ec7d Don't pass protocol-relative URLs to the Ace worker
Bug: T271487
Change-Id: Ib344e7c021f9224f08c0c844d4e96e5bede356c8
2021-01-11 13:33:11 +01:00
Daimona Eaytoy 2a3b636a45 Run real-time validation of rules with an Ace worker
The worker itself is essentially a wrapper around the
abusefilterchecksyntax API.

NOTE: As written in code comments, basically the whole
worker-abusefilter.js script consists of boilerplate code. You can
verify this by diffing this file and 6cb8a9cae1/modules/ace/worker-json.js
This means that there are only ~60 lines of code to review in that file.

Bug: T187686
Change-Id: I8950fcd5917ba226dda80b47b2bb713e685fad36
2020-12-18 15:05:28 +00:00
MarcoAurelio f07bf610c0 build: Update npm dependencies
- eslint-config-wikimedia  0.12.0  →  0.13.1
 - grunt-banana-checker      0.7.0  →   0.7.1
 - grunt-eslint             21.0.0  →  22.0.0
 - grunt-stylelint          0.10.1  →  0.11.0
 - stylelint                 9.9.0  →  10.1.0

Also npm audit (fix) them afterwards.

Addresses CVE-2019-10744.

Change-Id: I3153e269decab7f2637e2a41934e0ee07a5df760
2019-07-31 17:29:00 +00:00
Daimona Eaytoy c73d5b5bde Restore highlighting of all keywords, functions, etc.
Short explanation on phab. Ace stops at the first regex match, so we
must use a function to specify the token type.

Bug: T219593
Change-Id: If7e6e98de81ce7e1be334732518425c8115e4aea
2019-03-29 10:44:02 +01:00
Daimona Eaytoy bae9c5bb8f Use lowercase for built-in variables
The uppercase is just a leftover from a long time ago. Currently,
variables are case-insensitive, and we already perform a strtolower when
saving them. Since most parts of the code already use lowercase, the
uppercase leftovers only make it harder to grep the code to find
variables. As a bonus, make Ace recognize variables in a
case-insensitive fashion.

Change-Id: I72933fcc9952fc1aabf6464b2fc0b04ec39c024b
2019-03-17 14:23:11 +01:00
Daimona Eaytoy e60dacbbea Fix code comments
Fixed some comments adding explanations, fixing syntax, and parameter types
for docblocks. Also fixed some whitespace mess, and added a missing use
statement.

Change-Id: I3547c90bdaa2cab5443e8bf0c63b217fe6ba663f
2018-10-03 16:45:03 +02:00
Daimona Eaytoy b46a4336de Remove hex numbers from Ace highlight
Since our parser doesn't recognize them. Follow up of
If95e34fc7260413c4fb39c18a1ef44f5a93e1a68.

Change-Id: I4511a69f3be60b4c90b499c5179cf0f5bf1d6b07
2018-08-23 12:23:16 +02:00
Daimona Eaytoy e8a4517d6b Improve Ace syntax highlight
Several improvements, this is the list:
*Added highlighting for disabled and deprecated variables
*Simplified a bit Ace's keyword mapper
*Added highlighting for ternary operator
*Added logic to retrieve operators from AF tokenizer
*Removed $ symbol since it's not usable in declaring stuff
*Customized highlighting via CSS

Depends-On: I5c370b54e6516889624088e27928ad3a1f48a821
Change-Id: If95e34fc7260413c4fb39c18a1ef44f5a93e1a68
2018-08-22 15:23:35 +00:00
Daimona Eaytoy 83ccb376f0 Make Ace config pass eslint
Just a tiny change to be safer.

Change-Id: Id0e188ab6e5d0e14ef5f0fdcce74be5ec7f24470
2018-08-22 11:21:13 +02:00
Daimona Eaytoy 1f5fc1b26e Ace: retrieve keywords directly from tokenizer
We already do it for variables and functions, so that any new feature
won't need the ace files to be edited. I originally didn't implement it
for keywords too, but it's actually much better this way.

Change-Id: I1ee81feace2ea90d5dbb2e443f01bc0f6cf74eb7
2018-04-07 17:21:45 +02:00
Daimona Eaytoy 3350183fe3 Revert "Revert "Switch editor to Ace and provide syntax highlight""
Make Ace use a fixed size in em.

This reverts commit 272775ff81.

Change-Id: I9b439b20df91eb367bcef4b6f33ff087aded0b62
2018-03-30 11:10:16 -04:00
Huji 272775ff81 Revert "Switch editor to Ace and provide syntax highlight"
This reverts commit 89e6778793.

Change-Id: I41aee10fdd5633d56692334696fb750f41b15433
2018-03-30 02:07:00 +00:00
Daimona Eaytoy 89e6778793 Switch editor to Ace and provide syntax highlight
Replace the conditions textarea with Ace editor for editing and testing
filter. This uses a soft dependency on CodeEditor; if the latter isn't
installed, the classic textarea is used. The user is still able to
switch between the editors on the go; the new buttons may look a bit
ugly now, but after switching to OOUI they should get much better.
Finally, added a custom syntax highlight for AbuseFilter rules.

Bug: T39192
Change-Id: If3d6a994142e34686bb7fc9f09093f751b599485
2018-03-23 12:39:22 +01:00