From e69a47210fbe042add1b695497ce78c23e35622c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 12 Apr 2024 16:02:56 +0300 Subject: [PATCH] feature: redput: @putout/plugin-declare-before-reference v3.0.0 --- lib/write/nested/prepare-rule/prepare-rule.js | 2 ++ .../nested/prepare-rule/prepare-rule.spec.js | 17 +++++++++++++++++ package.json | 1 + 3 files changed, 20 insertions(+) diff --git a/lib/write/nested/prepare-rule/prepare-rule.js b/lib/write/nested/prepare-rule/prepare-rule.js index 693a713..384a599 100644 --- a/lib/write/nested/prepare-rule/prepare-rule.js +++ b/lib/write/nested/prepare-rule/prepare-rule.js @@ -2,11 +2,13 @@ import putout from 'putout'; import convertESMToCommonjs from '@putout/plugin-convert-esm-to-commonjs'; import putoutPlugin from '@putout/plugin-putout'; import declare from '@putout/plugin-declare'; +import declareBeforeReference from '@putout/plugin-declare-before-reference'; export const prepareRule = (source) => { const {code} = putout(source, { plugins: [ ['declare', declare], + ['declare-before-reference', declareBeforeReference], ['convert-esm-to-commonjs', convertESMToCommonjs], ['putout', putoutPlugin], ], diff --git a/lib/write/nested/prepare-rule/prepare-rule.spec.js b/lib/write/nested/prepare-rule/prepare-rule.spec.js index 51423bd..bace209 100644 --- a/lib/write/nested/prepare-rule/prepare-rule.spec.js +++ b/lib/write/nested/prepare-rule/prepare-rule.spec.js @@ -15,3 +15,20 @@ test('redput: prepareRule', (t) => { t.equal(result, expected); t.end(); }); + +test('redput: prepareRule: declare-before-reference', (t) => { + const source = montag` + const {getTemplateValues} = operator; + const {operator} = require('putout'); + `; + + const result = prepareRule(source); + const expected = montag` + const {operator} = require('putout'); + const {getTemplateValues} = operator; + + `; + + t.equal(result, expected); + t.end(); +}); diff --git a/package.json b/package.json index 414eb57..975afe3 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "dependencies": { "@putout/plugin-convert-esm-to-commonjs": "^6.0.0", "@putout/plugin-declare": "^3.0.0", + "@putout/plugin-declare-before-reference": "^3.0.0", "@putout/plugin-nodejs": "^11.0.0", "@putout/plugin-putout": "^18.0.0", "@putout/plugin-remove-unused-variables": "^8.0.0",