Skip to content

ESLint rule for user data lockfile #1430

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

Open
wants to merge 2 commits into
base: f26d/lockfile-poc
Choose a base branch
from

Conversation

bcotrim
Copy link
Contributor

@bcotrim bcotrim commented May 23, 2025

Related issues

Proposed Changes

  • Add ESLint rule to enforce lock and unlock when making changes to the app data file

Code errors examples:

Without changes With changes to data With changes, lock but no unlock No error
image image image image

Testing Instructions

  • Code review and checking the ESLint behavior mentioned above

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@bcotrim bcotrim self-assigned this May 23, 2025
@bcotrim bcotrim mentioned this pull request May 23, 2025
1 task
@@ -7,7 +7,7 @@ import { normalize } from 'path';
import * as atomically from 'atomically';
import { getUserDataFilePath } from 'src/storage/paths';
import { UserData } from 'src/storage/storage-types';
import { loadUserData, saveUserData } from 'src/storage/user-data';
Copy link
Contributor

Choose a reason for hiding this comment

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

@bcotrim I am reviewing, but initially wanted to say that here is something weird:
Screenshot 2025-05-23 at 15 36 06
Screenshot 2025-05-23 at 15 36 16

Copy link
Contributor

@nightnei nightnei left a comment

Choose a reason for hiding this comment

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

The general idea is awesome 👍
But I can't understand the usecase - in Frdrik's PR we are moving to using withUserDataWrite as the wrapper for saveUserData, so we won't use it directly anymore. And if somebody need to update appdata, they will definitely use only withUserDataWrite as the single option which includes lock/unlock out of the box, so we don't need eslint for this approach.
Could you please elaborate on the idea, maybe I am missing something, but can't understand how this linter will be used with Fredrik's changes.

@bcotrim
Copy link
Contributor Author

bcotrim commented May 23, 2025

Thanks for the review @nightnei

In Fredrik's PR you had some concerns about the readability and usage of the HOF, the ESLint rule allows us to not use that while ensuring we "force" developers to implement the lock/unlock in their code when they change the appdata.

@nightnei
Copy link
Contributor

@bcotrim oh, I missed that it's a proposition of an alternative approach to HOF. The idea is really cool 👍

@bcotrim bcotrim force-pushed the add/lockfile_eslint_rule branch from be5aa21 to 9a64b0b Compare May 27, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants