-
Notifications
You must be signed in to change notification settings - Fork 12
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
Defining functions #80
Comments
Please note that we already discussed and agreed about point 3. Points 1. and 2. needs to be defined after we made a decision to use ES6. |
👍 Agreed. I would add one more thing: Declaring function as assigning anonymous function to the variable is also a bad smell:
|
And this should be a rule too, in my opinion. |
We found one case when using a function expression makes more sense than using a function definition:
I'll update the proposal to explain such case. |
We follow the plan to use function declarations as often as possible and assigning function expressions to variables only if it makes real sense in a given context. |
Proposal for defining functions in the code. Should be added to https://github.com/ckeditor/ckeditor5-design/wiki/Code-Style.
Use arrow functions for anonymous functions (callbacks):
When using arrow functions, make sure to wrap the body of the function with
{}
to clarify where it ends if that may not be clear:When defining a function always use a function declaration. Usually you'll also want to keep the definition at the end of the outer function (not applying to tests).
Use named function expression (or a separate function declaration) when defining an important step of some algorithm to ease debugging:
The text was updated successfully, but these errors were encountered: