-
-
Notifications
You must be signed in to change notification settings - Fork 59
feat: Add require-store-callbacks-use-set-param rule
#284
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
feat: Add require-store-callbacks-use-set-param rule
#284
Conversation
🦋 Changeset detectedLatest commit: ec2d47d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
88ee1e0 to
40ab9b2
Compare
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
ota-meshi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR that adds the rule!
I made some comments.
| "writable", | ||
| ])) { | ||
| const [_, fn] = node.arguments | ||
| if (!fn || fn.type !== "ArrowFunctionExpression") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be even better if we also check FunctionExpression.
| if (!fn || fn.type !== "ArrowFunctionExpression") { | |
| if (!fn || (fn.type !== "ArrowFunctionExpression" && fn.type !== "FunctionExpression")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! Sorry I fixed it.
ec2d47d
| import { readable, writable, derived } from "svelte/store" | ||
|
|
||
| /** ✓ GOOD */ | ||
| readable(false, (set) => set(true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know it should return the stop function.
A rule doesn't have to check for it, but a GOOD example would be better if it was more correct.
| readable(false, (set) => set(true)) | |
| readable(false, (set) => { | |
| set(true) | |
| return () => {/* stop */} | |
| }) |
| // refer: https://eslint.org/docs/latest/rules/no-unused-vars | ||
| readable(false, (set) => true) | ||
|
|
||
| writable(false, (set) => set(true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| writable(false, (set) => set(true)) | |
| writable(false, (set) => { | |
| set(true) | |
| return () => {/* stop */} | |
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated.
a6686e4
And I added description about derived store.
ota-meshi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
resolve: #267