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

APIB Serializer #53

Merged
merged 52 commits into from Dec 19, 2018
Merged

APIB Serializer #53

merged 52 commits into from Dec 19, 2018

Conversation

@pksunkara
Copy link
Contributor

@pksunkara pksunkara commented Dec 19, 2018

Fixes #33

danielgtaylor and others added 30 commits Sep 10, 2015
Fix handling of empty body with description
chore: Upgrade to peasant 1 and release 0.3.0
chore: Upgrade peasant to 1.1.0
kylef and others added 22 commits Jul 11, 2017
Add support for some of the data structures produced from the Swagger adapter
Release 0.6.0
Test on Node 8 and 10
Update to fury 3.0.0-beta.7
Update .gitignore
chore: Update dev dependencies
Fix CHANGELOG format consistency
…4db3f9b6a21f5892cdfe8d74b9a2d'

git-subtree-dir: packages/fury-adapter-apib-serializer
git-subtree-mainline: 1f4e482
git-subtree-split: cc266e4
@pksunkara pksunkara force-pushed the pksunkara/apibserializer branch from a2a0d7c to b0022be Dec 19, 2018
* Indent a piece of multiline text by a number of spaces.
* Setting `first` to `true` will also indent the first line.
*/
const indent = (input, spaces, options = { first: false }) => {

This comment has been minimized.

@kylef

kylef Dec 19, 2018
Member

@pksunkara why did you make these closures instead of functions?

This comment has been minimized.

@pksunkara

pksunkara Dec 19, 2018
Author Contributor

Because we are exporting these in this module. I generally use the rule that if I am exporting functions in ES6, I make them closures

This comment has been minimized.

@kylef

kylef Dec 19, 2018
Member

This brings inconsistency, against both other packages we maintain and even other files in the same package (function getTypeAttributes(element, attributes, parent) { a few lines down). That said, I believe it should be a named function for numerous reasons, due to scoping, hoisting, and transferring of this. Our style guide is also clear on this, it should be a named function instead of a function declaration:

7.1:

  • 7.1 Use named function expressions instead of function declarations. eslint: func-style

    Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to explicitly name the expression, regardless of whether or not the name is inferred from the containing variable (which is often the case in modern browsers or when using compilers such as Babel). This eliminates any assumptions made about the Error’s call stack. (Discussion)

    // bad
    function foo() {
      // ...
    }
    
    // bad
    const foo = function () {
      // ...
    };
    
    // good
    // lexical name distinguished from the variable-referenced invocation(s)
    const short = function longUniqueMoreDescriptiveLexicalFoo() {
      // ...
    };

Arrow functions are function expressions instead of named functions. You cannot declare a named arrow function.

This comment has been minimized.

@pksunkara

pksunkara Dec 19, 2018
Author Contributor

I have been doing this for other packages in the monorepo. I will make a separate PR standardizing this once this is merged.

@kylef
kylef approved these changes Dec 19, 2018
@kylef
kylef approved these changes Dec 19, 2018
@kylef kylef merged commit 3010489 into master Dec 19, 2018
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@kylef kylef deleted the pksunkara/apibserializer branch Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants