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.1.0 to 1.1.1

2

coverage/coverage-final.json

@@ -1,2 +0,2 @@

{"/Users/kye/github/babel-plugin-sitrep/src/index.js": {"path":"/Users/kye/github/babel-plugin-sitrep/src/index.js","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":90,"column":1}},"1":{"start":{"line":2,"column":23},"end":{"line":2,"column":28}},"2":{"start":{"line":3,"column":20},"end":{"line":7,"column":3}},"3":{"start":{"line":10,"column":4},"end":{"line":10,"column":47}},"4":{"start":{"line":14,"column":4},"end":{"line":14,"column":58}},"5":{"start":{"line":14,"column":30},"end":{"line":14,"column":57}},"6":{"start":{"line":18,"column":4},"end":{"line":23,"column":5}},"7":{"start":{"line":26,"column":15},"end":{"line":63,"column":3}},"8":{"start":{"line":28,"column":6},"end":{"line":30,"column":7}},"9":{"start":{"line":33,"column":20},"end":{"line":33,"column":42}},"10":{"start":{"line":34,"column":6},"end":{"line":52,"column":8}},"11":{"start":{"line":35,"column":8},"end":{"line":49,"column":9}},"12":{"start":{"line":36,"column":10},"end":{"line":47,"column":12}},"13":{"start":{"line":37,"column":12},"end":{"line":46,"column":13}},"14":{"start":{"line":48,"column":10},"end":{"line":48,"column":16}},"15":{"start":{"line":51,"column":8},"end":{"line":51,"column":75}},"16":{"start":{"line":55,"column":17},"end":{"line":55,"column":64}},"17":{"start":{"line":56,"column":6},"end":{"line":60,"column":7}},"18":{"start":{"line":61,"column":6},"end":{"line":61,"column":29}},"19":{"start":{"line":65,"column":2},"end":{"line":89,"column":3}},"20":{"start":{"line":69,"column":16},"end":{"line":69,"column":40}},"21":{"start":{"line":70,"column":8},"end":{"line":72,"column":9}},"22":{"start":{"line":71,"column":10},"end":{"line":71,"column":16}},"23":{"start":{"line":74,"column":8},"end":{"line":76,"column":9}},"24":{"start":{"line":75,"column":10},"end":{"line":75,"column":29}},"25":{"start":{"line":79,"column":8},"end":{"line":86,"column":9}},"26":{"start":{"line":80,"column":10},"end":{"line":82,"column":11}},"27":{"start":{"line":81,"column":12},"end":{"line":81,"column":54}},"28":{"start":{"line":83,"column":10},"end":{"line":85,"column":11}},"29":{"start":{"line":84,"column":12},"end":{"line":84,"column":31}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":1,"column":17},"end":{"line":1,"column":18}},"loc":{"start":{"line":1,"column":33},"end":{"line":90,"column":1}},"line":1},"1":{"name":"getComments","decl":{"start":{"line":9,"column":11},"end":{"line":9,"column":22}},"loc":{"start":{"line":9,"column":29},"end":{"line":11,"column":3}},"line":9},"2":{"name":"hasSitrepComments","decl":{"start":{"line":13,"column":11},"end":{"line":13,"column":28}},"loc":{"start":{"line":13,"column":39},"end":{"line":15,"column":3}},"line":13},"3":{"name":"(anonymous_3)","decl":{"start":{"line":14,"column":25},"end":{"line":14,"column":26}},"loc":{"start":{"line":14,"column":30},"end":{"line":14,"column":57}},"line":14},"4":{"name":"createLogStatement","decl":{"start":{"line":17,"column":11},"end":{"line":17,"column":29}},"loc":{"start":{"line":17,"column":37},"end":{"line":24,"column":3}},"line":17},"5":{"name":"(anonymous_5)","decl":{"start":{"line":34,"column":20},"end":{"line":34,"column":21}},"loc":{"start":{"line":34,"column":27},"end":{"line":52,"column":7}},"line":34},"6":{"name":"(anonymous_6)","decl":{"start":{"line":36,"column":46},"end":{"line":36,"column":47}},"loc":{"start":{"line":36,"column":54},"end":{"line":47,"column":11}},"line":36}},"branchMap":{"0":{"loc":{"start":{"line":10,"column":11},"end":{"line":10,"column":47}},"type":"binary-expr","locations":[{"start":{"line":10,"column":12},"end":{"line":10,"column":16}},{"start":{"line":10,"column":20},"end":{"line":10,"column":40}},{"start":{"line":10,"column":45},"end":{"line":10,"column":47}}],"line":10},"1":{"loc":{"start":{"line":20,"column":6},"end":{"line":22,"column":69}},"type":"cond-expr","locations":[{"start":{"line":21,"column":10},"end":{"line":21,"column":51}},{"start":{"line":22,"column":10},"end":{"line":22,"column":69}}],"line":20},"2":{"loc":{"start":{"line":20,"column":6},"end":{"line":20,"column":54}},"type":"binary-expr","locations":[{"start":{"line":20,"column":6},"end":{"line":20,"column":16}},{"start":{"line":20,"column":20},"end":{"line":20,"column":54}}],"line":20},"3":{"loc":{"start":{"line":22,"column":10},"end":{"line":22,"column":69}},"type":"cond-expr","locations":[{"start":{"line":22,"column":23},"end":{"line":22,"column":59}},{"start":{"line":22,"column":62},"end":{"line":22,"column":69}}],"line":22},"4":{"loc":{"start":{"line":35,"column":8},"end":{"line":49,"column":9}},"type":"if","locations":[{"start":{"line":35,"column":8},"end":{"line":49,"column":9}},{"start":{"line":35,"column":8},"end":{"line":49,"column":9}}],"line":35},"5":{"loc":{"start":{"line":40,"column":18},"end":{"line":42,"column":52}},"type":"cond-expr","locations":[{"start":{"line":41,"column":22},"end":{"line":41,"column":54}},{"start":{"line":42,"column":22},"end":{"line":42,"column":52}}],"line":40},"6":{"loc":{"start":{"line":43,"column":18},"end":{"line":43,"column":68}},"type":"cond-expr","locations":[{"start":{"line":43,"column":47},"end":{"line":43,"column":57}},{"start":{"line":43,"column":60},"end":{"line":43,"column":68}}],"line":43},"7":{"loc":{"start":{"line":70,"column":8},"end":{"line":72,"column":9}},"type":"if","locations":[{"start":{"line":70,"column":8},"end":{"line":72,"column":9}},{"start":{"line":70,"column":8},"end":{"line":72,"column":9}}],"line":70},"8":{"loc":{"start":{"line":74,"column":8},"end":{"line":76,"column":9}},"type":"if","locations":[{"start":{"line":74,"column":8},"end":{"line":76,"column":9}},{"start":{"line":74,"column":8},"end":{"line":76,"column":9}}],"line":74},"9":{"loc":{"start":{"line":79,"column":8},"end":{"line":86,"column":9}},"type":"if","locations":[{"start":{"line":79,"column":8},"end":{"line":86,"column":9}},{"start":{"line":79,"column":8},"end":{"line":86,"column":9}}],"line":79},"10":{"loc":{"start":{"line":80,"column":10},"end":{"line":82,"column":11}},"type":"if","locations":[{"start":{"line":80,"column":10},"end":{"line":82,"column":11}},{"start":{"line":80,"column":10},"end":{"line":82,"column":11}}],"line":80},"11":{"loc":{"start":{"line":83,"column":10},"end":{"line":85,"column":11}},"type":"if","locations":[{"start":{"line":83,"column":10},"end":{"line":85,"column":11}},{"start":{"line":83,"column":10},"end":{"line":85,"column":11}}],"line":83}},"s":{"0":1,"1":1,"2":1,"3":35,"4":35,"5":6,"6":11,"7":1,"8":1,"9":11,"10":11,"11":11,"12":1,"13":4,"14":1,"15":10,"16":6,"17":6,"18":6,"19":1,"20":11,"21":11,"22":0,"23":11,"24":3,"25":24,"26":3,"27":2,"28":3,"29":3},"f":{"0":1,"1":35,"2":35,"3":6,"4":11,"5":11,"6":4},"b":{"0":[35,35,29],"1":[6,5],"2":[11,11],"3":[5,0],"4":[1,10],"5":[3,1],"6":[3,1],"7":[0,11],"8":[3,8],"9":[3,21],"10":[2,1],"11":[3,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"b54ce93dffaa326cca8bf59c7fa569e2affba844"}
{"/Users/kye/github/babel-plugin-sitrep/src/index.js": {"path":"/Users/kye/github/babel-plugin-sitrep/src/index.js","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":92,"column":1}},"1":{"start":{"line":2,"column":23},"end":{"line":2,"column":28}},"2":{"start":{"line":3,"column":20},"end":{"line":7,"column":3}},"3":{"start":{"line":10,"column":4},"end":{"line":10,"column":47}},"4":{"start":{"line":14,"column":4},"end":{"line":14,"column":58}},"5":{"start":{"line":14,"column":30},"end":{"line":14,"column":57}},"6":{"start":{"line":18,"column":4},"end":{"line":23,"column":5}},"7":{"start":{"line":26,"column":15},"end":{"line":66,"column":3}},"8":{"start":{"line":28,"column":6},"end":{"line":30,"column":7}},"9":{"start":{"line":33,"column":20},"end":{"line":33,"column":42}},"10":{"start":{"line":34,"column":6},"end":{"line":55,"column":8}},"11":{"start":{"line":35,"column":8},"end":{"line":52,"column":9}},"12":{"start":{"line":36,"column":10},"end":{"line":50,"column":14}},"13":{"start":{"line":40,"column":14},"end":{"line":49,"column":15}},"14":{"start":{"line":51,"column":10},"end":{"line":51,"column":16}},"15":{"start":{"line":54,"column":8},"end":{"line":54,"column":75}},"16":{"start":{"line":58,"column":17},"end":{"line":58,"column":64}},"17":{"start":{"line":59,"column":6},"end":{"line":63,"column":7}},"18":{"start":{"line":64,"column":6},"end":{"line":64,"column":29}},"19":{"start":{"line":68,"column":2},"end":{"line":91,"column":3}},"20":{"start":{"line":72,"column":8},"end":{"line":78,"column":9}},"21":{"start":{"line":73,"column":10},"end":{"line":77,"column":12}},"22":{"start":{"line":75,"column":14},"end":{"line":75,"column":47}},"23":{"start":{"line":81,"column":8},"end":{"line":88,"column":9}},"24":{"start":{"line":82,"column":10},"end":{"line":84,"column":11}},"25":{"start":{"line":83,"column":12},"end":{"line":83,"column":54}},"26":{"start":{"line":85,"column":10},"end":{"line":87,"column":11}},"27":{"start":{"line":86,"column":12},"end":{"line":86,"column":31}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":1,"column":17},"end":{"line":1,"column":18}},"loc":{"start":{"line":1,"column":34},"end":{"line":92,"column":1}},"line":1},"1":{"name":"getComments","decl":{"start":{"line":9,"column":11},"end":{"line":9,"column":22}},"loc":{"start":{"line":9,"column":30},"end":{"line":11,"column":3}},"line":9},"2":{"name":"hasSitrepComments","decl":{"start":{"line":13,"column":11},"end":{"line":13,"column":28}},"loc":{"start":{"line":13,"column":40},"end":{"line":15,"column":3}},"line":13},"3":{"name":"(anonymous_3)","decl":{"start":{"line":14,"column":25},"end":{"line":14,"column":26}},"loc":{"start":{"line":14,"column":30},"end":{"line":14,"column":57}},"line":14},"4":{"name":"createLogStatement","decl":{"start":{"line":17,"column":11},"end":{"line":17,"column":29}},"loc":{"start":{"line":17,"column":38},"end":{"line":24,"column":3}},"line":17},"5":{"name":"(anonymous_5)","decl":{"start":{"line":34,"column":20},"end":{"line":34,"column":21}},"loc":{"start":{"line":34,"column":27},"end":{"line":55,"column":7}},"line":34},"6":{"name":"(anonymous_6)","decl":{"start":{"line":39,"column":21},"end":{"line":39,"column":22}},"loc":{"start":{"line":39,"column":29},"end":{"line":50,"column":13}},"line":39}},"branchMap":{"0":{"loc":{"start":{"line":10,"column":11},"end":{"line":10,"column":47}},"type":"binary-expr","locations":[{"start":{"line":10,"column":12},"end":{"line":10,"column":16}},{"start":{"line":10,"column":20},"end":{"line":10,"column":40}},{"start":{"line":10,"column":45},"end":{"line":10,"column":47}}],"line":10},"1":{"loc":{"start":{"line":20,"column":6},"end":{"line":22,"column":69}},"type":"cond-expr","locations":[{"start":{"line":21,"column":10},"end":{"line":21,"column":51}},{"start":{"line":22,"column":10},"end":{"line":22,"column":69}}],"line":20},"2":{"loc":{"start":{"line":20,"column":6},"end":{"line":20,"column":54}},"type":"binary-expr","locations":[{"start":{"line":20,"column":6},"end":{"line":20,"column":16}},{"start":{"line":20,"column":20},"end":{"line":20,"column":54}}],"line":20},"3":{"loc":{"start":{"line":22,"column":10},"end":{"line":22,"column":69}},"type":"cond-expr","locations":[{"start":{"line":22,"column":23},"end":{"line":22,"column":59}},{"start":{"line":22,"column":62},"end":{"line":22,"column":69}}],"line":22},"4":{"loc":{"start":{"line":35,"column":8},"end":{"line":52,"column":9}},"type":"if","locations":[{"start":{"line":35,"column":8},"end":{"line":52,"column":9}},{"start":{"line":35,"column":8},"end":{"line":52,"column":9}}],"line":35},"5":{"loc":{"start":{"line":43,"column":20},"end":{"line":45,"column":54}},"type":"cond-expr","locations":[{"start":{"line":44,"column":24},"end":{"line":44,"column":56}},{"start":{"line":45,"column":24},"end":{"line":45,"column":54}}],"line":43},"6":{"loc":{"start":{"line":46,"column":20},"end":{"line":46,"column":70}},"type":"cond-expr","locations":[{"start":{"line":46,"column":49},"end":{"line":46,"column":59}},{"start":{"line":46,"column":62},"end":{"line":46,"column":70}}],"line":46},"7":{"loc":{"start":{"line":72,"column":8},"end":{"line":78,"column":9}},"type":"if","locations":[{"start":{"line":72,"column":8},"end":{"line":78,"column":9}},{"start":{"line":72,"column":8},"end":{"line":78,"column":9}}],"line":72},"8":{"loc":{"start":{"line":81,"column":8},"end":{"line":88,"column":9}},"type":"if","locations":[{"start":{"line":81,"column":8},"end":{"line":88,"column":9}},{"start":{"line":81,"column":8},"end":{"line":88,"column":9}}],"line":81},"9":{"loc":{"start":{"line":82,"column":10},"end":{"line":84,"column":11}},"type":"if","locations":[{"start":{"line":82,"column":10},"end":{"line":84,"column":11}},{"start":{"line":82,"column":10},"end":{"line":84,"column":11}}],"line":82},"10":{"loc":{"start":{"line":85,"column":10},"end":{"line":87,"column":11}},"type":"if","locations":[{"start":{"line":85,"column":10},"end":{"line":87,"column":11}},{"start":{"line":85,"column":10},"end":{"line":87,"column":11}}],"line":85}},"s":{"0":1,"1":1,"2":1,"3":40,"4":40,"5":6,"6":11,"7":1,"8":1,"9":11,"10":11,"11":11,"12":1,"13":4,"14":1,"15":10,"16":6,"17":6,"18":6,"19":1,"20":14,"21":3,"22":3,"23":26,"24":3,"25":2,"26":3,"27":3},"f":{"0":1,"1":40,"2":40,"3":6,"4":11,"5":11,"6":4},"b":{"0":[40,40,34],"1":[6,5],"2":[11,11],"3":[5,0],"4":[1,10],"5":[3,1],"6":[3,1],"7":[3,11],"8":[3,23],"9":[2,1],"10":[3,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"f59fcc4a4a0651cdb2a3f6488d57ccb8863a9563"}
}
{
"name": "babel-plugin-sitrep",
"version": "1.1.0",
"version": "1.1.1",
"description": "Log all assignments and the return value of a function with a simple comment",
"main": "src/index.js",
"scripts": {
"lint": "standard src",
"lint:fix": "standard --fix src",
"test": "jest --coverage --no-cache --ci --runInBand",

@@ -13,53 +15,16 @@ "test:watch": "jest --watch --no-cache"

"eslintConfig": {
"extends": [
"standard"
],
"plugins": [
"prettier"
],
"parser": "babel-eslint",
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": true,
"semi": false
}
],
"react/prop-types": 0,
"react/no-unused-prop-types": 0,
"standard/computed-property-even-spacing": 0,
"no-template-curly-in-string": 0
},
"overrides": [
{
"files": [
"*.test.js"
],
"env": {
"jest": true
}
}
]
"extends": "standard",
"parser": "babel-eslint"
},
"standard": {
"parser": "babel-eslint"
},
"devDependencies": {
"babel-eslint": "^7.2.3",
"eslint": "^4.5.0",
"eslint-config-prettier": "^2.3.0",
"eslint-config-react": "^1.1.7",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-react": "^5.0.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-prettier": "^2.2.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.3.0",
"eslint-plugin-standard": "^3.0.1",
"babel-plugin-tester": "^4.0.0",
"jest": "^20.0.4",
"jest-cli": "^20.0.4",
"prettier": "^1.6.1"
"prettier": "^1.6.1",
"standard": "^10.0.3"
},
"dependencies": {
"babel-plugin-tester": "^4.0.0"
},
"bugs": {

@@ -71,3 +36,14 @@ "url": "https://github.com/tkh44/babel-plugin-sitrep/issues"

"url": "git+https://github.com/tkh44/babel-plugin-sitrep.git"
}
},
"keywords": [
"console",
"console.log",
"babel",
"plugin",
"babel-plugin-sitrep",
"babel log",
"logging",
"logger",
"log"
]
}

@@ -110,4 +110,15 @@ const pluginTester = require('babel-plugin-tester')

`
},
{
title: 'no function parent',
code: `
// sitrep
if (a) {
let a = 2
let b = a + 5
}
`
}
]
})

@@ -1,2 +0,2 @@

module.exports = function(babel) {
module.exports = function (babel) {
const { types: t } = babel

@@ -9,11 +9,11 @@ const logCallee = t.memberExpression(

function getComments(node) {
function getComments (node) {
return (node && node.leadingComments) || []
}
function hasSitrepComments(comments) {
function hasSitrepComments (comments) {
return comments.some(c => c.value.trim() === 'sitrep')
}
function createLogStatement(thing) {
function createLogStatement (thing) {
return t.callExpression(

@@ -28,3 +28,3 @@ logCallee,

const dive = {
AssignmentExpression(path) {
AssignmentExpression (path) {
path.insertAfter(

@@ -34,18 +34,21 @@ t.expressionStatement(createLogStatement(path.node.left))

},
VariableDeclaration(path) {
VariableDeclaration (path) {
const decls = path.node.declarations
decls.forEach(dec => {
if (t.isPattern(dec.id)) {
dec.id.properties.reverse().forEach(prop => {
path.insertAfter(
t.expressionStatement(
t.callExpression(logCallee, [
t.isIdentifier(prop.value)
? t.stringLiteral(prop.value.name)
: t.stringLiteral(prop.key.name),
t.isIdentifier(prop.value) ? prop.value : prop.key
])
dec.id.properties
.slice()
.reverse()
.forEach(prop => {
path.insertAfter(
t.expressionStatement(
t.callExpression(logCallee, [
t.isIdentifier(prop.value)
? t.stringLiteral(prop.value.name)
: t.stringLiteral(prop.key.name),
t.isIdentifier(prop.value) ? prop.value : prop.key
])
)
)
)
})
})
return

@@ -57,3 +60,3 @@ }

},
ReturnStatement(path) {
ReturnStatement (path) {
const id = path.scope.generateUidIdentifier('returnValue')

@@ -70,15 +73,14 @@ path.insertBefore(

return {
name: 'babel-plugin-sitrep', // not required
name: 'babel-plugin-sitrep',
visitor: {
BlockStatement(path) {
let p = path.getFunctionParent()
if (!p) {
return
Function (path) {
if (hasSitrepComments(getComments(path.node))) {
path.traverse({
BlockStatement (blockStatementPath) {
blockStatementPath.traverse(dive)
}
})
}
if (hasSitrepComments(getComments(p.node))) {
path.traverse(dive)
}
},
VariableDeclarator(path) {
VariableDeclarator (path) {
if (hasSitrepComments(getComments(path.parentPath.node))) {

@@ -85,0 +87,0 @@ if (t.isArrowFunctionExpression(path.node.init)) {

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

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

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