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

Draft: Move Most Linting Logic to Web Workers #1047

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

pjkaufman
Copy link
Collaborator

@pjkaufman pjkaufman commented Mar 16, 2024

Fixes #337
Relates to #927
Relates to #872
This should unblock #488 which gets us closer to #183

To make the linting experience better for users, it is better if we can run the linting logic on a separate thread from the main thread. This will allow the user to be able to work on things if linting a file is taking a while. Most rules can run in the web workers. But the ones that deal with moment or obsidian specific logic have to remain on the main thread since they cannot have their data passed to and from the web worker (this is a limitation due to the complexity of the moment object) and because the source code is not available at compile time which makes it impossible to inline the logic from obsidian. So we have to compromise a little here. But this should still be a net improvement for users with larger files or who use mass linting options on their vaults. This will need to be in BETA for some time if possible. So I will need to setup BRAT for this change.

TODO:

  • Swap out uses of the RulesRunner class for references to the lint file manager
  • Make sure linting on active file change works
  • Make sure linting on active file change works when custom commands are used and no change is made
  • Make sure linting on active file change works when custom commands are used and a change is made
  • Make sure regular linting works
  • Make sure regular linting works when custom commands are used and no change is made
  • Make sure regular linting works when custom commands are used and a change is made
  • Make sure linting a folder works
  • Make sure linting the vault works
  • Make sure linting on paste works
  • Make sure that linting a file with YAML frontmatter that says that all rules are disabled does not run custom commands
  • Make sure that regular rule disabling via the YAML frontmatter is respected
  • Remove old copy folder and files
  • Move linting functions to the utils folder as a lint or lint-runner file since it is just a set of related functions that are useful when running linting operations
    • These should mostly be used by the file lint manager, but we shall see
  • See about setting a timeout on how long the worker can run before it will throw an error to prevent an infinite loop from happening and not allowing more linting to happen
    • I am thinking that 5 or 10 minutes should be a good value to use as a measurement
    • This will help out with making sure that we prevent long running lints from happening unexpectedly
    • We may want a user override, but that can probably wait until users request it
  • Break up rules runner UTs into their own separate files to make sure that things still work as intended
    • Maybe add more UTs to see how things work together if possible

If we want to have more than 1 worker running at a time:

  • See about adding file name to logs in console log for lints since there may be 2+ workers now which will make things pretty hectic when it comes to making sure that logs are displayed back to back in the console

@pjkaufman pjkaufman self-assigned this Mar 16, 2024
@pjkaufman pjkaufman added the enhancement New feature or request label Mar 16, 2024
…d the old rules runner which should be replaced by the worker now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FR: Use Web Workers to Improve Lint All and Lint Folder Experience
1 participant