Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

eslint-flat-config-utils

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-flat-config-utils - npm Package Compare versions

Comparing version
0.0.4
to
0.1.0
+41
-3
dist/index.cjs

@@ -94,3 +94,4 @@ 'use strict';

__publicField(this, "_operations", []);
__publicField(this, "_operationsPost", []);
__publicField(this, "_operationsOverrides", []);
__publicField(this, "_operationsResolved", []);
__publicField(this, "_renames", {});

@@ -161,3 +162,3 @@ }

override(nameOrIndex, config) {
this._operationsPost.push(async (configs) => {
this._operationsOverrides.push(async (configs) => {
const index = getConfigIndex(configs, nameOrIndex);

@@ -181,2 +182,37 @@ const extended = typeof config === "function" ? await config(configs[index]) : mergeConfigs(configs[index], config);

/**
* Remove a specific config by name or index.
*/
remove(nameOrIndex) {
this._operations.push(async (configs) => {
const index = getConfigIndex(configs, nameOrIndex);
configs.splice(index, 1);
return configs;
});
return this;
}
/**
* Replace a specific config by name or index.
*
* The original config will be removed and replaced with the new one.
*/
replace(nameOrIndex, ...items) {
const promise = Promise.all(items);
this._operations.push(async (configs) => {
const resolved = (await promise).flat();
const index = getConfigIndex(configs, nameOrIndex);
configs.splice(index, 1, ...resolved);
return configs;
});
return this;
}
/**
* Hook when all configs are resolved but before returning the final configs.
*
* You can modify the final configs here.
*/
onResolved(callback) {
this._operationsResolved.push(callback);
return this;
}
/**
* Resolve the pipeline and return the final configs.

@@ -190,5 +226,7 @@ *

configs = await promise(configs);
for (const promise of this._operationsPost)
for (const promise of this._operationsOverrides)
configs = await promise(configs);
configs = renamePluginsInConfigs(configs, this._renames);
for (const promise of this._operationsResolved)
configs = await promise(configs) || configs;
return configs;

@@ -195,0 +233,0 @@ }

+23
-6

@@ -141,5 +141,6 @@ import { Linter } from 'eslint';

*/
declare class FlatConfigPipeline<T extends object = FlatConfigItem> extends Promise<T[]> {
declare class FlatConfigPipeline<T extends object = FlatConfigItem, ConfigNames extends string = string> extends Promise<T[]> {
private _operations;
private _operationsPost;
private _operationsOverrides;
private _operationsResolved;
private _renames;

@@ -164,7 +165,7 @@ constructor();

*/
insertBefore(nameOrIndex: string | number, ...items: Awaitable<T | T[]>[]): this;
insertBefore(nameOrIndex: ConfigNames | string | number, ...items: Awaitable<T | T[]>[]): this;
/**
* Insert configs after a specific config.
*/
insertAfter(nameOrIndex: string | number, ...items: Awaitable<T | T[]>[]): this;
insertAfter(nameOrIndex: ConfigNames | string | number, ...items: Awaitable<T | T[]>[]): this;
/**

@@ -175,3 +176,3 @@ * Provide overrides to a specific config.

*/
override(nameOrIndex: string | number, config: T | ((config: T) => Awaitable<T>)): this;
override(nameOrIndex: ConfigNames | string | number, config: T | ((config: T) => Awaitable<T>)): this;
/**

@@ -182,4 +183,20 @@ * Provide overrides to multiple configs as an object map.

*/
overrides(overrides: Record<string | number, T | ((config: T) => Awaitable<T>)>): this;
overrides(overrides: Record<ConfigNames | string | number, T | ((config: T) => Awaitable<T>)>): this;
/**
* Remove a specific config by name or index.
*/
remove(nameOrIndex: ConfigNames | string | number): this;
/**
* Replace a specific config by name or index.
*
* The original config will be removed and replaced with the new one.
*/
replace(nameOrIndex: ConfigNames | string | number, ...items: Awaitable<T | T[]>[]): this;
/**
* Hook when all configs are resolved but before returning the final configs.
*
* You can modify the final configs here.
*/
onResolved(callback: (configs: T[]) => Awaitable<T[] | void>): this;
/**
* Resolve the pipeline and return the final configs.

@@ -186,0 +203,0 @@ *

@@ -141,5 +141,6 @@ import { Linter } from 'eslint';

*/
declare class FlatConfigPipeline<T extends object = FlatConfigItem> extends Promise<T[]> {
declare class FlatConfigPipeline<T extends object = FlatConfigItem, ConfigNames extends string = string> extends Promise<T[]> {
private _operations;
private _operationsPost;
private _operationsOverrides;
private _operationsResolved;
private _renames;

@@ -164,7 +165,7 @@ constructor();

*/
insertBefore(nameOrIndex: string | number, ...items: Awaitable<T | T[]>[]): this;
insertBefore(nameOrIndex: ConfigNames | string | number, ...items: Awaitable<T | T[]>[]): this;
/**
* Insert configs after a specific config.
*/
insertAfter(nameOrIndex: string | number, ...items: Awaitable<T | T[]>[]): this;
insertAfter(nameOrIndex: ConfigNames | string | number, ...items: Awaitable<T | T[]>[]): this;
/**

@@ -175,3 +176,3 @@ * Provide overrides to a specific config.

*/
override(nameOrIndex: string | number, config: T | ((config: T) => Awaitable<T>)): this;
override(nameOrIndex: ConfigNames | string | number, config: T | ((config: T) => Awaitable<T>)): this;
/**

@@ -182,4 +183,20 @@ * Provide overrides to multiple configs as an object map.

*/
overrides(overrides: Record<string | number, T | ((config: T) => Awaitable<T>)>): this;
overrides(overrides: Record<ConfigNames | string | number, T | ((config: T) => Awaitable<T>)>): this;
/**
* Remove a specific config by name or index.
*/
remove(nameOrIndex: ConfigNames | string | number): this;
/**
* Replace a specific config by name or index.
*
* The original config will be removed and replaced with the new one.
*/
replace(nameOrIndex: ConfigNames | string | number, ...items: Awaitable<T | T[]>[]): this;
/**
* Hook when all configs are resolved but before returning the final configs.
*
* You can modify the final configs here.
*/
onResolved(callback: (configs: T[]) => Awaitable<T[] | void>): this;
/**
* Resolve the pipeline and return the final configs.

@@ -186,0 +203,0 @@ *

@@ -141,5 +141,6 @@ import { Linter } from 'eslint';

*/
declare class FlatConfigPipeline<T extends object = FlatConfigItem> extends Promise<T[]> {
declare class FlatConfigPipeline<T extends object = FlatConfigItem, ConfigNames extends string = string> extends Promise<T[]> {
private _operations;
private _operationsPost;
private _operationsOverrides;
private _operationsResolved;
private _renames;

@@ -164,7 +165,7 @@ constructor();

*/
insertBefore(nameOrIndex: string | number, ...items: Awaitable<T | T[]>[]): this;
insertBefore(nameOrIndex: ConfigNames | string | number, ...items: Awaitable<T | T[]>[]): this;
/**
* Insert configs after a specific config.
*/
insertAfter(nameOrIndex: string | number, ...items: Awaitable<T | T[]>[]): this;
insertAfter(nameOrIndex: ConfigNames | string | number, ...items: Awaitable<T | T[]>[]): this;
/**

@@ -175,3 +176,3 @@ * Provide overrides to a specific config.

*/
override(nameOrIndex: string | number, config: T | ((config: T) => Awaitable<T>)): this;
override(nameOrIndex: ConfigNames | string | number, config: T | ((config: T) => Awaitable<T>)): this;
/**

@@ -182,4 +183,20 @@ * Provide overrides to multiple configs as an object map.

*/
overrides(overrides: Record<string | number, T | ((config: T) => Awaitable<T>)>): this;
overrides(overrides: Record<ConfigNames | string | number, T | ((config: T) => Awaitable<T>)>): this;
/**
* Remove a specific config by name or index.
*/
remove(nameOrIndex: ConfigNames | string | number): this;
/**
* Replace a specific config by name or index.
*
* The original config will be removed and replaced with the new one.
*/
replace(nameOrIndex: ConfigNames | string | number, ...items: Awaitable<T | T[]>[]): this;
/**
* Hook when all configs are resolved but before returning the final configs.
*
* You can modify the final configs here.
*/
onResolved(callback: (configs: T[]) => Awaitable<T[] | void>): this;
/**
* Resolve the pipeline and return the final configs.

@@ -186,0 +203,0 @@ *

@@ -92,3 +92,4 @@ function defineFlatConfig(config) {

__publicField(this, "_operations", []);
__publicField(this, "_operationsPost", []);
__publicField(this, "_operationsOverrides", []);
__publicField(this, "_operationsResolved", []);
__publicField(this, "_renames", {});

@@ -159,3 +160,3 @@ }

override(nameOrIndex, config) {
this._operationsPost.push(async (configs) => {
this._operationsOverrides.push(async (configs) => {
const index = getConfigIndex(configs, nameOrIndex);

@@ -179,2 +180,37 @@ const extended = typeof config === "function" ? await config(configs[index]) : mergeConfigs(configs[index], config);

/**
* Remove a specific config by name or index.
*/
remove(nameOrIndex) {
this._operations.push(async (configs) => {
const index = getConfigIndex(configs, nameOrIndex);
configs.splice(index, 1);
return configs;
});
return this;
}
/**
* Replace a specific config by name or index.
*
* The original config will be removed and replaced with the new one.
*/
replace(nameOrIndex, ...items) {
const promise = Promise.all(items);
this._operations.push(async (configs) => {
const resolved = (await promise).flat();
const index = getConfigIndex(configs, nameOrIndex);
configs.splice(index, 1, ...resolved);
return configs;
});
return this;
}
/**
* Hook when all configs are resolved but before returning the final configs.
*
* You can modify the final configs here.
*/
onResolved(callback) {
this._operationsResolved.push(callback);
return this;
}
/**
* Resolve the pipeline and return the final configs.

@@ -188,5 +224,7 @@ *

configs = await promise(configs);
for (const promise of this._operationsPost)
for (const promise of this._operationsOverrides)
configs = await promise(configs);
configs = renamePluginsInConfigs(configs, this._renames);
for (const promise of this._operationsResolved)
configs = await promise(configs) || configs;
return configs;

@@ -193,0 +231,0 @@ }

{
"name": "eslint-flat-config-utils",
"type": "module",
"version": "0.0.4",
"version": "0.1.0",
"packageManager": "pnpm@8.15.5",

@@ -6,0 +6,0 @@ "description": "Utils for managing and manipulating ESLint flat config arrays",