Logan Smyth
20679979fc
Remove the unused 'scope' param from 'traverse.hasType'.
2017-09-12 16:48:05 -07:00
Henry Zhu
1c13250807
v7.0.0-beta.0
2017-09-11 23:01:41 -04:00
Justin Ridgewell
4daf11528c
Return inserted/replaced paths ( #5710 )
...
* Return inserted/replaced paths
This gives `Path`’s replacement and insertion methods a consistent
return value: the inserted/replaced paths.
Before, they could return `undefined`, a `node`, or a the current path
inside an array. It was kinda pointless. But now they always return an
array of paths, which is useful for solving
https://github.com/babel/babel/pull/4935#discussion_r96151368 .
* Return inserted nodes and not BlockStatement
Addded test for bug #4363
* Cleanups
- `#replaceWith` will now return the current path if it's the same node
- `#insertAfter` and `#insertBefore` use public Path APIs now
- Makes container insertion faster (single splice call)
- Use public APIs in container insertion
- Replacing a statement with an expression returns the expression's path
- Replacing an expression with multiple statements returns the inserted
closure's body's paths.
2017-09-11 16:07:04 -04:00
Ruben Verborgh
6560a29c36
Redeclaring a variable counts as a modification ( #6219 )
...
* Redeclaring a variable counts as a modification.
Fixes #6217 .
* Remove "existing" logic from Binding.
Was added in #5745 , but no longer triggered since 6536e605a.
2017-09-08 23:02:26 -04:00
Justin Ridgewell
5df70e6a94
Fix bad Scope#parent caching ( #6155 )
...
* Fix bad Scope#parent caching
Now, we traverse the path until we find a parent scope.
Fixes #6057 .
* Fix bad merge
* Remove cached data
* I need to stop using Github editor
* Fix infinite loops due to scopable paths being moved up
2017-09-02 01:03:10 -04:00
Daniel Tschinder
ca117e08cb
fix(requeue): Always requeue implicitely created BlockStatements ( #6193 )
...
This reverts the former fix done in #5743 and always requeues
BlockStatements when they get created.
This also fixes a bug in babel-generator which would indent code
even though no comments are present.
2017-09-02 01:02:21 -04:00
Daniel Tschinder
ab30fa54cb
Update debug to 3.0 ( #6184 )
2017-08-31 23:30:04 -04:00
Daniel Tschinder
44f6ff5e85
Update prettier, eslint + plugins, flow, husky and lint-staged ( #6183 )
2017-08-31 22:56:29 +02:00
Daniel Tschinder
0189b38702
Merge branch '6.x' into 7.0
...
# Conflicts:
# CONTRIBUTING.md
# Makefile
# README.md
# lerna.json
# lib/types.js
# package.json
# packages/babel-cli/package.json
# packages/babel-code-frame/package.json
# packages/babel-core/package.json
# packages/babel-core/test/fixtures/transformation/misc/regression-2892/expected.js
# packages/babel-generator/package.json
# packages/babel-generator/src/generators/flow.js
# packages/babel-generator/src/index.js
# packages/babel-generator/test/fixtures/flow/declare-statements/expected.js
# packages/babel-generator/test/fixtures/flow/object-literal-types/expected.js
# packages/babel-generator/test/fixtures/flow/opaque-type-alias/expected.js
# packages/babel-helper-bindify-decorators/package.json
# packages/babel-helper-builder-binary-assignment-operator-visitor/package.json
# packages/babel-helper-builder-conditional-assignment-operator-visitor/package.json
# packages/babel-helper-builder-react-jsx/package.json
# packages/babel-helper-call-delegate/package.json
# packages/babel-helper-define-map/package.json
# packages/babel-helper-explode-assignable-expression/package.json
# packages/babel-helper-explode-class/package.json
# packages/babel-helper-fixtures/package.json
# packages/babel-helper-function-name/package.json
# packages/babel-helper-get-function-arity/package.json
# packages/babel-helper-hoist-variables/package.json
# packages/babel-helper-optimise-call-expression/package.json
# packages/babel-helper-plugin-test-runner/package.json
# packages/babel-helper-regex/package.json
# packages/babel-helper-remap-async-to-generator/package.json
# packages/babel-helper-replace-supers/package.json
# packages/babel-helper-transform-fixture-test-runner/package.json
# packages/babel-helpers/package.json
# packages/babel-plugin-transform-async-generator-functions/package.json
# packages/babel-plugin-transform-async-to-generator/package.json
# packages/babel-plugin-transform-async-to-module-method/package.json
# packages/babel-plugin-transform-class-constructor-call/package.json
# packages/babel-plugin-transform-class-properties/package.json
# packages/babel-plugin-transform-decorators/package.json
# packages/babel-plugin-transform-es2015-block-scoping/package.json
# packages/babel-plugin-transform-es2015-classes/package.json
# packages/babel-plugin-transform-es2015-classes/test/fixtures/regression/T6755/expected.js
# packages/babel-plugin-transform-es2015-computed-properties/package.json
# packages/babel-plugin-transform-es2015-duplicate-keys/package.json
# packages/babel-plugin-transform-es2015-function-name/package.json
# packages/babel-plugin-transform-es2015-modules-amd/package.json
# packages/babel-plugin-transform-es2015-modules-commonjs/package.json
# packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js
# packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/interop/export-destructured/expected.js
# packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-object-default-params/expected.js
# packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-object-rest/expected.js
# packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-object/expected.js
# packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/strict/options.json
# packages/babel-plugin-transform-es2015-modules-systemjs/package.json
# packages/babel-plugin-transform-es2015-modules-umd/package.json
# packages/babel-plugin-transform-es2015-object-super/package.json
# packages/babel-plugin-transform-es2015-parameters/package.json
# packages/babel-plugin-transform-es2015-shorthand-properties/package.json
# packages/babel-plugin-transform-es2015-sticky-regex/package.json
# packages/babel-plugin-transform-es2015-unicode-regex/package.json
# packages/babel-plugin-transform-es5-property-mutators/package.json
# packages/babel-plugin-transform-exponentiation-operator/package.json
# packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/opaque-type-alias/expected.js
# packages/babel-plugin-transform-object-rest-spread/package.json
# packages/babel-plugin-transform-object-rest-spread/src/index.js
# packages/babel-plugin-transform-object-rest-spread/test/fixtures/object-rest/nested-2/expected.js
# packages/babel-plugin-transform-object-rest-spread/test/fixtures/object-rest/nested/expected.js
# packages/babel-plugin-transform-proto-to-assign/package.json
# packages/babel-plugin-transform-react-constant-elements/test/fixtures/constant-elements/regression-node-type-export-default/expected.js
# packages/babel-plugin-transform-react-constant-elements/test/fixtures/constant-elements/regression-node-type-export/expected.js
# packages/babel-plugin-transform-react-display-name/package.json
# packages/babel-plugin-transform-react-display-name/src/index.js
# packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/assignment-expression/expected.js
# packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/nested/expected.js
# packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/object-property/expected.js
# packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/variable-declarator/expected.js
# packages/babel-plugin-transform-react-jsx-compat/package.json
# packages/babel-plugin-transform-react-jsx/package.json
# packages/babel-plugin-transform-regenerator/package.json
# packages/babel-plugin-transform-regenerator/test/fixtures/regression/6733/expected.js
# packages/babel-plugin-transform-regenerator/test/fixtures/regression/T7041/expected.js
# packages/babel-plugin-transform-regenerator/test/fixtures/variable-renaming/retain-lines/expected.js
# packages/babel-plugin-transform-runtime/README.md
# packages/babel-plugin-transform-runtime/test/fixtures/runtime/custom-runtime/expected.js
# packages/babel-plugin-transform-runtime/test/fixtures/runtime/full/expected.js
# packages/babel-plugin-transform-runtime/test/fixtures/runtime/regenerator-runtime/expected.js
# packages/babel-plugin-transform-strict-mode/package.json
# packages/babel-polyfill/package.json
# packages/babel-preset-es2015/package.json
# packages/babel-preset-es2016/package.json
# packages/babel-preset-es2017/package.json
# packages/babel-preset-latest/package.json
# packages/babel-preset-react/package.json
# packages/babel-preset-stage-0/package.json
# packages/babel-preset-stage-1/package.json
# packages/babel-preset-stage-2/package.json
# packages/babel-preset-stage-3/package.json
# packages/babel-register/README.md
# packages/babel-register/package.json
# packages/babel-runtime/package.json
# packages/babel-template/package.json
# packages/babel-traverse/package.json
# packages/babel-traverse/src/scope/lib/renamer.js
# packages/babel-traverse/test/evaluation.js
# packages/babel-traverse/test/replacement.js
# packages/babel-types/README.md
# packages/babel-types/package.json
# packages/babel-types/src/converters.js
# packages/babel-types/src/definitions/core.js
# packages/babel-types/src/definitions/es2015.js
# packages/babel-types/src/definitions/flow.js
# packages/babel-types/test/converters.js
# packages/babel-types/test/validators.js
# scripts/generate-interfaces.js
# yarn.lock
2017-08-31 17:44:17 +02:00
Henry Zhu
b82b65a31e
v7.0.0-alpha.20
2017-08-30 15:02:49 -04:00
Henry Zhu
0a4f1b0a6e
update babylon beta.22 ( #6167 )
2017-08-29 17:53:29 -04:00
Buu Nguyen
75861fac87
Fix bug replacement nodes not requeued ( #5743 )
2017-08-28 15:10:00 -06:00
Henry Zhu
827d84536a
Merge pull request #6156 from jridgewell/pr/5502
...
Fix overshadowing local binding
2017-08-28 13:38:21 -06:00
Justin Ridgewell
ac6eda2709
Class instance properties define their own context ( #6158 )
2017-08-28 12:47:17 -06:00
Justin Ridgewell
4b297907d1
Move fix into #checkBlockScopedCollisions
2017-08-25 19:23:11 -04:00
Moti Zilberman
48c114169f
Move up check for binding kind "local"
...
This puts the check before the call to `checkBlockScopedCollisions`.
Fixes #4946 .
2017-08-25 19:21:38 -04:00
Moti Zilberman
c3e8715010
Mask existing "local" bindings when registering new binding
...
Fixes #5491 .
2017-08-25 19:21:38 -04:00
Mauro Bringolf
d8b4073536
Consistent const violations ( #6100 )
...
* Changed updateExpression to report itself as violation instead of its argument
* Update getBindingIdentifiers to work with forXStatement and return proper node as violation
* Updated unaryExpression violation to be consistent with changes.
2017-08-24 21:19:02 -04:00
Henry Zhu
cee4cde53e
v6.26.0
2017-08-16 11:54:08 -04:00
Henry Zhu
5749276d7e
update deps
2017-08-16 10:21:19 -04:00
jbrown215
c28465e03e
Flow opaque type 6.x backport ( #6081 )
...
* Flow opaque type backport
* Add tests for strip types, comments, and babel-generator
* Fix failing tests, run scripts
* Bump babylon to 6.18.0
2017-08-15 16:44:15 -04:00
Justin Ridgewell
4ca686b7be
Fix relative execution location introspection ( #5741 )
...
So, I was reading the new Flow type strictness and noticed
https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/
Specifically, I wondered whether the `sum_all` example would copy the
arguments into an array, then loop over. Sadly, it does.
```js
function sum_all(...rest) {
let ret = 0;
for (let i = 0; i < rest.length; i++) { ret += rest[i]; }
return ret;
}
// output
function sum_all() {
var ret = 0;
for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
rest[_key] = arguments[_key];
}
for (var i = 0; i < rest.length; i++) { ret += rest[i]; }
return ret;
}
```
But then I noticed if I changed `let i = 0` to `let i: number = 0`, it
worked directly on `arguments`. That lead me down a rabbit hole to
`Path#_guessExecutionStatusRelativeTo`. When tracing through, the last
comparison made no sense to me. It was trying to find the index of
`"init"` in a list of `["declarations"]` and `"body"` in `["directives",
"body"]`. Red flags and such.
But it makes sense when you're trying to compare the visitor order of
the common ancestor path. Then we're trying to find `"init"` in a list
of `["init", "test", "update", "body"]`. Oh, and there's `"body"` in
there too! And now we know the `ForStatement`'s `init` is executed
before the `body`.
2017-08-14 22:22:18 -04:00
Henry Zhu
79f4956948
v7.0.0-alpha.19
2017-08-07 18:21:08 -04:00
Henry Zhu
47a9ba3440
Merge pull request #6051 from babel/5709-2
...
Rewrite parameter transform and drop _blockHoist reliance
2017-08-04 18:55:23 -04:00
Henry Zhu
a1debae8f0
babylon beta.19 ( #6053 )
2017-08-04 14:46:12 -04:00
Logan Smyth
8e19a5b057
Update param scope values when expanding parameters.
2017-08-03 20:56:24 -05:00
Henry Zhu
79c6814d65
v7.0.0-alpha.18
2017-08-03 18:20:36 -04:00
Sarup Banskota
75808a2d14
Prevent getFunctionParent from returning Program ( #5923 )
2017-08-02 16:30:33 -05:00
Henry Zhu
0f823beeb1
Newlines in fixtures ( #6044 )
...
* write newlines for fixtures
* rerun fixtures
2017-08-02 15:35:29 -04:00
Jimmy Jia
2dba910b9e
Merge branch '6.x'
2017-07-29 12:20:18 -04:00
Henry Zhu
9322fd0458
v7.0.0-alpha.17
2017-07-26 08:38:44 -04:00
Henry Zhu
f01438e9b1
update devdeps to latest, update babylon ( #6012 )
...
* temporary flow strip measure
2017-07-26 07:57:49 -04:00
Henry Zhu
7f1cd44d60
v7.0.0-alpha.16
2017-07-25 17:35:35 -04:00
MarckK
9fc910d8c0
Add optionality to catch bindings ( #5956 )
2017-07-25 09:38:48 -05:00
Peeyush Kushwaha
2225892348
Use first binding for multiple var declarations ( #5745 )
...
* Use first binding for multiple var declarations
Since var declarations after initial binding have no effect, use the
first declaration. Fixes #2378
* Include hoisted function bindings
* Missing newline in expected.js
* Simplify constantViolations in new Binding on existing
* clarify comment language
2017-07-24 14:43:17 -04:00
Daniel Tschinder
b9ed9919c1
Update globals to v10 ( #5993 )
2017-07-23 09:21:08 -04:00
Justin Ridgewell
8a98141b60
Fix a few type inferences ( #5835 )
2017-07-20 11:38:12 -04:00
Marcus Cavanaugh
fe13ba8fc2
Remove unused functions from renamer.js. ( #5965 )
2017-07-20 11:19:10 -04:00
Justin Ridgewell
63204ae51e
Remove maybePopFromStatements ( #5945 )
...
It prevented you from pushing into the `params` of a function.
```js
fnpath.pushContainer("params", t.identifier("memo"))
```
2017-07-18 14:55:33 -04:00
Justin Ridgewell
28ae47a174
Stop mutating nodes ( #5963 )
...
* Stop mutating nodes
* Update tests
* linting
2017-07-18 13:24:07 -04:00
Henry Zhu
a0f0411abf
v7.0.0-alpha.15
2017-07-11 23:35:22 -04:00
Henry Zhu
03f249430a
v7.0.0-alpha.14
2017-07-11 22:53:09 -04:00
Henry Zhu
8460b4c62f
v7.0.0-alpha.13
2017-07-11 22:27:56 -04:00
Ash
960e1708a1
babel-traverse: Mark appropriate template literals as pure ( #5914 )
...
* Identify pure template literals
* Mark template literals as pure where possible
* Changes based on code review
* nit
2017-07-11 17:42:34 -04:00
Daniel Tschinder
b3372a572d
Remove whitespace generation ( #5833 )
...
* Remove whitespace generation and rely on default printing
Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines
* Fix a few more fixtures
2017-06-27 21:57:02 -05:00
Henry Zhu
a4080dc095
update babylon
2017-06-27 17:17:41 -04:00
Brian Ng
e4b35f680d
Run prettier
2017-06-27 12:15:00 -05:00
Henry Zhu
89d8f70fcd
Merge pull request #5813 from jridgewell/pr/5786
...
Optional Chaining Operator (Stage 1)
2017-06-27 11:10:47 -04:00
Joseph Frazier
a330cf2b09
Add support for evaluating String.raw expressions ( #5681 )
...
* Add support for evaluating `String.raw` expressions
* Dedupe evaluation code for template literal quasis
* Check scoping in `String.raw` evaluation
This addresses https://github.com/babel/babel/pull/5681#discussion_r114203497
* Ensure that `tag` is a MemberExpression in `String.raw` evaluation
This addresses https://github.com/babel/babel/pull/5681#discussion_r114203555
* babel-traverse: Move evaluateQuasis() outside _evaluate()
2017-06-24 16:00:42 -04:00
Henry Zhu
ba671d0a66
update babel-eslint, try out numeric separators ( #5866 )
...
* update babel-eslint, try out numeric separators
* update version
2017-06-17 23:31:47 -04:00