Commit Graph

536 Commits

Author SHA1 Message Date
Anders Kaseorg 6e220f4dc1 eslint: Enable @typescript-eslint/method-signature-style.
For historical reasons, TypeScript ignores variance errors for method
shorthand type declarations even in strict mode.  Prefer the correctly
checked style.

https://typescript-eslint.io/rules/method-signature-style

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-12-26 17:30:33 -08:00
Anders Kaseorg ea697cdd93 eslint: Enable @typescript-eslint/stylistic-type-checked config.
https://typescript-eslint.io/linting/configs/#stylistic-type-checked

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-12-23 15:36:05 -08:00
Anders Kaseorg 8f3e5e1b6b eslint: Enable @typescript-eslint/strict-type-checked config.
https://typescript-eslint.io/linting/configs/#strict-type-checked

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-12-21 16:14:40 -08:00
Anders Kaseorg 37f0a3b41b eslint: Forbid unchecked casts in TypeScript.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 09:54:30 -07:00
Anders Kaseorg 0fd4e309d5 eslint: Enable import/no-cycle rule.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-10 12:09:15 -07:00
Anders Kaseorg b9cd8de822 eslint: Follow @typescript-eslint/no-parameter-properties rule rename.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-21 15:58:42 -07:00
Anders Kaseorg 9570ced462 eslint: Replace no-duplicate-imports rule with import/no-duplicates.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-21 15:58:42 -07:00
Anders Kaseorg 407c16fc77 eslint: Expand no-unused-vars check to all function parameters.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-02 16:16:38 -07:00
Anders Kaseorg 03a0a7abc6 shared: Avoid replaceAll again.
The JavaScript engine used by zulip-mobile on Android is still some
four years out of date, apparently.

This reverts commit a3d6c47b7d (#25734)
and part of commit 54f90e41c0 (#25554).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-05-25 22:39:12 -07:00
Anders Kaseorg 3e6a212ace dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-05-12 11:12:20 -07:00
Anders Kaseorg 66f762f4f4 eslint: Enable @typescript-eslint/strict configuration.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 084771ce74 eslint: Fix @typescript-eslint/consistent-type-definitions.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 4c5042e736 eslint: Loosen no-use-before-define for TS like we do for JS.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-25 09:40:57 -07:00
Anders Kaseorg b3f9fdf99a dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-20 15:48:29 -07:00
Anders Kaseorg 3109ee8015 eslint: Enable @typescript-eslint/recommended plugin.
This is not automatically enabled by
@typescript-eslint/recommended-requiring-type-checking for some
reason.

https://typescript-eslint.io/linting/configs/#recommended

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-16 13:24:27 -07:00
Alex Vandiver a8181152b7 webpack: Build a ZULIP_VERSION global constant into the built product. 2023-03-07 10:51:45 -08:00
Anders Kaseorg 2a70c11c5f eslint: Fix unicorn/prefer-spread.
This was initially disabled for IE/Babel-related reasons that no
longer apply.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 12:16:56 -08:00
Anders Kaseorg a58b87893e eslint: Prohibit import cycles in TypeScript.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-24 11:33:36 -08:00
Anders Kaseorg 0ef8e88b17 webpack: Move webpack configuration to web.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-24 06:35:58 -08:00
Anders Kaseorg 377b8b22c0 puppeteer_tests: Move to web/e2e-tests.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-23 16:04:17 -08:00
Anders Kaseorg cea1119423 node_tests: Move to web/tests.
This lets us simplify the long-ish ‘../../static/js’ paths, and will
remove the need for the ‘zrequire’ wrapper.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-23 16:04:17 -08:00
Anders Kaseorg c1675913a2 web: Move web app to ‘web’ directory.
Ever since we started bundling the app with webpack, there’s been less
and less overlap between our ‘static’ directory (files belonging to
the frontend app) and Django’s interpretation of the ‘static’
directory (files served directly to the web).

Split the app out to its own ‘web’ directory outside of ‘static’, and
remove all the custom collectstatic --ignore rules.  This makes it
much clearer what’s actually being served to the web, and what’s being
bundled by webpack.  It also shrinks the release tarball by 3%.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-23 16:04:17 -08:00
Anders Kaseorg 56f9a9c397 eslint: Add root: true.
https://eslint.org/docs/latest/user-guide/configuring/configuration-files#cascading-and-hierarchy

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-03 13:59:25 -08:00
Anders Kaseorg 5fda9f3439 eslint: Clean up configuration.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-25 20:37:51 -08:00
Anders Kaseorg 8b6bd961e6 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-07 09:55:05 -08:00
Anders Kaseorg eb2c822d3f eslint: Enable object-shorthand avoidExplicitReturnArrows option.
This is equivalent in the absence of ‘this’ (which ESLint knows to
check for).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-17 16:48:44 -08:00
Anders Kaseorg 762a2d8da4 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-10-11 10:50:57 -07:00
Anders Kaseorg dfda6d2895 puppeteer_tests: Remove jQuery dependency.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-11 12:53:20 -07:00
Anders Kaseorg 143a3350fa dependencies: Upgrade JavaScript dependencies.
jQuery is held at 3.6.0 due to
https://github.com/jquery/jquery/issues/5105.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-06 15:02:29 -07:00
Anders Kaseorg e8a30060ee js: Enable no-jquery/no-constructor-attributes.
https://github.com/wikimedia/eslint-plugin-no-jquery/blob/master/docs/rules/no-constructor-attributes.md

The motivation for this rule is a subtle caveat buried in the
documentation:

https://api.jquery.com/jquery/#jQuery-html-attributes

“While the second argument is convenient, its flexibility can lead to
unintended consequences (e.g. $( "<input>", {size: "4"} ) calling the
.size() method instead of setting the size attribute).”

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-08-16 13:42:28 -07:00
Anders Kaseorg 3bc1356f39 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-07-06 17:23:16 -07:00
Tim Abbott 24f527cb59 home: Don't send /register response for spectators.
In very large communities, computing page_params can be quite
expensive. Because we've moved the homepage for communities with web
public streams enabled to be the Zulip app, and it's common for
automation to frequently poll the homepage of a Zulip organization,
we'd like to keep those homepages cheap (as the login pages are).

We address this by prototyping something we may end up wanting to do
anyway -- having the web application do a `POST /register` API call in
order to fetch most page_params, and merging those with the mostly
webapp configuration page_params that we leave in the / response for
convenience.

This exact implementation is messy in a few ways:

* We rely on the assumption that ui_init.initialize_everything happens
  before all code that needs to inspect the page_params properties we
  are fetching via /register. This is likely mostly true, but nothing
  in the implementation enforces it.
* The bundle of ~25 keys that are in page_params ideally would be
  considered individually, with some moved to the /register API
  response and perhaps others eliminated or namespaced inside a
  webapp_settings object.
* It's weird to have the spectators network sequence different that
  from logged-in users, and potentially a maintainability risk.
* We might be able to arrange that the initial `/` response be
  cacheable, now that we're no longer embedding our metadata inside
  it. We've made no effort to do that as of yet.

Despite those issues, this commit solves an immediate problem and will
give us helpful experience with a model closer to the one we'll want
in order to happily support a web client that can be run locally
against a production Zulip server's data.

Co-authored-by: Anders Kaseorg <anders@zulip.com>
2022-05-05 15:20:46 -07:00
Anders Kaseorg 6aec27e646 js: Fix no-jquery/no-parse-html-literal.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-17 13:16:34 -07:00
Anders Kaseorg 215791db1e eslint: Enable no-jquery/deprecated rules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-17 13:10:23 -07:00
Anders Kaseorg 4b712b49ef eslint: Enable eslint-plugin-no-jquery.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-16 12:52:07 -07:00
Anders Kaseorg 381b6577a8 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-12-03 14:33:53 -08:00
Anders Kaseorg f194ffbee8 compose_actions: Remove self-import.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-11-23 15:21:48 -08:00
Anders Kaseorg 2bb4410698 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-10-17 07:15:09 -07:00
Anders Kaseorg 0ef5cb4813 eslint: Enable @typescript-eslint/recommended-requiring-type-checking.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-09-22 18:06:06 -07:00
Priyank Patel c862c673af ts: Convert blueslip module to TypeScript.
We turn off the eslint no-use-before-define for TypeScript files
because it does not work correctly for types. There is already
a typescript-eslint version of it that is enabled for TS.

We also update the error handler on window to use instanceof check
for ErrorEvent instead of checking the error property.
2021-06-22 09:09:36 -07:00
Anders Kaseorg a9f6764d8c eslint: Add eslint-plugin-formatjs.
This guards against various mistakes, such as setting defaultMessage
to a computed expression that can’t be extracted.

https://formatjs.io/docs/tooling/linter/

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-13 22:32:40 -07:00
Anders Kaseorg ad7466a2bf dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:15:52 -07:00
Priyank Patel 7999d52400 ts: Convert keydown_util to TypeScript.
We also add JQuery to globals which is a global type.
2021-05-27 23:33:21 -07:00
Priyank Patel 6ab66ea17a keydown_util: Use Event.key instead of deprecated properties.
The Event.which and Event.keyCode are deprecated as pointed out by
TypeScript intellisense based on the jQuery types. We use Event.key
instead which behaves similarly to Event.which & Event.keyCode for
our use case.

The only difference in functionality by this change is that the vim
keys won't work when Caps Lock is on. This is because, in this case,
the key property will be "J" instead of 'j'. We can fix this by
adding a mapping for this, however, I think we don't want to handle
this case so I left this change out. Tested by trying out the
everywhere keydown_util is used.

Finally, we also turn off the new-cap rule for tests since I think
it fine to only enforce it on real code and exempting test code is
fine.
2021-05-27 23:33:17 -07:00
Anders Kaseorg 5ca763fc24 eslint: Fix unicorn/prefer-switch.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-10 19:26:41 -07:00
Anders Kaseorg a284299b85 eslint: Fix unicorn/prefer-array-flat.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-10 18:07:13 -07:00
Anders Kaseorg 42abc1b635 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-10 18:07:13 -07:00
Anders Kaseorg bf056c8990 js: Extract password_quality module; remove zxcvbn from globals.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-24 13:08:52 -07:00
Anders Kaseorg 6dc783e562 eslint: Enable sort-imports for member sorting.
This sorts the members imported within each individual declaration; we
use import/order for sorting multiple declarations.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-03 15:54:14 -07:00
Anders Kaseorg d43ac7357a js: Move current_msg_list, home_msg_list to ES6 module message_lists.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-29 18:23:47 -07:00