Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-sitrep

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-sitrep - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

src/__tests__/.babelrc

3

package.json
{
"name": "babel-plugin-sitrep",
"version": "1.2.1",
"version": "1.2.2",
"description": "Log all assignments and the return value of a function with a simple comment",

@@ -24,2 +24,3 @@ "main": "src/index.js",

"babel-plugin-tester": "^4.0.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"jest": "^20.0.4",

@@ -26,0 +27,0 @@ "jest-cli": "^20.0.4",

@@ -197,4 +197,21 @@ const pluginTester = require('babel-plugin-tester')

`
},
{
title: 'class property',
code: `
class Foo {
// sitrep
handleClick = (e) =>{
const foo = e.target.innerText;
// some actions based on foo
e.preventDefault()
}
}
`,
babelOptions: {
babelrc: true,
filename: __filename
}
}
]
})

@@ -27,3 +27,3 @@ module.exports = function (babel) {

logCallee,
thing.name && thing.name.includes('returnValue')
thing.name && thing.name.indexOf('returnValue') > -1
? [t.stringLiteral('Return Value:'), thing]

@@ -35,2 +35,8 @@ : thing.name ? [t.stringLiteral(`${thing.name}: `), thing] : [thing]

function getName (path) {
if (path.parentPath.isClassProperty()) {
if (path.parentPath.node.key && t.isIdentifier(path.parentPath.node.key)) {
return path.parentPath.node.key.name
}
}
if (path.node.id && path.node.id.name) {

@@ -53,6 +59,2 @@ return path.node.id.name

function functionVisitor (functionPath, state) {
if (functionPath.isArrowFunctionExpression()) {
return
}
let name = getName(functionPath)

@@ -102,3 +104,5 @@ functionPath

variableDeclPath.insertAfter(t.expressionStatement(createLogStatement(dec.id)))
variableDeclPath.insertAfter(
t.expressionStatement(createLogStatement(dec.id))
)
})

@@ -142,2 +146,15 @@ },

visitor: {
Class (path, state) {
path.traverse({
ClassProperty (path) {
if (hasSitrepComments(getComments(path.node), state.opts.label)) {
path.traverse({
Function (path) {
functionVisitor(path, state)
}
})
}
}
})
},
Function (path, state) {

@@ -144,0 +161,0 @@ if (hasSitrepComments(getComments(path.node), state.opts.label)) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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