Anna Henningsen
1ef78ca55b
Expand type definitions for path.{get,set}Data to cover symbols ( #13044 )
2021-03-24 14:04:13 +01:00
Nicolò Ribaudo
6ef7b51a11
Implement assumptions defined in the babel/rfcs#5 RFC
...
- `mutableTemplateObject` and `ignoreToPrimitiveHint` (#12408 )
- `setClassMethods` (#12407 )
- `setComputedProperties` (#12490 )
- `ignoreFunctionLength` (#12491 )
- `noDocumentAll` (#12481 )
- `iterableIsArray` and `arrayLikeIsIterable` (#12489 )
- `pureGetters` (#12504 )
- `skipForOfIteratorClosing` (#12496 )
- `objectRestNoSymbols`, `setSpreadProperties` and `pureGetters` (#12505 )
- `noNewArrows` (#12613 , #12793 )
- `setPublicClassFields` and `privateFieldsAsProperties` (#12497 )
- `constantReexports` and `enumerableModuleMeta` (#12618 )
- `constantSuper`, `superIsCallableConstructor` and `noClassCalls` (#12726 )
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
Co-authored-by: Huáng Jùnliàng <JLHwung@users.noreply.github.com>
2021-02-21 17:09:45 +01:00
overlookmotel
792672ec60
Fix scope of computed method keys ( #12812 )
...
* Fix scope of computed method keys
* Test for nested computed keys
* Fix scope.rename with computed method keys
* Optional chaining tests
2021-02-19 02:36:34 +01:00
Huáng Jùnliàng
4462eeae6b
Clean up traverse scope ( #12797 )
2021-02-16 23:23:34 +01:00
Bogdan Savluk
d98418efbe
Convert @babel/traverse to TypeScript ( #12488 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-01-24 01:33:09 +01:00
Zen
e08f68bf61
Skip discriminant when renaming starting from SwitchStatement ( #12530 )
2020-12-22 03:10:43 +01:00
Huáng Jùnliàng
ea2892fefc
add declare to class properties type annotations ( #12257 )
...
* add declare to class properties type annotations
* chore: use preset-flow
2020-10-27 10:05:01 -04:00
Huáng Jùnliàng
f697e7995d
Transform class static block ( #12143 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-10-14 21:16:24 +02:00
James Addison
94b5f92e39
Replace lodash 'defaults' usage with ES6 Spread initializer ( #11797 )
...
Co-authored-by: Corey Farrell <git@cfware.com>
2020-10-14 20:10:44 +02:00
Huáng Jùnliàng
e0b2bfb78f
fix: mark Pattern in CatchClause as scope ( #12119 )
2020-09-29 15:04:24 -04:00
James Addison
3e55270135
Reduce dependency on lodash functions: includes, uniq, repeat, isinteger ( #11790 )
...
* Replace lodash 'includes' usage with Array.prototype.includes
* Replace lodash 'values' usage with Object.values
* Replace lodash 'uniq' usage with Array.from(new Set(...))
* Property safety: ensure that ignoreSuites/ignoreTasks are populated prior to access
* Property safety: ensure that blacklistTypes is populated prior to access
* Revert "Replace lodash 'values' usage with Object.values"
This reverts commit 9fd3679d6db03066daee09fad0050e5292a32aa1.
* Replace lodash 'repeat' usage with String.prototype.repeat
* Replace lodash 'isinteger' usage with Number.isInteger
* Remove explicit lodash dependency from babel-generator package
* Update packages/babel-helper-transform-fixture-test-runner/src/index.js
Co-authored-by: Brian Ng <bng412@gmail.com>
* Rely on optional chaining operator as sole boolean check
* Handle additional optional chaining operator simplification
* Update type signature
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-07-06 09:27:41 +02:00
Wojciech Maj
1dd94e813e
Replace non-inclusive "whitelist" and "blacklist" terms with "allowlist" etc. ( #11758 )
2020-06-29 15:39:38 -04:00
任文龙
429840dc2b
scope.rename() missing identifier in VariableDeclarator ( #11595 )
2020-05-26 23:05:12 +02:00
Nicolò Ribaudo
93978267ec
Add "allowArrayLike" opt to destructuring and spread transforms ( #11265 )
2020-05-24 23:00:06 +02:00
Nicolò Ribaudo
31b361b736
Use ?. where it represents the intended semantics ( #11512 )
2020-05-09 23:31:50 +02:00
Zen
83d365acb6
handle objectMethod in scope.isPure ( #11482 )
2020-04-25 18:34:52 +02:00
Mateusz Burzyński
70cc111b35
Fixed generateUid creating clashing ids after scope re-crawling ( #11375 )
2020-04-07 17:32:46 +02:00
Mateusz Burzyński
aeebc08234
Simplify scope.hasReferences implementation ( #11368 )
2020-04-04 00:44:44 +02:00
Mateusz Burzyński
025e4ae44c
Fixed issue with programPath.scope.references not being regist… ( #11323 )
2020-03-24 16:27:32 +01:00
Justin Ridgewell
661ffbd830
Support more node types in generateUidBasedOnNode ( #11260 )
...
* Support more node types in generateUidBasedOnNode
* More nodes
2020-03-14 16:24:50 +01:00
Huáng Jùnliàng
afb0f489de
Enable more eslint recommended rules ( #11168 )
...
* chore: enable no-constant-condition
* chore: enable no-empty rule
* chore: enable no-unreachable
* chore: enable no-cond-assign
* chore: enable no-inner-declarations
* chore: remove disabled rules that are not in eslint:recommended
* fix: oops
2020-02-24 19:04:25 -05:00
Erlend Tobiassen
740064ced7
Fix missing ClassDeclaration references after scope#crawl ( #11011 )
...
* Bug replication test
* Simplify test
* Fixes #10896
* Merge path.crawl `ClassDeclaration` and `Declaration` visitors
Merged to avoid subtle assumption that `Declaration` is called before `ClassDeclaration`
* Move registartion of class id in crawl to BlockScoped
* Add some assertions to crawl test
2020-01-19 21:32:05 -05:00
Huáng Jùnliàng
fc5365fe4a
Fix parameter expression get binding ( #10912 )
...
* fix: parameter expression closure should not have access to the declaration inside function body
* fix: renameVisitor should skip when a pattern is a scope
* address review comments
2019-12-24 15:18:46 -05:00
Huáng Jùnliàng
5fb4d84a33
perf: always return void 0 as undefined node ( #10243 )
2019-08-01 09:53:40 +02:00
Nicolò Ribaudo
f195daa092
Don't add params of anonymous exported function decls to the outer scope ( #9613 )
...
* Don't add params of anonymous exported function decls to the outer scope
* Test
2019-03-01 00:09:49 +01:00
Nicolò Ribaudo
0345c1bc1d
Use for..of Object.keys instead of for..in ( #9518 )
...
In https://github.com/babel/babel/issues/9511 (and #9495 is another symptom), @PavelKastornyy reported a node crash becaue the JavaScript heap run out of memory. The problem was that their code was adding enumerable properties to `Object.prototype`: it is something that shouldn't be done, but Babel shouldn't make node crash if someone adds them.
I reduced down the problem to `for...in` loops in `@babel/traverse` that grew the memory consumption exponentially because of that unexpected properties.
2019-02-26 20:09:02 +01:00
Daniel Tschinder
b32d271fee
Migrate some duplicate binding tests to traverse ( #9532 )
...
* Migrate try-catch duplicate error
* Remove exception for functions and let in the same scope
* Migrate duplicate bindings tests to traverse
* Add test for subscope and let/const
* Add more test cases
2019-02-19 21:25:49 -08:00
Nicolò Ribaudo
911c2d0bf4
Use @babel/eslint-plugin-developement ( #9206 )
2018-12-18 22:59:43 +01:00
Logan Smyth
b04de1196a
Rename exported functions where name conflicts with param. ( #8505 )
2018-08-21 13:54:29 -07:00
Yongxu Ren
0fd3da110d
Rewrite Hub as interface #5047
2018-08-20 19:30:29 +02:00
Nicolò Ribaudo
3c46e75b8f
Don't split an exported class when renaming an inner binding ( #8051 )
2018-06-12 13:45:21 -04:00
Rubén Norte
bc6f0f989d
Re-add support for local Flow bindings (TypeAlias, OpaqueTypeAlias and Interface) ( #7900 )
2018-05-17 10:54:14 -07:00
Justin Ridgewell
21c7ff3f37
Classes cleanup ( #7737 )
...
* Cleanup
* Move verifyConstructorVisitor out of closure
2018-04-17 17:52:43 -04:00
Justin Ridgewell
43040a4181
Private Properties phase 1 ( #7666 )
...
* Private Properties phase 1
Co-authored-by: CodingItWrong
* Private fields are optional
* Docs update
2018-04-05 11:17:34 +01:00
Logan Smyth
4d76d5dddc
Refactor Babel's helpers into smaller functions.
2018-03-05 09:32:39 -08:00
Mateusz Burzyński
4d164bd8e6
Added babel-helper-split-export-declaration ( #7313 )
2018-02-13 16:44:05 +01:00
Nicolò Ribaudo
252ea5a966
Fix reused nodes - part 2 ( #7149 )
2018-01-29 22:59:06 +01:00
Mateusz Burzyński
912bcc186d
Fix reused nodes - part 1 ( #7149 )
2018-01-29 22:59:06 +01:00
Nicolò Ribaudo
9a231c5671
Remove support for flow bindings ( #6528 )
...
Flow bindings have been deprecated for a while.
The reason behind this change is that `declare var foo`
doesn't introduce a new local binding, but it represents
a global one.
2017-11-09 12:29:04 -08:00
Henry Zhu
cde0054227
Scoped: change src imports to @babel/ [skip ci]
2017-10-16 22:49:56 -04:00
JeromeFitz
ae168edcfa
Remove babel-messages ( #6347 ), continuation of #6352
...
package.json "babel-messages" removed:
- babel-core
- babel-helper-replace-supers
- babel-plugin-transform-es2015-classes
- babel-traverse
"messages" remove from:
- babel-plugin-check-es2015-constants/src/index.js
- babel-plugin-transform-es2015-for-of/src/index.js
export "babel-messages" removed from:
- babel-core/src/index.js
import "babel-messages" removed from:
- babel-generator/src/index.js
- babel-helper-replace-supers/src/index.js
- babel-traverse/src/index.js
- babel-traverse/src/scope/index.js
- babel-traverse/src/visitors.js
package "babel-messages" removed completely.
💯 ️ All tests pass.
2017-09-30 09:31:53 -04:00
Justin Ridgewell
3746273eda
Path#ensureBlock keeps path context ( #6337 )
...
* Path#ensureBlock keeps path context
This ensures that if you're inside an ArrowFunction with an expression body (say, you're on the BooleanLiteral in `() => true`), you don't suddenly lose your path context after inserting a variable.
This is because of 82d8aded8e (diff-9e0668ad44535be897b934e7077ecea5R14) . Basically, an innocent `Scope#push` caused my visitor to suddenly stop working. Now, we mutate the Path so it's still in the tree.
* Tests
2017-09-29 19:00:10 -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
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
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