From 8fab49ed2f229b6ec9858fe3000204b600b1cc73 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Fri, 7 Oct 2016 15:24:11 +0100 Subject: [PATCH] add babel-plugin-transform-class-properties to class-properties babel fixtures - using only babel-plugin-syntax-class-properties produces invalid output --- .../fixtures/class-properties/arguments/.babelrc | 2 +- .../class-properties/arguments/expected.js | 12 +++++++----- .../async-functions-expression-body/.babelrc | 4 ++-- .../async-functions-expression-body/expected.js | 6 +++--- .../class-properties/async-functions/.babelrc | 4 ++-- .../class-properties/async-functions/expected.js | 6 +++--- .../fixtures/class-properties/block-body/.babelrc | 2 +- .../class-properties/block-body/expected.js | 6 +++--- .../class-properties/default-params/.babelrc | 2 +- .../class-properties/default-params/expected.js | 6 +++--- .../class-properties/destructured-params/.babelrc | 2 +- .../destructured-params/expected.js | 6 +++--- .../class-properties/expression-body/.babelrc | 2 +- .../class-properties/expression-body/expected.js | 6 +++--- .../class-properties/nested-arguments/.babelrc | 2 +- .../class-properties/nested-arguments/expected.js | 14 ++++++++------ .../class-properties/nested-new.target/.babelrc | 2 +- .../class-properties/nested-new.target/expected.js | 13 ++++++++----- .../fixtures/class-properties/new.target/.babelrc | 2 +- .../class-properties/new.target/expected.js | 11 +++++++---- .../class-properties/not-a-function/.babelrc | 2 +- .../class-properties/not-a-function/expected.js | 5 ++++- .../not-an-arrow-function/.babelrc | 2 +- .../not-an-arrow-function/expected.js | 9 ++++++--- .../same-name-as-class-method/.babelrc | 2 +- .../same-name-as-class-method/expected.js | 6 +++--- .../class-properties/static-property/.babelrc | 2 +- .../class-properties/static-property/expected.js | 11 ++++++----- 28 files changed, 83 insertions(+), 66 deletions(-) diff --git a/test/babel/fixtures/class-properties/arguments/.babelrc b/test/babel/fixtures/class-properties/arguments/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/arguments/.babelrc +++ b/test/babel/fixtures/class-properties/arguments/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/arguments/expected.js b/test/babel/fixtures/class-properties/arguments/expected.js index 985d899a1..99835ee0a 100644 --- a/test/babel/fixtures/class-properties/arguments/expected.js +++ b/test/babel/fixtures/class-properties/arguments/expected.js @@ -1,10 +1,12 @@ -var _arguments = arguments; class Foo { - bar = (a, b) => { - _arguments; + constructor() { + this.bar = (a, b) => { + arguments; + + return a(b); + }; + } - return a(b); - }; } ; diff --git a/test/babel/fixtures/class-properties/async-functions-expression-body/.babelrc b/test/babel/fixtures/class-properties/async-functions-expression-body/.babelrc index a86136fec..9f1e1af4b 100644 --- a/test/babel/fixtures/class-properties/async-functions-expression-body/.babelrc +++ b/test/babel/fixtures/class-properties/async-functions-expression-body/.babelrc @@ -1,7 +1,7 @@ { "plugins": [ + "../../../../../src/babel", + "transform-class-properties", "syntax-async-functions", - "syntax-class-properties", - "../../../../../src/babel" ] } diff --git a/test/babel/fixtures/class-properties/async-functions-expression-body/expected.js b/test/babel/fixtures/class-properties/async-functions-expression-body/expected.js index 81b2e5e7c..5033e6987 100644 --- a/test/babel/fixtures/class-properties/async-functions-expression-body/expected.js +++ b/test/babel/fixtures/class-properties/async-functions-expression-body/expected.js @@ -1,7 +1,7 @@ -var _this = this; - class Foo { - bar = async (...params) => await _this.__bar__REACT_HOT_LOADER__(...params); + constructor() { + this.bar = async (...params) => await this.__bar__REACT_HOT_LOADER__(...params); + } async __bar__REACT_HOT_LOADER__(a, b) { return await b(a); diff --git a/test/babel/fixtures/class-properties/async-functions/.babelrc b/test/babel/fixtures/class-properties/async-functions/.babelrc index a86136fec..9f1e1af4b 100644 --- a/test/babel/fixtures/class-properties/async-functions/.babelrc +++ b/test/babel/fixtures/class-properties/async-functions/.babelrc @@ -1,7 +1,7 @@ { "plugins": [ + "../../../../../src/babel", + "transform-class-properties", "syntax-async-functions", - "syntax-class-properties", - "../../../../../src/babel" ] } diff --git a/test/babel/fixtures/class-properties/async-functions/expected.js b/test/babel/fixtures/class-properties/async-functions/expected.js index ba0c41e8b..4bc37895a 100644 --- a/test/babel/fixtures/class-properties/async-functions/expected.js +++ b/test/babel/fixtures/class-properties/async-functions/expected.js @@ -1,7 +1,7 @@ -var _this = this; - class Foo { - bar = async (...params) => await _this.__bar__REACT_HOT_LOADER__(...params); + constructor() { + this.bar = async (...params) => await this.__bar__REACT_HOT_LOADER__(...params); + } async __bar__REACT_HOT_LOADER__(a, b) { return await a(b); diff --git a/test/babel/fixtures/class-properties/block-body/.babelrc b/test/babel/fixtures/class-properties/block-body/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/block-body/.babelrc +++ b/test/babel/fixtures/class-properties/block-body/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/block-body/expected.js b/test/babel/fixtures/class-properties/block-body/expected.js index 894278fc2..fa7ebdee5 100644 --- a/test/babel/fixtures/class-properties/block-body/expected.js +++ b/test/babel/fixtures/class-properties/block-body/expected.js @@ -1,7 +1,7 @@ -var _this = this; - class Foo { - bar = (...params) => _this.__bar__REACT_HOT_LOADER__(...params); + constructor() { + this.bar = (...params) => this.__bar__REACT_HOT_LOADER__(...params); + } __bar__REACT_HOT_LOADER__(a, b) { return a(b); diff --git a/test/babel/fixtures/class-properties/default-params/.babelrc b/test/babel/fixtures/class-properties/default-params/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/default-params/.babelrc +++ b/test/babel/fixtures/class-properties/default-params/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/default-params/expected.js b/test/babel/fixtures/class-properties/default-params/expected.js index 19f8f34c6..ddd573435 100644 --- a/test/babel/fixtures/class-properties/default-params/expected.js +++ b/test/babel/fixtures/class-properties/default-params/expected.js @@ -1,7 +1,7 @@ -var _this = this; - class Foo { - bar = (...params) => _this.__bar__REACT_HOT_LOADER__(...params); + constructor() { + this.bar = (...params) => this.__bar__REACT_HOT_LOADER__(...params); + } __bar__REACT_HOT_LOADER__(a = "foo") { return `${ a }bar`; diff --git a/test/babel/fixtures/class-properties/destructured-params/.babelrc b/test/babel/fixtures/class-properties/destructured-params/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/destructured-params/.babelrc +++ b/test/babel/fixtures/class-properties/destructured-params/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/destructured-params/expected.js b/test/babel/fixtures/class-properties/destructured-params/expected.js index 7916cc25f..7c4dac820 100644 --- a/test/babel/fixtures/class-properties/destructured-params/expected.js +++ b/test/babel/fixtures/class-properties/destructured-params/expected.js @@ -1,7 +1,7 @@ -var _this = this; - class Foo { - bar = (...params) => _this.__bar__REACT_HOT_LOADER__(...params); + constructor() { + this.bar = (...params) => this.__bar__REACT_HOT_LOADER__(...params); + } __bar__REACT_HOT_LOADER__({ a }, { b }) { return `${ a }${ b }`; diff --git a/test/babel/fixtures/class-properties/expression-body/.babelrc b/test/babel/fixtures/class-properties/expression-body/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/expression-body/.babelrc +++ b/test/babel/fixtures/class-properties/expression-body/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/expression-body/expected.js b/test/babel/fixtures/class-properties/expression-body/expected.js index 4ac9d1755..ced1724a1 100644 --- a/test/babel/fixtures/class-properties/expression-body/expected.js +++ b/test/babel/fixtures/class-properties/expression-body/expected.js @@ -1,7 +1,7 @@ -var _this = this; - class Foo { - onClick = (...params) => _this.__onClick__REACT_HOT_LOADER__(...params); + constructor() { + this.onClick = (...params) => this.__onClick__REACT_HOT_LOADER__(...params); + } __onClick__REACT_HOT_LOADER__(e) { return e.target.value; diff --git a/test/babel/fixtures/class-properties/nested-arguments/.babelrc b/test/babel/fixtures/class-properties/nested-arguments/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/nested-arguments/.babelrc +++ b/test/babel/fixtures/class-properties/nested-arguments/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/nested-arguments/expected.js b/test/babel/fixtures/class-properties/nested-arguments/expected.js index ceaf67be1..86cf53ea8 100644 --- a/test/babel/fixtures/class-properties/nested-arguments/expected.js +++ b/test/babel/fixtures/class-properties/nested-arguments/expected.js @@ -1,12 +1,14 @@ -var _arguments = arguments; class Foo { - bar = (a, b) => { - () => { - _arguments; + constructor() { + this.bar = (a, b) => { + () => { + arguments; + }; + + return a(b); }; + } - return a(b); - }; } ; diff --git a/test/babel/fixtures/class-properties/nested-new.target/.babelrc b/test/babel/fixtures/class-properties/nested-new.target/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/nested-new.target/.babelrc +++ b/test/babel/fixtures/class-properties/nested-new.target/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/nested-new.target/expected.js b/test/babel/fixtures/class-properties/nested-new.target/expected.js index fa479c403..cf4ad1552 100644 --- a/test/babel/fixtures/class-properties/nested-new.target/expected.js +++ b/test/babel/fixtures/class-properties/nested-new.target/expected.js @@ -1,11 +1,14 @@ class Foo { - bar = (a, b) => { - () => { - new.target; + constructor() { + this.bar = (a, b) => { + () => { + new.target; + }; + + return a(b); }; + } - return a(b); - }; } ; diff --git a/test/babel/fixtures/class-properties/new.target/.babelrc b/test/babel/fixtures/class-properties/new.target/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/new.target/.babelrc +++ b/test/babel/fixtures/class-properties/new.target/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/new.target/expected.js b/test/babel/fixtures/class-properties/new.target/expected.js index 16311e162..8fe6cc9ca 100644 --- a/test/babel/fixtures/class-properties/new.target/expected.js +++ b/test/babel/fixtures/class-properties/new.target/expected.js @@ -1,9 +1,12 @@ class Foo { - bar = (a, b) => { - new.target; + constructor() { + this.bar = (a, b) => { + new.target; + + return a(b); + }; + } - return a(b); - }; } ; diff --git a/test/babel/fixtures/class-properties/not-a-function/.babelrc b/test/babel/fixtures/class-properties/not-a-function/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/not-a-function/.babelrc +++ b/test/babel/fixtures/class-properties/not-a-function/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/not-a-function/expected.js b/test/babel/fixtures/class-properties/not-a-function/expected.js index 6e2cf5432..8eebee8ab 100644 --- a/test/babel/fixtures/class-properties/not-a-function/expected.js +++ b/test/babel/fixtures/class-properties/not-a-function/expected.js @@ -1,5 +1,8 @@ class Foo { - bar = 2; + constructor() { + this.bar = 2; + } + } ; diff --git a/test/babel/fixtures/class-properties/not-an-arrow-function/.babelrc b/test/babel/fixtures/class-properties/not-an-arrow-function/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/not-an-arrow-function/.babelrc +++ b/test/babel/fixtures/class-properties/not-an-arrow-function/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/not-an-arrow-function/expected.js b/test/babel/fixtures/class-properties/not-an-arrow-function/expected.js index 3799c87a6..ea5674d51 100644 --- a/test/babel/fixtures/class-properties/not-an-arrow-function/expected.js +++ b/test/babel/fixtures/class-properties/not-an-arrow-function/expected.js @@ -1,7 +1,10 @@ class Foo { - bar = function (a, b) { - return a(b); - }; + constructor() { + this.bar = function (a, b) { + return a(b); + }; + } + } ; diff --git a/test/babel/fixtures/class-properties/same-name-as-class-method/.babelrc b/test/babel/fixtures/class-properties/same-name-as-class-method/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/same-name-as-class-method/.babelrc +++ b/test/babel/fixtures/class-properties/same-name-as-class-method/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/same-name-as-class-method/expected.js b/test/babel/fixtures/class-properties/same-name-as-class-method/expected.js index 50173acae..9bcc53586 100644 --- a/test/babel/fixtures/class-properties/same-name-as-class-method/expected.js +++ b/test/babel/fixtures/class-properties/same-name-as-class-method/expected.js @@ -1,7 +1,7 @@ -var _this = this; - class Foo { - bar = (...params) => _this.__bar__REACT_HOT_LOADER__(...params); + constructor() { + this.bar = (...params) => this.__bar__REACT_HOT_LOADER__(...params); + } __bar__REACT_HOT_LOADER__(a, b) { return a(b); diff --git a/test/babel/fixtures/class-properties/static-property/.babelrc b/test/babel/fixtures/class-properties/static-property/.babelrc index 4075556b7..3d663018a 100644 --- a/test/babel/fixtures/class-properties/static-property/.babelrc +++ b/test/babel/fixtures/class-properties/static-property/.babelrc @@ -1,3 +1,3 @@ { - "plugins": ["syntax-class-properties", "../../../../../src/babel"] + "plugins": ["../../../../../src/babel", "transform-class-properties"] } diff --git a/test/babel/fixtures/class-properties/static-property/expected.js b/test/babel/fixtures/class-properties/static-property/expected.js index c3da49e95..d4ded03aa 100644 --- a/test/babel/fixtures/class-properties/static-property/expected.js +++ b/test/babel/fixtures/class-properties/static-property/expected.js @@ -1,8 +1,9 @@ -class Foo { - static bar = (a, b) => { - return a(b); - }; -} +class Foo {} + +Foo.bar = (a, b) => { + return a(b); +}; + ; var _temp = function () {