Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@eslint/config-helpers

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eslint/config-helpers - npm Package Compare versions

Comparing version
0.4.0
to
0.4.1
+36
-29
dist/cjs/index.cjs

@@ -12,11 +12,13 @@ 'use strict';

/** @typedef {import("@eslint/core").ConfigObject} Config */
/** @typedef {import("@eslint/core").LegacyConfigObject} LegacyConfig */
/** @typedef {import("@eslint/core").Plugin} Plugin */
/** @typedef {import("@eslint/core").RuleConfig} RuleConfig */
/** @typedef {import("./types.ts").ExtendsElement} ExtendsElement */
/** @typedef {import("./types.ts").SimpleExtendsElement} SimpleExtendsElement */
/** @typedef {import("./types.ts").ConfigWithExtends} ConfigWithExtends */
/** @typedef {import("./types.ts").InfiniteArray<Config>} InfiniteConfigArray */
/** @typedef {import("./types.ts").ConfigWithExtendsArray} ConfigWithExtendsArray */
/** @import * as $eslintcore from "@eslint/core"; */
/** @typedef {$eslintcore.ConfigObject} Config */
/** @typedef {$eslintcore.LegacyConfigObject} LegacyConfig */
/** @typedef {$eslintcore.Plugin} Plugin */
/** @typedef {$eslintcore.RuleConfig} RuleConfig */
/** @import * as $typests from "./types.ts"; */
/** @typedef {$typests.ExtendsElement} ExtendsElement */
/** @typedef {$typests.SimpleExtendsElement} SimpleExtendsElement */
/** @typedef {$typests.ConfigWithExtends} ConfigWithExtends */
/** @typedef {$typests.InfiniteArray<Config>} InfiniteConfigArray */
/** @typedef {$typests.ConfigWithExtendsArray} ConfigWithExtendsArray */

@@ -80,2 +82,7 @@ //-----------------------------------------------------------------------------

function isLegacyConfig(config) {
// eslintrc's plugins must be an array; while flat config's must be an object.
if (Array.isArray(config.plugins)) {
return true;
}
for (const key of eslintrcKeys) {

@@ -258,2 +265,4 @@ if (key in config) {

const directConfig = plugin.configs?.[configName];
// Prefer direct config, but fall back to flat config if available
if (directConfig) {

@@ -269,26 +278,24 @@ // Arrays are always flat configs, and non-legacy configs can be used directly

}
}
// If it's a legacy config, look for the flat version
const flatConfig = plugin.configs?.[`flat/${configName}`];
if (
flatConfig &&
(Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))
) {
return deepNormalizePluginConfig(
userPluginNamespace,
plugin,
flatConfig,
pluginConfigName,
);
}
throw new TypeError(
`Plugin config "${configName}" in plugin "${userPluginNamespace}" is an eslintrc config and cannot be used in this context.`,
// If it's a legacy config, or the config does not exist => look for the flat version
const flatConfig = plugin.configs?.[`flat/${configName}`];
if (
flatConfig &&
(Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))
) {
return deepNormalizePluginConfig(
userPluginNamespace,
plugin,
flatConfig,
pluginConfigName,
);
}
throw new TypeError(
`Plugin config "${configName}" not found in plugin "${userPluginNamespace}".`,
);
// If we get here, then the config was either not found or is a legacy config
const message =
directConfig || flatConfig
? `Plugin config "${configName}" in plugin "${userPluginNamespace}" is an eslintrc config and cannot be used in this context.`
: `Plugin config "${configName}" not found in plugin "${userPluginNamespace}".`;
throw new TypeError(message);
}

@@ -295,0 +302,0 @@

@@ -1,10 +0,10 @@

export type Config = import("@eslint/core").ConfigObject;
export type LegacyConfig = import("@eslint/core").LegacyConfigObject;
export type Plugin = import("@eslint/core").Plugin;
export type RuleConfig = import("@eslint/core").RuleConfig;
export type ExtendsElement = import("./types.cts").ExtendsElement;
export type SimpleExtendsElement = import("./types.cts").SimpleExtendsElement;
export type ConfigWithExtends = import("./types.cts").ConfigWithExtends;
export type InfiniteConfigArray = import("./types.cts").InfiniteArray<Config>;
export type ConfigWithExtendsArray = import("./types.cts").ConfigWithExtendsArray;
export type Config = $eslintcore.ConfigObject;
export type LegacyConfig = $eslintcore.LegacyConfigObject;
export type Plugin = $eslintcore.Plugin;
export type RuleConfig = $eslintcore.RuleConfig;
export type ExtendsElement = $typests.ExtendsElement;
export type SimpleExtendsElement = $typests.SimpleExtendsElement;
export type ConfigWithExtends = $typests.ConfigWithExtends;
export type InfiniteConfigArray = $typests.InfiniteArray<Config>;
export type ConfigWithExtendsArray = $typests.ConfigWithExtendsArray;
/**

@@ -25,1 +25,3 @@ * Helper function to define a config array.

export function globalIgnores(ignorePatterns: string[], name?: string): Config;
import type * as $eslintcore from "@eslint/core";
import type * as $typests from "./types.cts";

@@ -1,10 +0,10 @@

export type Config = import("@eslint/core").ConfigObject;
export type LegacyConfig = import("@eslint/core").LegacyConfigObject;
export type Plugin = import("@eslint/core").Plugin;
export type RuleConfig = import("@eslint/core").RuleConfig;
export type ExtendsElement = import("./types.ts").ExtendsElement;
export type SimpleExtendsElement = import("./types.ts").SimpleExtendsElement;
export type ConfigWithExtends = import("./types.ts").ConfigWithExtends;
export type InfiniteConfigArray = import("./types.ts").InfiniteArray<Config>;
export type ConfigWithExtendsArray = import("./types.ts").ConfigWithExtendsArray;
export type Config = $eslintcore.ConfigObject;
export type LegacyConfig = $eslintcore.LegacyConfigObject;
export type Plugin = $eslintcore.Plugin;
export type RuleConfig = $eslintcore.RuleConfig;
export type ExtendsElement = $typests.ExtendsElement;
export type SimpleExtendsElement = $typests.SimpleExtendsElement;
export type ConfigWithExtends = $typests.ConfigWithExtends;
export type InfiniteConfigArray = $typests.InfiniteArray<Config>;
export type ConfigWithExtendsArray = $typests.ConfigWithExtendsArray;
/**

@@ -25,1 +25,3 @@ * Helper function to define a config array.

export function globalIgnores(ignorePatterns: string[], name?: string): Config;
import type * as $eslintcore from "@eslint/core";
import type * as $typests from "./types.ts";

@@ -11,11 +11,13 @@ // @ts-self-types="./index.d.ts"

/** @typedef {import("@eslint/core").ConfigObject} Config */
/** @typedef {import("@eslint/core").LegacyConfigObject} LegacyConfig */
/** @typedef {import("@eslint/core").Plugin} Plugin */
/** @typedef {import("@eslint/core").RuleConfig} RuleConfig */
/** @typedef {import("./types.ts").ExtendsElement} ExtendsElement */
/** @typedef {import("./types.ts").SimpleExtendsElement} SimpleExtendsElement */
/** @typedef {import("./types.ts").ConfigWithExtends} ConfigWithExtends */
/** @typedef {import("./types.ts").InfiniteArray<Config>} InfiniteConfigArray */
/** @typedef {import("./types.ts").ConfigWithExtendsArray} ConfigWithExtendsArray */
/** @import * as $eslintcore from "@eslint/core"; */
/** @typedef {$eslintcore.ConfigObject} Config */
/** @typedef {$eslintcore.LegacyConfigObject} LegacyConfig */
/** @typedef {$eslintcore.Plugin} Plugin */
/** @typedef {$eslintcore.RuleConfig} RuleConfig */
/** @import * as $typests from "./types.ts"; */
/** @typedef {$typests.ExtendsElement} ExtendsElement */
/** @typedef {$typests.SimpleExtendsElement} SimpleExtendsElement */
/** @typedef {$typests.ConfigWithExtends} ConfigWithExtends */
/** @typedef {$typests.InfiniteArray<Config>} InfiniteConfigArray */
/** @typedef {$typests.ConfigWithExtendsArray} ConfigWithExtendsArray */

@@ -79,2 +81,7 @@ //-----------------------------------------------------------------------------

function isLegacyConfig(config) {
// eslintrc's plugins must be an array; while flat config's must be an object.
if (Array.isArray(config.plugins)) {
return true;
}
for (const key of eslintrcKeys) {

@@ -257,2 +264,4 @@ if (key in config) {

const directConfig = plugin.configs?.[configName];
// Prefer direct config, but fall back to flat config if available
if (directConfig) {

@@ -268,26 +277,24 @@ // Arrays are always flat configs, and non-legacy configs can be used directly

}
}
// If it's a legacy config, look for the flat version
const flatConfig = plugin.configs?.[`flat/${configName}`];
if (
flatConfig &&
(Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))
) {
return deepNormalizePluginConfig(
userPluginNamespace,
plugin,
flatConfig,
pluginConfigName,
);
}
throw new TypeError(
`Plugin config "${configName}" in plugin "${userPluginNamespace}" is an eslintrc config and cannot be used in this context.`,
// If it's a legacy config, or the config does not exist => look for the flat version
const flatConfig = plugin.configs?.[`flat/${configName}`];
if (
flatConfig &&
(Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))
) {
return deepNormalizePluginConfig(
userPluginNamespace,
plugin,
flatConfig,
pluginConfigName,
);
}
throw new TypeError(
`Plugin config "${configName}" not found in plugin "${userPluginNamespace}".`,
);
// If we get here, then the config was either not found or is a legacy config
const message =
directConfig || flatConfig
? `Plugin config "${configName}" in plugin "${userPluginNamespace}" is an eslintrc config and cannot be used in this context.`
: `Plugin config "${configName}" not found in plugin "${userPluginNamespace}".`;
throw new TypeError(message);
}

@@ -294,0 +301,0 @@

{
"name": "@eslint/config-helpers",
"version": "0.4.0",
"version": "0.4.1",
"description": "Helper utilities for creating ESLint configuration",

@@ -31,5 +31,6 @@ "type": "module",

"build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
"test:jsr": "npx jsr@latest publish --dry-run",
"test": "mocha \"tests/**/*.test.js\"",
"test:coverage": "c8 npm test",
"test:jsr": "npx jsr@latest publish --dry-run",
"test:pnpm": "cd tests/pnpm && pnpm install && pnpm exec tsc",
"test:types": "tsc -p tests/types/tsconfig.json"

@@ -36,0 +37,0 @@ },