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

Add rule no-inline-units #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spitfire1236
Copy link

@spitfire1236 spitfire1236 commented Apr 13, 2022

Closes #84

Copy link
Member

@igorkamyshev igorkamyshev left a comment

Choose a reason for hiding this comment

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

Thanks for contribution 💙

As I see, tests for documentation is broken, so, please add this rule to README.md.

Furthermore, I've found some minor issues. Could you consider fixing it?

@@ -0,0 +1,13 @@
# effector/no-inline-units

Disallows to use inline units in methods
Copy link
Member

Choose a reason for hiding this comment

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

Could you provide further information, why it is a bad idea to use inline units?

Copy link
Author

Choose a reason for hiding this comment

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

ye sure

@@ -0,0 +1,83 @@
const { RuleTester } = require("eslint");
Copy link
Member

Choose a reason for hiding this comment

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

I do not find any TS-tests. Should we add it?

Copy link
Author

Choose a reason for hiding this comment

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

I can add TS-tests, but I don't understand what specific cases they should cover.
Can u help me with that?

Copy link
Member

Choose a reason for hiding this comment

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

In mind, we should cover something like sample({ source: createCustomStoreBySomeFactory() }) where createCustomStoreBySomeFactory is not imported from effector, but it returns Store.

"createApi",
];

const UNIT_CREATORS = ["createStore", "createEvent", "createEffect"];
Copy link
Member

Choose a reason for hiding this comment

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

What about attach?

Copy link
Author

@spitfire1236 spitfire1236 Apr 14, 2022

Choose a reason for hiding this comment

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

ohh i lost it 🤪

"forward",
"sample",
"guard",
"attach",
Copy link
Member

Choose a reason for hiding this comment

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

I do not see, why inline effect in attach in bad 🤔

It looks like other rule to omit createEffect at all in this case.

const newEffect = attach({ effect: createEffect(() => null) })

const newEffect = attach({ effect: () => null })

Copy link
Member

Choose a reason for hiding this comment

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

I think it is because the name of the effect is lost. Sometimes you can't just understand the meaning of the unit from the context.

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.

Rule: no-inline-units
3 participants