Commit Graph

30 Commits

Author SHA1 Message Date
Felix Kling
db3e905242
Migrate deprecated rxjs functions/methods (#61222)
As a follow up to https://github.com/sourcegraph/sourcegraph/pull/61122 this commit updates the deprecated methods with the suggested replacements.

**Note**

This only migrates functions/methods that are replaced with something else, or whose deprecated call signature can easily be identified (e.g. `throwError(error)` -> `throwError(() => error)`). It's possible that there are more functions which deprecate a specific signature that we are using. I'll migrate those as I encounter them.

**Notes about `.toPromise`**

The instances of `.toPromise` converted here are all instances where the updated return value of `Promise<X|undefined>` did not produce a TS error (the ones with errors have been converted in #61122). However that doesn't mean that they can simply be replaced with `firstValueFrom`, `lastValueFrom` (these two methods throw errors when the source observable hasn't emitted a value before closing).
I update the callsites under two assumptions:
- Callsites that involve GraphQL requests will always emit a value and thus can be converted to using `lastValueFrom`/`firstValueFrom`.
- For other callsites we cannot make the assumption that the source observable emits before closing and thus they need a default value.
2024-04-08 11:23:34 +02:00
Felix Kling
c529631483
web: Update rxjs to v7 (#61122)
A side goal for the web rewrite is to leave the existing code base in a better state than before. I recently [added a hacky workaround](da5ddc99b6/client/web-sveltekit/vite.config.ts (L82-L101)) to make the Svelte version work properly with different rxjs versions. But the whole point of the rewrite is to not have to do these things anymore. So this is my attempt of upgrading rsjx in the main repo to v7.

I worked through the list of breaking changes in the [rxjs documentation](https://rxjs.dev/deprecations/breaking-changes) and fixed TypeScript issues to the best of my abilities.

Most notable changes:

- The custom `combineLatestOrDefault` operator was rewritten to avoid using rxjs internals, and the `.lift` method (side note: the corresponding tests do not cover all expected behavior, but issues had been caught through other tests)
- Where necessary `.toPromise()` was replaced with `lastValueFrom` or `firstValueFrom`. My assumption was that since we don't get runtime errors for the existing code, it's save to assume that the corresponding observables emit at least one value, i.e. `.toPromise()` did not return `undefined`. Only in some places I added a default value where it was easy to deduce what it should be.
- The generic type in `of()` was removed
- The generic type in `concat()` was removed
- `Subject.next` seemed to have allowed `undefined` to be passed even if the subject's types didn't allow that. If the subject's type couldn't be extended to include `undefined` I changed the code to not pass `undefined`.
- The generic type signature of `defaultIfEmpty` changed.
- Where possible I replaced `Subscribable` with `ObservableInput`, but we also have a copy of the old `Subscribable` interface in the `sourcegraph` package, and that makes things more complicated.
- I simplified unnecessary Promise/Observable interop where necessary.

A lot of the complex rxjs logic and usage of changed interfaces, such as `Subscribable`, is in extensions related code, which is not used in the web app anymore, but is still at least imported in the browser extensions code. Most of it is probably not used anymore, which makes the migration somewhat simpler.
2024-03-18 14:02:57 +01:00
Quinn Slack
4002774429
reapply "switch from jest to vitest for faster, simpler tests (#57886)" (#58145)
* reapply "switch from jest to vitest for faster, simpler tests (https://github.com/sourcegraph/sourcegraph/pull/57886)"

This was reverted in https://github.com/sourcegraph/sourcegraph/pull/58116 due to an issue with the browser tests.

* include fetch-mock

* fix flakiness

* rm mock that did not work in experimentalVmThreads

* fix

* timeout

* fixup

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2023-11-07 12:00:18 +02:00
William Bezuidenhout
7f4bebe29d
Revert: bazel+vitest - when running vitests concurrently the target //client/browser:test fails (#58116)
When running vitests concurrently the target //client/browser:test fails

Revert "switch from jest to vitest for faster, simpler tests (#57886)"

This reverts commit ae5325e432.
2023-11-06 14:02:35 +02:00
Quinn Slack
ae5325e432
switch from jest to vitest for faster, simpler tests (#57886)
Replaces our usage of jest with vitest. Also removes the babel transpiler. This simplifies our test configuration by a lot, makes tests run 10% faster, and makes further modernizations to our build/test stuff possible (such as using vite for frontend builds).

This removes some of the junit exporting for Buildkite, and the vitest bazel defs don't really cleanly implement bazel testing guidelines (like sharding). But vitest is only used for unit tests (all integration/e2e/regression tests have always run in mocha), so none of them are very slow anyway.

## Codemods for vitest imports

fastmod -e js,ts,tsx @jest/globals vitest client/ dev/release/
fastmod -e js,ts,tsx 'jest\.(\w+)\(' 'vi.$1(' client/ dev/release/
fastmod -e js,ts,tsx 'jest,' 'vi,' client/ dev/release/
fastmod -e js,ts,tsx 'jest }' 'vi }' client/ dev/release/
git diff --diff-filter=M --name-only | xargs pnpm exec prettier --write
2023-11-05 21:57:04 -10:00
Quinn Slack
131ad5019f
upgrade @sourcegraph/eslint-config and fix all auto-fixable issues (#57847)
Also configures to `warn` for some rules that require manual code fixes and that are not urgent.
2023-10-24 00:52:12 +00:00
Quinn Slack
f160c5c041
explicitly import @jest/globals and mocha (#57786)
Previously bindings like `expect`, `describe`, `afterAll`, etc., were imported implicitly by Jest or Mocha. We should import them explicitly to reduce magic. (Also this makes it easier to migrate to another test runner in the future if we want.)
2023-10-23 21:40:17 +00:00
Quinn Slack
c0442a2e9f
disable slow eslint rules, remove unused disable directives (#57788)
* disable slow eslint rules, remove unused disable directives

Disabling these eslint rules makes saving significantly faster. These rules are not worthless, but they are usually ignored anyway, and I can't recall a specific instance when they would have caught a bug. I am proposing we disable them and then set a checkpoint in 14 days to rerun eslint with the rules enabled and see if they would have caught any bad practices. In the meantime, we will all benefit from instant saves (with eslint fixes) instead of waiting 3-5 seconds or more after each save in VS Code, which is destructive to productivity.

* upgrade eslint
2023-10-23 13:23:44 -07:00
Felix Kling
7363557f41
Eslint fix type imports (#54920)
This PR adds the eslint rules @typescript-eslint/consistent-type-imports and @typescript-eslint/no-import-type-side-effects. Having type imports be explicitly declared as such makes it easier for modern bundlers to strip those imports which is useful if e.g. a module is sent directly to the browser.

I added both rules as a warning because @typescript-eslint/consistent-type-exports is also a warning.
2023-08-10 21:12:31 +02:00
Quinn Slack
45cd5171fd
remove unnecessary usage of sourcegraph import (#46021)
We have deprecated the extension API (`sourcegraph` module) and want to remove it entirely. The `@sourcegraph/shared/src/codeintel/legacy-extensions/api` module already duplicates most of the `sourcegraph` exports and does not have the implicit representation of being an external API. This commit is one step along the way toward removing the `sourcegraph` module and package.
2023-01-02 20:00:20 +00:00
Valery Bugakov
260561a942
web: upgrade prettier to the latest version to support TS satisfies operator (#45400) 2022-12-08 02:37:23 -08:00
Vova Kulikov
a3a7308da2
Upgrade TypeScript to the 4.9.3 (#44638) 2022-11-21 16:17:58 -03:00
Geoffrey Gilmore
99e458a3a8
Revert "[SG-43144]: Tables in code excerpts should use headers for line numbers (#43389)" (#44514) 2022-11-16 10:59:13 -08:00
GitStart-SourceGraph
5e41e12491
[SG-43144]: Tables in code excerpts should use headers for line numbers (#43389)
* chore: tables in code excerpts should use headers for line numbers

* chore: apply td to th for data-line in syntax-highlighter image

* feat: add more changes to fix blob view issues

* fix: ui review changes

* fix: percy snapshots
2022-11-03 11:23:36 +07:00
GitStart-SourceGraph
51befbfa52
[SG-39797] Enable no-console ESLint rule (#40458) 2022-10-03 07:19:17 -07:00
Felix Kling
d101e5cad9
Fix scrolling first selected line into view (#38175)
Problem: When selecting multiple lines such that the first selected line
is out of view, the file view jumps back to the first selected line
after selecting the last line.

This is because we are only considering the first selected line when we
determine the position to scroll to.

This commit changes the logic to take into account the top and bottom of
the complete line range.
2022-07-05 15:16:26 +00:00
Chris Wendt
48d4f87732
Fix popover appearing on page load without being pinned (#36194) 2022-06-01 11:51:47 -06:00
GitStart-SourceGraph
00039658b5
Upgrade to the latest version of ESLint (#35111)
Co-authored-by: gitstart-sourcegraph <gitstart@users.noreply.github.com>
Co-authored-by: Valery Bugakov <skymk1@gmail.com>
2022-05-31 07:08:01 +01:00
Chris Wendt
d609d35093
Add (back) the ability to share links to code intel popover locations 2 (#36039) 2022-05-25 18:30:21 +00:00
Tom Ross
cc13d116ce
Revert "Add (back) the ability to share links to code intel popover locations" (#36025)
Revert "Add (back) the ability to share links to code intel popover locations (#35658)"

This reverts commit 41faa7fcdc.
2022-05-25 15:28:32 +01:00
Cesar Jimenez
41faa7fcdc
Add (back) the ability to share links to code intel popover locations (#35658) 2022-05-24 12:46:56 -06:00
Chris Wendt
e858f43375
Fix hover reposition jank 2 (#34859) 2022-05-03 17:35:31 -06:00
Chris Wendt
baba399413
Revert "codeintellify: Fix hover reposition jank (#34028)" (#34206)
This reverts commit adb53dea29.
2022-04-20 11:35:52 -06:00
Chris Wendt
adb53dea29
codeintellify: Fix hover reposition jank (#34028) 2022-04-19 15:38:39 +00:00
Chris Wendt
f2847e1daf
codeintellify: Fix hover flicker (#33988) 2022-04-19 09:16:12 -06:00
Valery Bugakov
868472f43e
ci: run client linters on changed files (#33701) 2022-04-14 00:37:25 -07:00
GitStart-SourceGraph
93eebb8b84
[SG-31914] Fix failing unit tests on client/common, client/codeintellify packages (#32241)
* fix: unit tests in client/common client/codeintellify

* chore: decrease TOOLTIP_DISPLAY_DELAY

Co-authored-by: gitstart-sourcegraph <gitstart@users.noreply.github.com>
2022-03-08 21:55:50 +07:00
Juliana Peña
3d690041bc
disable broken jest tests (#31956) 2022-03-01 01:59:14 -08:00
Thorsten Ball
8f347b33a5
Add experimental reference panel behind feature flag (#30095)
This is the first, experimental, tech preview, proof-of-concept version of a better reference panel to get internal user feedback. 

Use the feature flag `"experimentalFeatures": { "coolCodeIntel": true }` to try it.

Requirement: it only works with precise code intel data now.

This fixes https://github.com/sourcegraph/sourcegraph/issues/30969
2022-02-14 17:36:26 +01:00
GitStart-SourceGraph
f9dc317cfe
refactor: extract codeintellify as new package (#29233)
* refactor: extract codeintellify as new package

* feat: add client/codeintellify into lsif-ts

Co-authored-by: gitstart-sourcegraph <gitstart@users.noreply.github.com>
2022-01-10 22:29:47 +07:00