New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

putout

Package Overview
Dependencies
Maintainers
1
Versions
1245
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

putout - npm Package Compare versions

Comparing version 2.18.1 to 2.18.2

34

lib/get-vars/index.js

@@ -34,4 +34,2 @@ 'use strict';

//fixBabelObjectProperty(ast);
traverse(ast, getVars({

@@ -58,34 +56,2 @@ use,

// @babel/traverse uses ObjectProperty in ObjectPattern
// but according to standard Property should be used
// all other parsers use Property.
//
// Remove when this will be fixed
// https://github.com/babel/babel/issues/9251
// https://github.com/babel/babel/pull/9258
/*
function fixBabelObjectProperty(ast) {
traverse(ast, {
noScope: true,
FunctionExpression(path) {
console.log(path.node.loc);
},
ObjectMethod(path) {
console.log(path.node.loc);
},
enter(path) {
if (path.type === 'Property') {
path.node.type = 'ObjectProperty';
return;
}
if (path.type === 'FunctionExpression') {
path.node.type = 'ObjectMethod';
return;
}
},
});
}
*/
function getScopeNumber(name, scope) {

@@ -92,0 +58,0 @@ let done = false;

44

lib/putout.js

@@ -5,3 +5,4 @@ 'use strict';

const alignSpaces = require('align-spaces');
const babelParser = require('@babel/parser');
const cherow = require('cherow');
const toBabel = require('estree-to-babel');

@@ -16,3 +17,5 @@ const getVars = require('./get-vars');

parse(source) {
return babelParser.parse(source);
return toBabel(cherow.parse(source, {
loc: true,
}));
},

@@ -35,11 +38,8 @@ };

const {code} = recast.print(ast, {
trailingComma: true,
});
const {code} = recast.print(ast);
const aligned = alignSpaces(code);
const result = fixStrictMode(aligned);
return {
code: `${shebang}${result}`,
code: `${shebang}${aligned}`,
unused,

@@ -49,32 +49,2 @@ };

// when unused variable located in a root scope
// near 'use strict' directive
// it generates something like this:
//
// "use strict";;
//
// or
//
// "use strict";
// const nextVar = require('some');
//
// in case unused variable located in function scope
// such problem doesn't occure but
// there is no way to determine scope of a variable
// before generating result
//
// tests :
// - strict-mode
// - return-statement
//
// In case removing with function do not fail any test
// should be removed as soon as possible
function fixStrictMode(a) {
return a
.replace(';;', ';')
.replace(`'use strict';`, `'use strict';\n`)
.replace(`'use strict';\n\n\n`, `'use strict';\n\n`);
}
module.exports.parse = parse;

@@ -81,0 +51,0 @@ function parse(source) {

5

package.json
{
"name": "putout",
"version": "2.18.1",
"version": "2.18.2",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",

@@ -27,3 +27,2 @@ "description": "find and remove unused variables",

"dependencies": {
"@babel/parser": "^7.2.3",
"@babel/traverse": "^7.1.6",

@@ -33,2 +32,4 @@ "@babel/types": "^7.2.0",

"chalk": "^2.4.1",
"cherow": "^1.6.9",
"estree-to-babel": "^1.0.1",
"glob": "^7.1.3",

@@ -35,0 +36,0 @@ "recast": "^0.16.1",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc