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

eslint-plugin-payfit

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-payfit - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

48

lib/rules/no-mongo-objectid.js

@@ -28,25 +28,5 @@ /**

// visitor functions for different types of nodes
VariableDeclarator: (node) => {
if (
node.init &&
node.init.callee &&
node.init.callee.name === 'ObjectId' &&
node.init.type !== 'NewExpression'
) {
context.report({
node,
message: 'Mongo ObjectId must be used with "new" keyword.',
fix: (fixer) => {
const sourceCode = context.getSourceCode()
const fixedText = sourceCode.getText(node).split('ObjectId').join('new ObjectId')
return fixer.replaceText(node, fixedText)
},
})
}
if (
node.init &&
node.init.type === 'ObjectExpression' &&
node.init.properties.length > 0
) {
node.init.properties.forEach((property) => {
ObjectExpression(node) {
if (node.properties && node.properties.length > 0) {
node.properties.forEach((property) => {
if (

@@ -63,5 +43,3 @@ property.value &&

const text = context.getSourceCode().getText(node)
const fixedText = text
.split('ObjectId')
.join('new ObjectId')
const fixedText = text.split('ObjectId').join('new ObjectId')
return fixer.replaceText(node, fixedText)

@@ -74,3 +52,21 @@ },

},
VariableDeclarator: (node) => {
if (
node.init &&
node.init.callee &&
node.init.callee.name === 'ObjectId' &&
node.init.type !== 'NewExpression'
) {
context.report({
node,
message: 'Mongo ObjectId must be used with "new" keyword.',
fix: (fixer) => {
const text = context.getSourceCode().getText(node)
const fixedText = text.split('ObjectId').join('new ObjectId')
return fixer.replaceText(node, fixedText)
},
})
}
},
}),
}
{
"name": "eslint-plugin-payfit",
"version": "1.0.3",
"version": "1.0.4",
"description": "eslint-payfit-plugin",

@@ -5,0 +5,0 @@ "keywords": [

@@ -34,2 +34,12 @@ /**

{
code: 'callToFunction({ id: ObjectId() })',
errors: [
{
message: 'Mongo ObjectId must be used with "new" keyword.',
type: 'ObjectExpression',
},
],
output: 'callToFunction({ id: new ObjectId() })',
},
{
code: 'var invalid = { id: ObjectId(), createdAt: Date(), companyId: ObjectId() }',

@@ -39,7 +49,7 @@ errors: [

message: 'Mongo ObjectId must be used with "new" keyword.',
type: 'VariableDeclarator',
type: 'ObjectExpression',
},
{
message: 'Mongo ObjectId must be used with "new" keyword.',
type: 'VariableDeclarator',
type: 'ObjectExpression',
},

@@ -46,0 +56,0 @@ ],

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