Skip to content

Commit

Permalink
feature: redput: @putout/plugin-declare-before-reference v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Apr 12, 2024
1 parent 4aa6489 commit e69a472
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/write/nested/prepare-rule/prepare-rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
],
Expand Down
17 changes: 17 additions & 0 deletions lib/write/nested/prepare-rule/prepare-rule.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e69a472

Please sign in to comment.