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

@secretlint/config-loader

Package Overview
Dependencies
Maintainers
0
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@secretlint/config-loader - npm Package Compare versions

Comparing version 8.3.2 to 8.3.3

4

module/index.d.ts

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

import { SecretLintCoreConfig, SecretLintConfigDescriptor, SecretLintUnionRuleCreator, SecretLintRuleModule } from "@secretlint/types";
import { SecretLintConfigDescriptor, SecretLintCoreConfig, SecretLintRuleModule, SecretLintUnionRuleCreator } from "@secretlint/types";
import { AggregationError } from "./AggregationError.js";
export declare function importSecretlintCreator(moduleExports?: SecretLintRuleModule): SecretLintUnionRuleCreator;
export declare function importSecretlintCreator(moduleExports?: SecretLintRuleModule | Record<string, unknown>): SecretLintUnionRuleCreator;
export type SecretLintConfigLoaderOptions = {

@@ -5,0 +5,0 @@ cwd?: string;

import { rcFile } from "rc-config-loader";
import { secretLintProfiler } from "@secretlint/profiler";
import { SecretLintModuleResolver } from "./SecretLintModuleResolver.js";
import { validateConfigWithDescriptor, validateConfigDescriptor } from "./validator.js";
import * as url from "node:url";
import { validateConfigDescriptor, validateConfigWithDescriptor } from "./validator.js";
import { AggregationError } from "./AggregationError.js";
import { dynamicImport } from "@secretlint/resolver";
export function importSecretlintCreator(moduleExports) {

@@ -16,7 +16,2 @@ if (!moduleExports) {

}
// Windows's path require to convert file://
// https://github.com/secretlint/secretlint/issues/205
const convertToFileUrl = (filePath) => {
return url.pathToFileURL(filePath).href;
};
/**

@@ -58,3 +53,6 @@ * Load packages in RawConfig and return loaded config object

? replacedDefinition.rule
: importSecretlintCreator(await import(convertToFileUrl(moduleResolver.resolveRulePackageName(configDescriptorRule.id))));
: importSecretlintCreator((await dynamicImport(moduleResolver.resolveRulePackageName(configDescriptorRule.id), {
parentModule: "config-loader",
parentImportMeta: import.meta,
})).exports);
if (isSecretLintCoreConfigRulePreset(ruleCreator)) {

@@ -61,0 +59,0 @@ const configDescriptorRulePreset = configDescriptorRule;

// LICENSE : MIT
import * as path from "node:path";
import { createFullPackageName } from "./package-name-util.js";
import { createRequire } from "node:module";
import debug0 from "debug";
const require = createRequire(import.meta.url);
const debug = debug0("@secretlint/config-loader");
const tryResolve = (packageName) => {
try {
// TODO: use import.meta.resolve to support exports fields
return require.resolve(packageName);
}
catch {
return false;
}
import { tryResolve } from "@secretlint/resolver";
/**
* Try to resolve module or file path.
* @param modulePath
*/
const tryResolveModulePath = (modulePath) => {
return tryResolve(modulePath, {
parentImportMeta: import.meta,
parentModule: "config-loader",
});
};

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

// <rule-name> or secretlint-rule-<rule-name>
const pkgPath = tryResolve(path.join(baseDir, fullPackageName)) || tryResolve(path.join(baseDir, packageName));
const pkgPath = tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -70,3 +71,4 @@ debug(`rule fullPackageName: ${fullPackageName}`);

// <rule-name> or secretlint-filter-rule-<rule-name> or @scope/<rule-name>
const pkgPath = tryResolve(path.join(baseDir, fullPackageName)) || tryResolve(path.join(baseDir, packageName));
const pkgPath = tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -91,3 +93,4 @@ debug(`filter rule fullPackageName: ${fullPackageName}`);

// <plugin-name> or secretlint-plugin-<rule-name>
const pkgPath = tryResolve(path.join(baseDir, fullPackageName)) || tryResolve(path.join(baseDir, packageName));
const pkgPath = tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -135,9 +138,9 @@ debug(`plugin fullPackageName: ${fullPackageName}`);

// secretlint-rule-preset-<preset-name> or @scope/secretlint-rule-preset-<preset-name>
tryResolve(path.join(baseDir, fullFullPackageName)) ||
tryResolveModulePath(path.join(baseDir, fullFullPackageName)) ||
// <preset-name>
tryResolve(path.join(baseDir, packageNameWithoutPreset)) ||
tryResolveModulePath(path.join(baseDir, packageNameWithoutPreset)) ||
// <rule-name>
tryResolve(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
// <package-name>
tryResolve(path.join(baseDir, packageName));
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -163,3 +166,4 @@ debug(`preset fullPackageName: ${fullPackageName}`);

// <plugin-name> or secretlint-config-<rule-name>
const pkgPath = tryResolve(path.join(baseDir, fullPackageName)) || tryResolve(path.join(baseDir, packageName));
const pkgPath = tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -166,0 +170,0 @@ throw new ReferenceError(`Failed to load secretlint's config module: "${packageName}" is not found.

{
"name": "@secretlint/config-loader",
"version": "8.3.2",
"version": "8.3.3",
"description": "Config loader for secretlint.",

@@ -60,4 +60,5 @@ "keywords": [

"dependencies": {
"@secretlint/profiler": "^8.3.2",
"@secretlint/types": "^8.3.2",
"@secretlint/profiler": "^8.3.3",
"@secretlint/resolver": "^8.3.3",
"@secretlint/types": "^8.3.3",
"ajv": "^8.17.1",

@@ -69,4 +70,4 @@ "debug": "^4.3.7",

"devDependencies": {
"@secretlint/secretlint-rule-internal-test-cjs": "^8.3.2",
"@secretlint/secretlint-rule-internal-test-esm": "^8.3.2",
"@secretlint/secretlint-rule-internal-test-cjs": "^8.3.3",
"@secretlint/secretlint-rule-internal-test-esm": "^8.3.3",
"@types/mocha": "^10.0.8",

@@ -88,3 +89,3 @@ "@types/node": "^20.16.10",

},
"gitHead": "97ebb453fa3dc82454dcbb29fb2e4a14194c6f97"
"gitHead": "f5b6e6d2ce95d31d8161fc71d0b692ccbacb7c21"
}
import { rcFile } from "rc-config-loader";
import {
SecretLintConfigDescriptor,
SecretLintConfigDescriptorRulePreset,
SecretLintCoreConfig,
SecretLintCoreConfigUnionRule,
SecretLintConfigDescriptor,
SecretLintUnionRuleCreator,
SecretLintRuleModule,
SecretLintRulePresetCreator,
SecretLintConfigDescriptorRulePreset,
SecretLintUnionRuleCreator,
} from "@secretlint/types";
import { secretLintProfiler } from "@secretlint/profiler";
import { SecretLintModuleResolver } from "./SecretLintModuleResolver.js";
import { validateConfigWithDescriptor, validateConfigDescriptor } from "./validator.js";
import * as url from "node:url";
import { validateConfigDescriptor, validateConfigWithDescriptor } from "./validator.js";
import { AggregationError } from "./AggregationError.js";
import { dynamicImport } from "@secretlint/resolver";
export function importSecretlintCreator(moduleExports?: SecretLintRuleModule): SecretLintUnionRuleCreator {
export function importSecretlintCreator(
moduleExports?: SecretLintRuleModule | Record<string, unknown>
): SecretLintUnionRuleCreator {
if (!moduleExports) {

@@ -24,10 +26,5 @@ throw new Error("Secretlint rule should export { creator }. module is undefined");

}
return moduleExports.creator;
return moduleExports.creator as SecretLintUnionRuleCreator;
}
// Windows's path require to convert file://
// https://github.com/secretlint/secretlint/issues/205
const convertToFileUrl = (filePath: string) => {
return url.pathToFileURL(filePath).href;
};
export type SecretLintConfigLoaderOptions = {

@@ -136,3 +133,8 @@ cwd?: string;

: importSecretlintCreator(
await import(convertToFileUrl(moduleResolver.resolveRulePackageName(configDescriptorRule.id)))
(
await dynamicImport(moduleResolver.resolveRulePackageName(configDescriptorRule.id), {
parentModule: "config-loader",
parentImportMeta: import.meta,
})
).exports
);

@@ -139,0 +141,0 @@ if (isSecretLintCoreConfigRulePreset(ruleCreator)) {

// LICENSE : MIT
import * as path from "node:path";
import { createFullPackageName } from "./package-name-util.js";
import { createRequire } from "node:module";
import debug0 from "debug";
const require = createRequire(import.meta.url);
const debug = debug0("@secretlint/config-loader");
import { tryResolve } from "@secretlint/resolver";
const tryResolve = (packageName: string) => {
try {
// TODO: use import.meta.resolve to support exports fields
return require.resolve(packageName);
} catch {
return false;
}
/**
* Try to resolve module or file path.
* @param modulePath
*/
const tryResolveModulePath = (modulePath: string): string | undefined => {
return tryResolve(modulePath, {
parentImportMeta: import.meta,
parentModule: "config-loader",
});
};

@@ -53,3 +54,5 @@

// <rule-name> or secretlint-rule-<rule-name>
const pkgPath = tryResolve(path.join(baseDir, fullPackageName)) || tryResolve(path.join(baseDir, packageName));
const pkgPath =
tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -75,3 +78,5 @@ debug(`rule fullPackageName: ${fullPackageName}`);

// <rule-name> or secretlint-filter-rule-<rule-name> or @scope/<rule-name>
const pkgPath = tryResolve(path.join(baseDir, fullPackageName)) || tryResolve(path.join(baseDir, packageName));
const pkgPath =
tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -97,3 +102,5 @@ debug(`filter rule fullPackageName: ${fullPackageName}`);

// <plugin-name> or secretlint-plugin-<rule-name>
const pkgPath = tryResolve(path.join(baseDir, fullPackageName)) || tryResolve(path.join(baseDir, packageName));
const pkgPath =
tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -142,9 +149,9 @@ debug(`plugin fullPackageName: ${fullPackageName}`);

// secretlint-rule-preset-<preset-name> or @scope/secretlint-rule-preset-<preset-name>
tryResolve(path.join(baseDir, fullFullPackageName)) ||
tryResolveModulePath(path.join(baseDir, fullFullPackageName)) ||
// <preset-name>
tryResolve(path.join(baseDir, packageNameWithoutPreset)) ||
tryResolveModulePath(path.join(baseDir, packageNameWithoutPreset)) ||
// <rule-name>
tryResolve(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
// <package-name>
tryResolve(path.join(baseDir, packageName));
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -171,3 +178,5 @@ debug(`preset fullPackageName: ${fullPackageName}`);

// <plugin-name> or secretlint-config-<rule-name>
const pkgPath = tryResolve(path.join(baseDir, fullPackageName)) || tryResolve(path.join(baseDir, packageName));
const pkgPath =
tryResolveModulePath(path.join(baseDir, fullPackageName)) ||
tryResolveModulePath(path.join(baseDir, packageName));
if (!pkgPath) {

@@ -174,0 +183,0 @@ throw new ReferenceError(`Failed to load secretlint's config module: "${packageName}" is not found.

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