Commit graph

18 commits

Author SHA1 Message Date
Ed Sanders 9e9ad65f2b build: Update eslint-config-wikimedia to 0.28.2
Change-Id: Ifb0eb261325544fceeb16d13be31bbf303e64124
2024-06-13 17:28:06 +01:00
Ed Sanders e9f412f4c0 eslint: Remove no-op config
Change-Id: Idcc2f4e4edeb57d1fb11deb4e798529f14466c9b
2024-06-06 16:30:49 +01:00
Ed Sanders ea5639b20b ESLint: Enforce prefer-const
Change-Id: I5985d1b532988bb3b71ff1aa24eae57ac2e1b9c5
2024-05-24 16:50:13 +01:00
Ed Sanders dda9227947 ESLint: Manually fix remaining no-var violations
Change-Id: I4474bd0205e7a1ed8e60147e52675e3e0b93ccd9
2024-05-24 16:50:11 +01:00
Ed Sanders ca5157156a ESLint: Autofix no-var rule
Leave rule off for now as manual fixes are required.

Also temporarily disable prefer-const rule as that
will also require some manual fixes.

Change-Id: I8c3478f26f51287acb943bd38c9c1020c06b9f39
2024-05-24 16:49:36 +01:00
Ed Sanders 1e0aa2171f Replace $.extend with Object.assign
Change-Id: Id559ab68451a1d767e92ed17b1ef0832a5f243af
2024-05-02 16:49:43 +01:00
Bartosz Dziewoński d4c5aebd8f Prefer short arrow functions
When an arrow function body contains just a single `return` statement,
the braces can be omitted.

(Changes are mostly made by `grunt eslint --fix`, with only some line
breaks added by hand.)

Change-Id: I37f259f87085c8d20ed09cfa58a8456dd36cdc38
2024-04-20 00:08:51 +02:00
Ed Sanders a74c00ba8c Prefer arrow functions for callbacks
This allows us to remove our `this` bindings.

Change-Id: Ie8c8c38d36af8a033b5181870c39f8981a57b939
2024-04-19 12:34:23 +01:00
Bartosz Dziewoński f7d98d7690 Redo wrapper for localStorage integration
I think the issues in T329299 are caused by partially autosaved
comments. We store data in multiple localStorage keys, and if some of
them are stored but others are not (due to exceeding storage quota),
our code can't handle the inconsistent state.

We already have a wrapper around localStorage that tries to cover up
these issues. Change it so that all values specific to an instance of
a reply tool are stored under one localStorage key. This ensures that
all updates consistently succeed or fail, with no partially stored
state.

One of the reasons we haven't done this is because this requires the
whole data to be serialized to JSON every time, but our experience
with VE change 4355d697aa shows that this is fast enough.

Extra changes:
* Remove storagePrefix, now redundant
* Remove use of createConflictableStorage, now redundant
* Prefix the key with 'mw' as advised by mw.storage documentation
* Use ES6 syntax for the new code (just for fun)
* Use consistent expiry (T339042)

Bug: T329299
Change-Id: I347115f7187fd7d6afd9c6f368441e262154233b
2023-06-19 16:45:08 +02:00
Ed Sanders b3b543040b Implement percentDecode for finding link fragment targets
Relying on :target getting set means we can't use
history.pushState to change the URL without scrolling.

Should conform to https://url.spec.whatwg.org/#percent-decode

Change-Id: I4ccc3fd745884849a781a9f7fc8b00b8b689e20a
2022-08-09 20:06:28 +00:00
Ed Sanders af5b9a9b46 ReplyWidgetVisual: Pass in memory-wrapped store to VE
We switched to our memory-wrapped store everywhere outside the
VE surface, but not in the VE surface itself.

Change the way we construct MemoryStorage objects so that they can
be constructed from a specific mw.SafeStorage instance.

Ensure MemoryStorage's cache is populated with initial storage object
data, and that the cache is copied over when we create derivative
objectes.

Bug: T310438
Change-Id: I652428f114dc5169195887cb8ca719ae196bb76f
2022-06-17 14:05:54 +01:00
Bartosz Dziewoński cf255f28bf Replace mediawiki.Uri with native URL (or polyfill)
Depends-On: I7c4f9b6449a4317d68f4923fb4f198181bbfe800
Depends-On: I04464c17369ffb0dd4e7c33d2bd4db7b2d050bf4
Bug: T305010
Change-Id: I02da91010304af35f0b1f2bd4d65a84d51f29930
2022-04-08 00:35:37 +02:00
Bartosz Dziewoński 8e44b43df0 Split off ThreadItemSet from CommentParser
Goal:
-----
Finishing the work from Iadb7757debe000025e52770ca51ebcf24ca8ee66
by changing CommentParser::parse() to return a data object, instead of
the whole parser.

Changes:
--------
ThreadItemSet.php:
ThreadItemSet.js:
* New data class to access the results of parsing a discussion. Most
  methods and properties are moved from CommentParser with no changes.

CommentParser.php:
Parser.js:
* parse() returns a new ThreadItemSet.
* Remove methods moved to ThreadItemSet.
* Placeholder headings are generated slightly differently, as we process
  things in a different order.
* Grouping threads and computing IDs/names is no longer lazy. We always
  needed IDs/names anyway.
* computeId() explicitly uses a ThreadItemSet to check the existing IDs
  when de-duplicating.

controller.js:
* Move the code for turning some nodes annotated by CommentFormatter
  into a ThreadItemSet (previously a Parser) from controller#init to
  ThreadItemSet.static.newFromAnnotatedNodes, and rewrite it to handle
  assigning parents/replies and recalculating legacy IDs more nicely.
* mw.dt.pageThreads is now a ThreadItemSet.

Change-Id: I49bfe019aa460651447fd383f73eafa9d7180a92
2022-02-21 16:22:32 +00:00
Ed Sanders f4c12e120a Define documentable types in eslintrc instead of inline
These types can be passed a parameters to any file without
creating a dependency, so it makes more sense to allow
the globally.

Change-Id: I5504465fd997b46547642e7046993b370b85586e
2021-10-17 14:38:39 +01:00
Ed Sanders 605e7322b8 eslint: Lint root folder with server rules
Change-Id: I372eef293983bff0c79ad8aa0da1c7e5d07b1e44
2021-10-07 17:37:52 +01:00
Ed Sanders d3c46a2967 eslint: Disable max-len
Change-Id: I7e49dc170dba62b88f1879ae670f806f6b54d4e9
2020-04-21 15:50:19 +01:00
Ed Sanders a9340f0c84 build: Update linters
Change-Id: Iee2e91b24218c6120f4a20d6ea38ea03c6292ef0
2019-10-28 12:29:56 +00:00
Bartosz Dziewoński b105bf7ded Detect and parse timestamps, signatures, comments and threads
Bug: T232780
Bug: T234404
Change-Id: Ie9c80121089742cfc7cd7c04d694c2e0fe8d6a98
2019-10-18 13:59:07 +02:00