Commit graph

6626 commits

Author SHA1 Message Date
Richard Hansen
77f480d954 hooks: Asyncify aCallFirst 2021-02-02 09:09:02 +00:00
Richard Hansen
22d02dbcbf hooks: Factor out value normalization 2021-02-02 09:09:02 +00:00
Richard Hansen
f316a3bacd hooks: Never pass a falsy error to a callback 2021-02-02 09:09:02 +00:00
Richard Hansen
708206449a hooks: Factor out callback attachment
The separate function will be reused in a future commit.
2021-02-02 09:09:02 +00:00
Richard Hansen
13e806ad7a hooks: Inline mapFirst() into aCallFirst() for readability
There's only one caller of the function, and the function is simple,
so there's no need for a separate function.
2021-02-02 09:09:02 +00:00
Richard Hansen
4ab7a99512 hooks: Inline syncMapFirst() into callFirst() for readability
There's only one caller of the function, and the function is simple,
so there's no need for a separate function.
2021-02-02 09:09:02 +00:00
Richard Hansen
53ccfa8703 hooks: Asyncify mapFirst 2021-02-02 09:09:02 +00:00
Richard Hansen
0b83ff8ec2 hooks: Simplify syncMapFirst iteration 2021-02-02 09:09:02 +00:00
Richard Hansen
c89db33ff0 hooks: Refine caveat comments about function parameter count 2021-02-02 09:09:02 +00:00
Richard Hansen
f02f288e80 hooks: Rename args to context for consistency 2021-02-02 09:09:02 +00:00
Richard Hansen
7dba847f21 hooks: Don't export syncMapFirst or mapFirst
Nobody uses these functions outside of this file.
2021-02-02 09:09:02 +00:00
Richard Hansen
6b42dabf6c hooks: Delete unused bubbleExceptions setting 2021-02-02 09:09:02 +00:00
Richard Hansen
ba02e70020 tests: Make the fake webaccess hook registrations look more real
The additional properties will be needed once `aCallAll()` is upgraded
to use `callHookFnAsync()`.
2021-02-02 09:09:02 +00:00
Richard Hansen
47f0a7dacf lint: Fix more ESLint errors 2021-02-02 09:09:02 +00:00
Richard Hansen
1bc52f4913 hooks: Remove unnecessary callAllStr() function 2021-02-02 09:09:02 +00:00
John McLear
3e910b9905 stale: remove convert.js as no one runs old Etherpad 2021-02-01 22:45:51 +00:00
John McLear
915849b319
Low hanging lint frontend tests (#4695)
* lint: low hanging specs/alphabet.js

* lint: low hanging specs/authorship_of_editions.js

* lint: low hanging specs/bold.js

* lint: low hanging specs/caret.js

* lint: low hanging specs/change_user_color.js

* lint: low hanging specs/change_user_name.js

* lint: low hanging specs/chat.js

* lint: low hanging specs/chat_load_messages.js

* lint: low hanging specs/clear_authorship_colors.js

* lint: low hanging specs/delete.js

* lint: low hanging specs/drag_and_drop.js

* lint: low hanging specs/embed_value.js

* lint: low hanging specs/enter.js

* lint: low hanging specs/font_type.js

* lint: low hanging specs/helper.js

* lint: low hanging specs/importexport.js

* lint: low hanging specs/importindents.js

* lint: low hanging specs/indentation.js

* lint: low hanging specs/italic.js

* lint: low hanging specs/language.js

* lint: low hanging specs/multiple_authors_clear_authorship_colors.js

* lint: low hanging specs/ordered_list.js

* lint: low hanging specs/pad_modal.js

* lint: low hanging specs/redo.js

* lint: low hanging specs/responsiveness.js

* lint: low hanging specs/select_formatting_buttons.js

* lint: low hanging specs/strikethrough.js

* lint: low hanging specs/timeslider.js

* lint: low hanging specs/timeslider_labels.js

* lint: low hanging specs/timeslider_numeric_padID.js

* lint: low hanging specs/timeslider_revisions.js

* lint: low hanging specs/undo.js

* lint: low hanging specs/unordered_list.js

* lint: low hanging specs/xxauto_reconnect.js

* lint: attempt to do remote_runner.js

* lint: helper linting

* lint: rate limit linting

* use constructor for Event to make eslint happier

* for squash: lint fix refinements

* for squash: lint fix refinements

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-02-01 20:23:14 +00:00
Richard Hansen
759e2aaec3 lint: Use node config for tests/frontend/travis, tests/ratelimit
The files in these directories contain test drivers, not tests.
2021-02-01 19:52:24 +00:00
John McLear
9987fab574 lint: low hanging bin/doc/*.js 2021-02-01 13:15:48 -05:00
translatewiki.net
5b701b97c3 Localisation updates from https://translatewiki.net. 2021-02-01 15:21:50 +01:00
John McLear
b3dda3b11c lint: src/static/js/pluginfw/*.js 2021-01-30 17:00:40 -05:00
John McLear
0cc8405e9c Bump minimum required Node.js version to 10.17.0
This makes it possible to use fs.promises.
2021-01-30 17:00:40 -05:00
Richard Hansen
877f0c5883 server: Use wtfnode to log reasons why node isn't exiting 2021-01-30 08:05:08 +00:00
Richard Hansen
ba81ead101 server: Remove all other signal listeners 2021-01-30 08:05:08 +00:00
Richard Hansen
ecdb105bfe server: Refine process lifetime management
Define states and use them to properly handle multiple calls to
`start()`, `stop()`, and `exit()`. (Multiple calls to `exit()` can
happen if there is an uncaught exception or signal during shutdown.)

This should also make it easier to add support for cleanly restarting
the server after a shutdown (for tests or via an `/admin` page).
2021-01-30 08:05:08 +00:00
Richard Hansen
725023fe58 server: Refactor stop() to avoid no-async-promise-executor lint error
Also log when Etherpad has stopped.
2021-01-30 08:05:08 +00:00
Richard Hansen
d339f2a671 server: Perform init after adding uncaught exception handler
This avoids an unnecessary `try` block.
2021-01-30 08:05:08 +00:00
Richard Hansen
86ceb2b610 server: Exit on unhandled Promise rejection 2021-01-30 08:05:08 +00:00
Richard Hansen
0ad0160b7c bin/rebuildPad.js: Fix check for existing rev 2021-01-30 07:45:37 +00:00
Richard Hansen
846e3e9fbd bin/rebuildPad.js: Don't overwrite DB settings
There's no need, and setting `json` to true breaks databases that do
their own serialization of ECMAScript objects.
2021-01-30 07:45:37 +00:00
Richard Hansen
bf209ddad3 bin/rebuildPad.js: Close the database when done
This prevents loss of data due to unflushed writes.
2021-01-30 07:45:37 +00:00
Richard Hansen
809dc6e367 bin/rebuildPad.js: PadManager must be loaded before Pad
There is a circular dependency between the two; loading PadManager
first ensures that PadManager's Pad variable is not undefined.
2021-01-30 07:45:37 +00:00
Richard Hansen
5b519b9a9c bin/rebuildPad.js: Asyncify 2021-01-30 07:45:37 +00:00
Richard Hansen
72c2abab8d bin/rebuildPad.js: Fix sequencing of asynchronous functions 2021-01-30 07:45:37 +00:00
Richard Hansen
69efd16a6d bin/rebuildPad.js: Add missing calls to util.callbackify 2021-01-30 07:45:37 +00:00
Richard Hansen
c622894fe0 bin scripts: Promisify db.init and db.close 2021-01-30 07:45:37 +00:00
Richard Hansen
0a61767901 bin scripts: Delete redundant exception log messages
The exception will cause Node.js to print the error message and stack
trace so there's no point in logging it ourselves.
2021-01-30 07:45:37 +00:00
Richard Hansen
efdcaae526 bin scripts: Promisify npm.load 2021-01-30 07:45:37 +00:00
Richard Hansen
92cd2cc760 bin scripts: Use destructuring instead of long condition checks 2021-01-30 07:45:37 +00:00
Richard Hansen
f03c4bd7f7 bin scripts: compare against null, not undefined 2021-01-30 07:45:37 +00:00
John McLear
5bcd6f44a5
lint: skin-variants (#4603)
* lint: skin-variants

* for squash: Fix attachment of event listener

Before this PR the statement was outside the function. I'm assuming
the move into the function body was accidental, so move it back out.

* for squash: Preserve order of function calls

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-01-30 07:32:12 +00:00
John McLear
29179e512f lint: skiplist 2021-01-30 00:52:55 -05:00
John McLear
f72ce463ef lint: undomodule 2021-01-30 00:51:29 -05:00
Richard Hansen
89bcfa2b4a tests: Stop using nyc
There are some problems with nyc:
  * The coverage numbers aren't useful in our case because most of the
    code is executed outside the test process (the test code is mostly
    API client logic).
  * nyc messes with line numbers, which makes it much harder to debug
    problems.
  * We're seeing frequent SIGABRT crashes while nyc is printing the
    results table. I'm not sure if nyc is the cause of the crashes, or
    if it's making a race condition worse, or if the crashes have
    nothing to do with nyc, but we don't lose much by removing it so
    we might as well see if the crash frequency improves.
2021-01-29 09:17:17 +00:00
John McLear
0897a28e70 lint: AttributeManager 2021-01-29 09:16:50 +00:00
Richard Hansen
873987f989 tests: Asyncify indentation test
This makes it much easier to see why a test is failing. Before, a
`helper.waitFor()` failure would simply cause the test to time out.
Now an exception is displayed.
2021-01-29 09:16:50 +00:00
Richard Hansen
462530eafb AttributeManager: Fix attribute name during attribute removal
Before this change, the `author` attribute was silently discarded
during `.map()` iteration and the name of the attribute to remove was
included twice with two different values.
2021-01-29 09:16:50 +00:00
Richard Hansen
8efc87f33a AttributeManager: Fix bogus this during attribute removal
Before this commit, the callback passed to `.map()` during attribute
removal was a normal function, not an arrow function. This meant that
the value of `this` in the function body depended on how the callback
was invoked. In this case, the callback was invoked without any
explicit context (it was not called as a method, nor was it called via
`.call()`, `.apply()`, or `.bind()`). Without any explicit context,
the value of `this` depends on strict mode. Currently the function is
in sloppy mode, so `this` refers to the "global this" object (a.k.a.,
`window`). It doesn't make sense for the callback to reference
`window.author`, so I'm assuming the previous behavior was a bug.

Now the function is an arrow function, so the value of `this` comes
from the enclosing lexical context, which in this case is the
AttributeManager object. I believe that was the original intention.
2021-01-29 09:16:50 +00:00
Richard Hansen
c1ef12b8da lint: Re-run eslint --fix 2021-01-29 01:14:03 -05:00
Richard Hansen
b02ab430fe Bump eslint-config-etherpad to 1.0.24 2021-01-29 01:10:58 -05:00