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

[Doc PR] naming fix in example #5659

Merged
merged 5 commits into from Apr 25, 2017
Merged

[Doc PR] naming fix in example #5659

merged 5 commits into from Apr 25, 2017

Conversation

aretecode
Copy link
Contributor

Q A
Doc PR x

because code is declared as const twice

because code is declared as const twice
@mention-bot
Copy link

@aretecode, thanks for your PR! By analyzing the history of the files in this pull request, we identified @xtuc, @existentialism and @novemberborn to be potential reviewers.

align the naming, allow the example to be usable without change
@aretecode aretecode changed the title [Doc PR] change code -> string [Doc PR] naming fix in example Apr 23, 2017
@codecov
Copy link

codecov bot commented Apr 23, 2017

Codecov Report

Merging #5659 into 7.0 will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              7.0    #5659   +/-   ##
=======================================
  Coverage   84.38%   84.38%           
=======================================
  Files         284      284           
  Lines        9760     9760           
  Branches     2735     2735           
=======================================
  Hits         8236     8236           
  Misses       1010     1010           
  Partials      514      514
Impacted Files Coverage Δ
packages/babel-traverse/src/path/context.js 85.34% <0%> (-0.87%) ⬇️
...bel-plugin-transform-es2015-classes/src/vanilla.js 90.59% <0%> (+0.42%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8434f89...b4f3d94. Read the comment docs.

const ast = babylon.parse(code, { allowReturnOutsideFunction: true });
const { code, map, ast } = babel.transformFromAst(ast, code, options);
const string = "if (true) return;";
const parsedAst = babel.parse(string, { allowReturnOutsideFunction: true });
Copy link
Member

Choose a reason for hiding this comment

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

This should be kept babylon.parse().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@existentialism updated

@existentialism existentialism added the PR: Docs 📝 A type of pull request used for our changelog categories label Apr 24, 2017
const code = "if (true) return;";
const ast = babylon.parse(code, { allowReturnOutsideFunction: true });
const { code, map, ast } = babel.transformFromAst(ast, code, options);
const string = "if (true) return;";
Copy link
Member

Choose a reason for hiding this comment

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

We could call this sourceCode, what do you think?

const { code, map, ast } = babel.transformFromAst(ast, code, options);
const string = "if (true) return;";
const parsedAst = babylon.parse(string, { allowReturnOutsideFunction: true });
const { code, map, ast } = babel.transformFromAst(parsedAst, string, options);
Copy link
Member

Choose a reason for hiding this comment

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

This could be called generatedCode

@xtuc
Copy link
Member

xtuc commented Apr 24, 2017

Good catch and thanks for your PR. I added a few notes, could you tell me what do you think about it. The idea is too make the example as clear as possible.

@aretecode
Copy link
Contributor Author

@xtuc variable names that describe their intention is 👍 👌

const ast = babylon.parse(code, { allowReturnOutsideFunction: true });
const { code, map, ast } = babel.transformFromAst(ast, code, options);
const sourceCode = "if (true) return;";
const generatedCode = babylon.parse(sourceCode, { allowReturnOutsideFunction: true });
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, it's the ast, this was good. I meant the code variable above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xtina-starr that's the returned object property, can't be changed unless destructuring is removed. Main thing for this PR was just fixing the duplicated unclear variable name (now named as you suggested, sourceCode)

Copy link
Member

Choose a reason for hiding this comment

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

Yes sorry, that's correct (I don't believe I missed that)

@existentialism existentialism merged commit 8895828 into babel:7.0 Apr 25, 2017
@existentialism
Copy link
Member

@aretecode thanks!

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Docs 📝 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants