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

eslint-plugin-factorial

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-factorial - npm Package Compare versions

Comparing version 2.0.15 to 2.0.16

2

package.json
{
"name": "eslint-plugin-factorial",
"version": "2.0.15",
"version": "2.0.16",
"main": "index.js",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -1,51 +0,4 @@

const path = require('path')
const fs = require('fs')
const yaml = require('yaml')
const retrieveAllowedCollections = (fileName) => {
const regex = /modules\/(?<module>[^\/]+)/
const matchFileName = fileName.match(regex)
if (!matchFileName) return []
const { module: moduleFileName } = matchFileName.groups
const packagePath = path.join(process.cwd(), 'src/modules', moduleFileName, 'package.yml')
if (!fs.existsSync(packagePath)) {
console.warn(
`Unable to retrieve allowed collections because '${packagePath}' file doesn't exists.`
)
return []
}
try {
const { collections } = yaml.parse(fs.readFileSync(packagePath, 'utf8'))
return collections ?? []
} catch (error) {
console.error(error)
console.warn(
`Unable to retrieve allowed collections because '${packagePath}' file is not a valid YAML.`
)
return []
}
}
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
create(context) {
const fileName = context.getFilename()
const allowedCollections = retrieveAllowedCollections(fileName)
// console.log(`Allowed collections for file: ${fileName}`, allowedCollections)
// NOTE: If user collection is allowed, then access collection is also
// allowed because it is an alias. We are in the process of renaming the
// uses collection to access collection.
if (allowedCollections.includes('modules/core/store/collections/users')) {
allowedCollections.push('modules/core/store/collections/accesses')
}
const reportWarning = (node) => {

@@ -55,3 +8,3 @@ context.report({

message:
'Try to use GraphQL instead of this mobx-rest collection',
'mobx-rest is deprecated. Use GraphQL instead.',
})

@@ -67,9 +20,7 @@ }

const validSpecifier = node.specifiers.filter((specifier) => {
return specifier.importKind === 'value'
return specifier.parent.importKind === 'value'
}).length > 0
if (validImport && validSource && validSpecifier) {
if (!allowedCollections.includes(value)) {
reportWarning(node)
}
reportWarning(node)
}

@@ -79,2 +30,2 @@ },

},
}
}
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