Socket
Socket
Sign inDemoInstall

eslint

Package Overview
Dependencies
99
Maintainers
4
Versions
356
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.54.0 to 8.55.0

83

lib/rules/no-restricted-imports.js

@@ -77,2 +77,5 @@ /**

},
importNamePattern: {
type: "string"
},
message: {

@@ -119,4 +122,8 @@ type: "string",

patternAndEverything: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted from being used by a pattern.",
patternAndEverythingWithRegexImportName: "* import is invalid because import name matching '{{importNames}}' pattern from '{{importSource}}' is restricted from being used.",
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
patternAndEverythingWithCustomMessage: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted from being used by a pattern. {{customMessage}}",
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
patternAndEverythingWithRegexImportNameAndCustomMessage: "* import is invalid because import name matching '{{importNames}}' pattern from '{{importSource}}' is restricted from being used. {{customMessage}}",

@@ -180,6 +187,7 @@ everything: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted.",

// relative paths are supported for this rule
const restrictedPatternGroups = restrictedPatterns.map(({ group, message, caseSensitive, importNames }) => ({
const restrictedPatternGroups = restrictedPatterns.map(({ group, message, caseSensitive, importNames, importNamePattern }) => ({
matcher: ignore({ allowRelativePaths: true, ignorecase: !caseSensitive }).add(group),
customMessage: message,
importNames
importNames,
importNamePattern
}));

@@ -268,2 +276,3 @@

const restrictedImportNames = group.importNames;
const restrictedImportNamePattern = group.importNamePattern ? new RegExp(group.importNamePattern, "u") : null;

@@ -274,3 +283,3 @@ /*

*/
if (!restrictedImportNames) {
if (!restrictedImportNames && !restrictedImportNamePattern) {
context.report({

@@ -287,36 +296,50 @@ node,

if (importNames.has("*")) {
const specifierData = importNames.get("*")[0];
importNames.forEach((specifiers, importName) => {
if (importName === "*") {
const [specifier] = specifiers;
context.report({
node,
messageId: customMessage ? "patternAndEverythingWithCustomMessage" : "patternAndEverything",
loc: specifierData.loc,
data: {
importSource,
importNames: restrictedImportNames,
customMessage
if (restrictedImportNames) {
context.report({
node,
messageId: customMessage ? "patternAndEverythingWithCustomMessage" : "patternAndEverything",
loc: specifier.loc,
data: {
importSource,
importNames: restrictedImportNames,
customMessage
}
});
} else {
context.report({
node,
messageId: customMessage ? "patternAndEverythingWithRegexImportNameAndCustomMessage" : "patternAndEverythingWithRegexImportName",
loc: specifier.loc,
data: {
importSource,
importNames: restrictedImportNamePattern,
customMessage
}
});
}
});
}
restrictedImportNames.forEach(importName => {
if (!importNames.has(importName)) {
return;
}
const specifiers = importNames.get(importName);
specifiers.forEach(specifier => {
context.report({
node,
messageId: customMessage ? "patternAndImportNameWithCustomMessage" : "patternAndImportName",
loc: specifier.loc,
data: {
importSource,
customMessage,
importName
}
if (
(restrictedImportNames && restrictedImportNames.includes(importName)) ||
(restrictedImportNamePattern && restrictedImportNamePattern.test(importName))
) {
specifiers.forEach(specifier => {
context.report({
node,
messageId: customMessage ? "patternAndImportNameWithCustomMessage" : "patternAndImportName",
loc: specifier.loc,
data: {
importSource,
customMessage,
importName
}
});
});
});
}
});

@@ -323,0 +346,0 @@ }

{
"name": "eslint",
"version": "8.54.0",
"version": "8.55.0",
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",

@@ -22,2 +22,3 @@ "description": "An AST-based pattern checker for JavaScript.",

"lint:docs:js": "node Makefile.js lintDocsJS",
"lint:docs:rule-examples": "node Makefile.js checkRuleExamples",
"lint:fix": "node Makefile.js lint -- fix",

@@ -46,2 +47,3 @@ "lint:fix:docs:js": "node Makefile.js lintDocsJS -- fix",

"docs/src/rules/*.md": [
"node tools/check-rule-examples.js",
"node tools/fetch-docs-links.js",

@@ -67,4 +69,4 @@ "git add docs/src/_data/further_reading_links.json"

"@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.3",
"@eslint/js": "8.54.0",
"@eslint/eslintrc": "^2.1.4",
"@eslint/js": "8.55.0",
"@humanwhocodes/config-array": "^0.11.13",

@@ -138,2 +140,4 @@ "@humanwhocodes/module-importer": "^1.0.1",

"load-perf": "^0.2.0",
"markdown-it": "^12.2.0",
"markdown-it-container": "^3.0.0",
"markdownlint": "^0.31.1",

@@ -140,0 +144,0 @@ "markdownlint-cli": "^0.37.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc