From cac1fde26e7fb99e1990d8a6b69a42682006c9d1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 22 Sep 2023 20:10:19 +0300 Subject: [PATCH] feature: @putout/engine-parser: babel: decoratorAutoAccessors --- packages/engine-parser/lib/parse.spec.js | 23 +++++++++++++++++++ .../lib/parsers/babel/plugins.js | 1 + 2 files changed, 24 insertions(+) diff --git a/packages/engine-parser/lib/parse.spec.js b/packages/engine-parser/lib/parse.spec.js index 8c8812d17e..92b60add3f 100644 --- a/packages/engine-parser/lib/parse.spec.js +++ b/packages/engine-parser/lib/parse.spec.js @@ -1,6 +1,9 @@ 'use strict'; const test = require('supertape'); +const montag = require('montag'); +const tryCatch = require('try-catch'); + const parse = require('./parse'); const generate = require('./generate'); const babel = require('./parsers/babel'); @@ -24,6 +27,26 @@ test('putout: engina-parser: tuple', (t) => { t.end(); }); +test('putout: engina-parser: babel: decoratorAutoAccessors', (t) => { + const source = montag` + class SomeClass { + @setMetadata + foo = 123; + + @setMetadata + accessor bar = "hello!"; + + @setMetadata + baz() { } + } + `; + + const [error] = tryCatch(parse, source); + + t.notOk(error); + t.end(); +}); + test('putout: engina-parser: parse + generate = sourcemap', (t) => { const source = `const hello = 'world';`; diff --git a/packages/engine-parser/lib/parsers/babel/plugins.js b/packages/engine-parser/lib/parsers/babel/plugins.js index 1444bb21fa..3f08c43737 100644 --- a/packages/engine-parser/lib/parsers/babel/plugins.js +++ b/packages/engine-parser/lib/parsers/babel/plugins.js @@ -9,6 +9,7 @@ module.exports = [ 'bigInt', 'classProperties', 'decorators-legacy', + 'decoratorAutoAccessors', 'destructuringPrivate', 'exportDefaultFrom', 'throwExpressions',