Skip to content

Commit

Permalink
chore: package: v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Sep 6, 2022
1 parent 64c7c08 commit 2c20746
Show file tree
Hide file tree
Showing 4 changed files with 7,455 additions and 4,783 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2022.09.06, v1.2.0

feature:
- package: eslint-plugin-putout v16.2.1
- package: rollup-plugin-polyfill-node v0.10.2
- package: rollup-plugin-node-externals v5.0.0
- package: hermes-parser v0.9.0

2022.07.13, v1.1.6

fix:
Expand Down
56 changes: 32 additions & 24 deletions bundle/plugin-putout.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ function requireConvertBabelTypes () {
const {replaceWith} = operator;

const astRequire = template.ast(`
require('putout').types
`);
require('putout').types
`);

convertBabelTypes.report = () => {
return `"putout.types" should be used instead of "@babel/types"`;
Expand Down Expand Up @@ -846,8 +846,16 @@ function requireConvertNumberToNumeric () {
convertNumberToNumeric.report = () => `Use 'isNumericLiteral()' instead of 'isNumberLiteral()'`;

convertNumberToNumeric.fix = (path) => {
path.scope.rename('isNumberLiteral', 'isNumericLiteral');
path.scope.rename('NumberLiteral', 'NumericLiteral');
const bindings = path.scope.getAllBindings();
const {name} = path.node.callee;

if (!bindings.isNumericLiteral)
path.scope.rename('isNumberLiteral', 'isNumericLiteral');

if (!bindings.NumericLiteral)
path.scope.rename('NumberLiteral', 'NumericLiteral');

path.node.callee.name = name.replace('Number', 'Numeric');
};

convertNumberToNumeric.traverse = ({push}) => ({
Expand Down Expand Up @@ -1017,8 +1025,8 @@ function requireConvertReplaceWith () {

if (!bindings.replaceWithMultiple && !bindings.insertAfter && !isInserted()) {
const replaceWithAST = template.ast.fresh(`
const {replaceWith} = require('putout').operator;
`);
const {replaceWith} = require('putout').operator;
`);

const {types} = bindings;
const pathToInsertAfter = types ? types.path.parentPath : strictModePath;
Expand Down Expand Up @@ -1108,8 +1116,8 @@ function requireConvertReplaceWithMultiple () {
};

const replaceWithAST = template.ast(`
const {replaceWithMultiple} = require('putout').operate;
`);
const {replaceWithMultiple} = require('putout').operate;
`);

convertReplaceWithMultiple.fix = ({path, calleePath, property, object, program}) => {
const strictModePath = program.get('body.0');
Expand Down Expand Up @@ -2836,16 +2844,16 @@ function requireMoveRequireOnTopLevel () {
} = require$$0$1;

const TEST = `
const test = require('@putout/test')(__dirname, {
__a: __b
});
`;
const test = require('@putout/test')(__dirname, {
__a: __b
});
`;

const TRANSFORM = `
t.transform(__c, {
__a: __b
});
`;
t.transform(__c, {
__a: __b
});
`;

const {
Identifier,
Expand All @@ -2867,21 +2875,21 @@ function requireMoveRequireOnTopLevel () {
const value = __a.value || __a.name;

return `
const test = require('@putout/test')(__dirname, {
'${value}': ${name},
});
`;
const test = require('@putout/test')(__dirname, {
'${value}': ${name},
});
`;
},
[TRANSFORM]: (vars, path) => {
const name = declareRequire(vars, path);
const {__a} = vars;
const value = __a.value || __a.name;

return `
t.transform(__c, {
'${value}': ${name},
});
`;
t.transform(__c, {
'${value}': ${name},
});
`;
},
});

Expand Down
Loading

0 comments on commit 2c20746

Please sign in to comment.