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

@roadmunk/eslint-plugin-roadmunk-custom

Package Overview
Dependencies
Maintainers
10
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@roadmunk/eslint-plugin-roadmunk-custom - npm Package Compare versions

Comparing version 1.6.0 to 1.6.1

4

docs/rules/no-require-views.md
# Prevent requiring `views/` packages in JS code (no-require-views)
This rule aims to prevent importing packages from within the `views/`, directory. We should instead be only requiring the packages we specifically need, instead of entire views.
This rule aims to prevent importing packages from within the `views/`, directory. We should instead be only requiring the packages we specifically need, instead of entire views (unless we need the entire view).
## Rule Details
This rule checks any `require` statements for the packages they're importing _except_ for on-demand `require` statements (see below).
This rule checks any `require` statements for the packages they're importing _except_ for on-demand `require` statements, as this is the preferred method of requiring views (see below).

@@ -9,0 +9,0 @@ Examples of **incorrect** code for this rule:

@@ -98,7 +98,22 @@ 'use strict';

/**
* Checks if the given node is a require statement function call
*
* @param {Object} node - the node whose properties need to be looked up
* @returns {Boolean} true if it is a require function call with a single argument literal. Otherwise, returns false
*/
function isRequire(node) {
return node
&& node.callee.type === 'Identifier'
&& node.callee.name === 'require'
&& node.arguments.length === 1
&& node.arguments[0].type === 'Literal';
}
module.exports = {
lodashAutofix,
hasPropsWithValues,
isRequire,
isPropertyAnIdentifierWithName,
isObjectAnIdentifierWithName,
};

@@ -7,3 +7,4 @@ /**

const _ = require('lodash');
const _ = require('lodash');
const { isRequire } = require('../helper.js');

@@ -14,10 +15,2 @@ // ------------------------------------------------------------------------------

function isNonDemandRequire(node) {
return node
&& node.callee.type === 'Identifier'
&& node.callee.name === 'require'
&& node.arguments.length === 1
&& node.arguments[0].type === 'Literal';
}
module.exports = {

@@ -35,3 +28,3 @@ meta : {

CallExpression(node) {
if (!isNonDemandRequire(node)) {
if (!isRequire(node)) {
return;

@@ -44,3 +37,3 @@ }

node,
message : 'Prevent importing \'views\' packages',
message : 'Use an on-demand require statement to import views',
});

@@ -47,0 +40,0 @@ }

@@ -7,3 +7,4 @@ /**

const _ = require('lodash');
const _ = require('lodash');
const { isRequire } = require('../helper.js');

@@ -15,10 +16,2 @@ // ------------------------------------------------------------------------------

function isRequire(node) {
return node
&& node.callee.type === 'Identifier'
&& node.callee.name === 'require'
&& node.arguments.length === 1
&& node.arguments[0].type === 'Literal';
}
function isRelativeRequire(moduleName) {

@@ -25,0 +18,0 @@ return moduleName.startsWith('.');

{
"name": "@roadmunk/eslint-plugin-roadmunk-custom",
"version": "1.6.0",
"version": "1.6.1",
"description": "Plugin to hold custom ESLint rules for Roadmunk",

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

@@ -60,2 +60,2 @@ # eslint-plugin-roadmunk-custom

`no-require-views` : Prevents requiring packages from the `views/` folder.
`no-require-views` : Warns about requiring packages from the `views/` folder.

@@ -12,3 +12,4 @@ /**

const RuleTester = require('eslint').RuleTester;
const rule = require('../../../lib/rules/no-require-views');
const _ = require('lodash');
const rule = require('../../../lib/rules/no-require-views');

@@ -19,6 +20,6 @@ // ------------------------------------------------------------------------------

const errors = [ {
message : 'Prevent importing \'views\' packages',
const error = {
message : 'Use an on-demand require statement to import views',
type : 'CallExpression',
} ];
};

@@ -53,3 +54,3 @@ const ruleTester = new RuleTester();

`,
errors,
errors : _.times(1, _.constant(error)),
},

@@ -67,3 +68,3 @@ {

`,
errors,
errors : _.times(1, _.constant(error)),
},

@@ -84,3 +85,3 @@ // Should only fail on the require method at the top

`,
errors,
errors : _.times(1, _.constant(error)),
},

@@ -108,12 +109,3 @@ // Should fail on the require method at the top and the require within the function only

`,
errors : [
{
message : 'Prevent importing \'views\' packages',
type : 'CallExpression',
},
{
message : 'Prevent importing \'views\' packages',
type : 'CallExpression',
},
],
errors : _.times(2, _.constant(error)),
},

@@ -133,18 +125,5 @@ {

`,
errors : [
{
message : 'Prevent importing \'views\' packages',
type : 'CallExpression',
},
{
message : 'Prevent importing \'views\' packages',
type : 'CallExpression',
},
{
message : 'Prevent importing \'views\' packages',
type : 'CallExpression',
},
],
errors : _.times(3, _.constant(error)),
},
],
});
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