Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H-2457: Improved ESLint configuration #5847

Merged
merged 51 commits into from
Dec 11, 2024

Conversation

indietyp
Copy link
Member

🌟 What is the purpose of this PR?

ESLint 9 introduces flat configs which breaks the existing configuration format, in light of this we decided to move to a more encompassing ruleset in the longterm.

Previous attempts have been made to apply a stricter ruleset, but it was found that due to the sheer size of some projects it just isn't feasible to transition every project in one go, instead the approach is as follows:

  1. We transition to ESLint 9 and use flat configs
  2. During this transition to ESLint 9 we implement a new (stricter) ruleset. The ruleset won't be applied directly, but instead gradually over all projects. The existing legacy ruleset is used in its stead for now.
  3. Key existing libraries/apps (HaRPC client, hash-isomorphic-utils, and others) could be moved over to newer configs.
  4. New projects use the new ruleset instead of the deprecated one.

For stricter rulesets there are quite some prebuilt ones, these include:

  • xo
  • sheriff
  • @antfu/eslint-config

The main problem with xo is that it is exposed through an alternative binary, making it unsuitable to use in, e.g., WebStorm. It also, by default, lints stylistic choices covered by prettier.

@antfu/eslint-config is just eslint, but like xo also pretty heavily features stylistic rules.

sheriff instead fully embraces ESLint flat configs, is highly configurable, and has an excellent webpage detailing all the configurations used.

To see a comprehensive comparison of different configs, see: https://www.eslint-config-sheriff.dev/docs/prior-art

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • affected the execution graph, and the turbo.json's have been updated to reflect this

@indietyp indietyp requested a review from a team as a code owner December 10, 2024 12:33
@github-actions github-actions bot added area/deps Relates to third-party dependencies (area) area/apps > hash* Affects HASH (a `hash-*` app) area/infra Relates to version control, CI, CD or IaC (area) area/apps > hash-api Affects the HASH API (app) area/blocks Relates to first-party blocks (area) area/apps > hash.dev Affects the `hash.dev` developer site (app) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team type/eng > backend Owned by the @backend team area/tests New or updated tests area/tests > integration New or updated integration tests area/tests > playwright New or updated Playwright tests area/apps > hash-realtime area/apps > hash-search-loader area/apps type/legal Owned by the @legal team area/apps > hash.design Affects the `hash.design` design site (app) labels Dec 10, 2024
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 9.37500% with 29 lines in your changes missing coverage. Please review.

Project coverage is 23.18%. Comparing base (3790335) to head (eceafca).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...w-activities/shared/create-file-entity-from-url.ts 0.00% 3 Missing ⚠️
...-activities/infer-metadata-from-document-action.ts 0.00% 2 Missing ⚠️
...low-activities/research-entities-action.ai.test.ts 0.00% 2 Missing ⚠️
...se-relevant-links-from-content.optimize.ai.test.ts 0.00% 2 Missing ⚠️
...llower-agent/llama-index/simple-storage-context.ts 0.00% 2 Missing ⚠️
...-entities-action/sub-coordinating-agent.ai.test.ts 0.00% 2 Missing ⚠️
...get-entity-summaries-from-text.optimize.ai.test.ts 0.00% 2 Missing ⚠️
...t/infer-summaries-then-claims-from-text.ai.test.ts 0.00% 2 Missing ⚠️
...ts/src/activities/shared/optimize-system-prompt.ts 0.00% 2 Missing ⚠️
...pps/hash-api/src/ai/gpt/generate-hashgpt-schema.ts 0.00% 2 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5847      +/-   ##
==========================================
+ Coverage   22.99%   23.18%   +0.18%     
==========================================
  Files         569      522      -47     
  Lines       19096    16976    -2120     
  Branches     2709     2460     -249     
==========================================
- Hits         4392     3936     -456     
+ Misses      14652    12991    -1661     
+ Partials       52       49       -3     
Flag Coverage Δ
apps.hash-ai-worker-py ?
apps.hash-ai-worker-ts 1.32% <0.00%> (+<0.01%) ⬆️
apps.hash-api 1.16% <0.00%> (ø)
backend-integration-tests ?
deer ?
error-stack ?
local.hash-backend-utils 8.81% <ø> (+<0.01%) ⬆️
local.hash-graph-sdk 58.62% <ø> (ø)
local.hash-isomorphic-utils 1.00% <ø> (+<0.01%) ⬆️
local.hash-subgraph 24.54% <ø> (ø)
rust.error-stack 72.51% <ø> (ø)
sarif ?
tests.hash-backend-integration ?
unit-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

CiaranMn
CiaranMn previously approved these changes Dec 11, 2024
Copy link
Contributor

Benchmark results

@rust/hash-graph-benches – Integrations

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$16.4 \mathrm{ms} \pm 170 \mathrm{μs}\left({\color{lightgreen}-29.261 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$16.1 \mathrm{ms} \pm 185 \mathrm{μs}\left({\color{gray}-4.289 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$17.0 \mathrm{ms} \pm 220 \mathrm{μs}\left({\color{gray}4.67 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$16.0 \mathrm{ms} \pm 198 \mathrm{μs}\left({\color{lightgreen}-5.172 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$16.7 \mathrm{ms} \pm 194 \mathrm{μs}\left({\color{gray}3.10 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$17.0 \mathrm{ms} \pm 200 \mathrm{μs}\left({\color{gray}-2.643 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$16.8 \mathrm{ms} \pm 221 \mathrm{μs}\left({\color{gray}4.31 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.5 \mathrm{ms} \pm 197 \mathrm{μs}\left({\color{lightgreen}-28.759 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$16.5 \mathrm{ms} \pm 151 \mathrm{μs}\left({\color{gray}1.18 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$68.8 \mathrm{ms} \pm 591 \mathrm{μs}\left({\color{gray}2.52 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$40.5 \mathrm{ms} \pm 158 \mathrm{μs}\left({\color{gray}3.35 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$58.5 \mathrm{ms} \pm 160 \mathrm{μs}\left({\color{gray}1.29 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$44.5 \mathrm{ms} \pm 281 \mathrm{μs}\left({\color{gray}3.54 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$49.7 \mathrm{ms} \pm 293 \mathrm{μs}\left({\color{gray}0.748 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$54.3 \mathrm{ms} \pm 286 \mathrm{μs}\left({\color{gray}-0.469 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$109 \mathrm{ms} \pm 675 \mathrm{μs}\left({\color{gray}0.375 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$43.2 \mathrm{ms} \pm 314 \mathrm{μs}\left({\color{gray}0.820 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$101 \mathrm{ms} \pm 463 \mathrm{μs}\left({\color{gray}0.930 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$82.0 \mathrm{ms} \pm 374 \mathrm{μs}\left({\color{gray}-1.087 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$91.5 \mathrm{ms} \pm 413 \mathrm{μs}\left({\color{gray}-1.494 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$97.3 \mathrm{ms} \pm 436 \mathrm{μs}\left({\color{gray}0.749 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: d4e16033-c281-4cde-aa35-9085bf2e7579 $$1.41 \mathrm{ms} \pm 5.33 \mathrm{μs}\left({\color{gray}1.58 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$267 \mathrm{ms} \pm 1.46 \mathrm{ms}\left({\color{gray}-0.638 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$27.0 \mathrm{ms} \pm 109 \mathrm{μs}\left({\color{gray}0.870 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$20.3 \mathrm{ms} \pm 89.8 \mathrm{μs}\left({\color{lightgreen}-5.413 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$53.4 \mathrm{ms} \pm 2.30 \mathrm{ms}\left({\color{gray}3.85 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$176 \mathrm{ms} \pm 641 \mathrm{μs}\left({\color{gray}-2.200 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$1.97 \mathrm{ms} \pm 7.08 \mathrm{μs}\left({\color{gray}1.14 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.12 \mathrm{ms} \pm 6.49 \mathrm{μs}\left({\color{gray}0.411 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.98 \mathrm{ms} \pm 7.34 \mathrm{μs}\left({\color{gray}0.661 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.84 \mathrm{ms} \pm 11.2 \mathrm{μs}\left({\color{gray}-0.403 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$9.37 \mathrm{ms} \pm 83.6 \mathrm{μs}\left({\color{gray}-1.915 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$4.04 \mathrm{ms} \pm 22.2 \mathrm{μs}\left({\color{gray}-1.875 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.98 \mathrm{ms} \pm 8.22 \mathrm{μs}\left({\color{gray}-0.566 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.95 \mathrm{ms} \pm 10.5 \mathrm{μs}\left({\color{gray}0.492 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.17 \mathrm{ms} \pm 7.53 \mathrm{μs}\left({\color{gray}3.59 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$3.35 \mathrm{ms} \pm 11.9 \mathrm{μs}\left({\color{gray}0.200 \mathrm{\%}}\right) $$ Flame Graph

@indietyp indietyp enabled auto-merge December 11, 2024 12:25
Copy link
Member

@hashdotai hashdotai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CiaranMn on behalf of Legal

@indietyp indietyp added this pull request to the merge queue Dec 11, 2024
Merged via the queue into main with commit cb79928 Dec 11, 2024
166 checks passed
@indietyp indietyp deleted the bm/h-2457-improved-eslint-configuration branch December 11, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apps > hash.design Affects the `hash.design` design site (app) area/apps > hash.dev Affects the `hash.dev` developer site (app) area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) area/apps > hash-realtime area/apps > hash-search-loader area/apps area/blocks Relates to first-party blocks (area) area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests > integration New or updated integration tests area/tests > playwright New or updated Playwright tests area/tests New or updated tests type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team type/legal Owned by the @legal team
Development

Successfully merging this pull request may close these issues.

3 participants