MarckK 8dffbf19d0 Codemod: remove unused catch binding (#6048)
* outline of plugin to remove unused catch binding, test not passing

* plugin to remove unused catch binding

* Edit README.md and package.json

* tests for try catch finally

* Add test to handle case when binding is referenced and given new TypeError (not passing)

* Fix visitor to not remove catch clause param when binding being assigned a new value

* Improve naming of tests and explanations

* add test case for catch param not present and fix test for duplicate variable declaration

* Remove binding.constantViolations filter in visitor as superfluous

* Remove duplicate check that catch clause param present

* Alter visitor so returns out when catch binding is not an Identifier

* Created failing tests for ObjectPattern params and rewrote visitor so now passing
Took out the pass in visitor when param not an Identifier, wrote case to handle when param isObjectPattern, and wrote failing tests for when param isArrayPattern

* Handle case when param isArrayPattern, tests passing

* Update package.json to  v7.0.0-alpha.20

* Revert visitor to only consider transform if param is Identifier
2017-09-19 15:38:17 -04:00

6 lines
171 B
JavaScript

try {
throw 0;
} catch (e) {
e = new TypeError('A new variable is not being declared or initialized; the catch binding is being referenced and cannot be removed.');
}