import { ConfigWithExtends } from "@eslint/config-helpers"; import { ESLintUtils, TSESLint } from "@typescript-eslint/utils"; import { ConfigObject, ConfigObject as ConfigObject$1, RulesConfig, RulesConfig as RulesConfig$1 } from "@eslint/core"; import { Linter } from "eslint"; import ts from "typescript"; //#region src/utils/resolver.d.ts /** * A resolver for file paths relative to a base URL. */ declare class PathResolver { #private; constructor(url: string); /** * @returns * The directory path of the URL passed to the constructor. */ get root(): string; /** * Converts a file path relative to 'root' to an absolute file path. * * @param file * The file path to be converted. * * @returns * The absolute file path. */ path(file: string): string; } //#endregion //#region src/utils/utils.d.ts type DeepOptArray = T | false | null | undefined | ReadonlyArray>; //#endregion //#region src/eslint/shared/env-utils.d.ts type Config = ConfigObject$1 | ConfigWithExtends | Linter.Config | TSESLint.FlatConfig.Config; type ConfigArg = DeepOptArray; /** * Configuration options for language and project setup. */ interface LanguageOptions { /** * The ECMAScript version to be used in the project (version or year). * * @default 'latest' */ ecmaVersion?: Linter.EcmaVersion; /** * Specifies how to treat `.js`, `.jsx`, `.ts`, and `.tsx` files. * * - 'module': The files will be considered being ES modules. * - 'commonjs': The files will be considered being CommonJS modules. * * @default 'module' */ sourceType?: 'module' | 'commonjs'; } /** * Configuration options for external package dependencies. */ interface PackagesOptions { /** * A list of packages to be allowed in the project even if they have been * banned by the plugin `eslint-plugin-depend`. */ allowed?: readonly string[]; /** * A list of additional packages to be banned in the project. */ banned?: readonly string[]; } /** * Configuration options for code indentation per file type. */ interface IndentOverridesOptions { /** * Indentation size for JavaScript and TypeScript files, including JSX. */ js?: number; /** * Indentation size for JSON files. */ json?: number; /** * Indentation size for YAML files. */ yaml?: number; /** * Indentation size for Vue.js files (script and template blocks). */ vue?: number; } /** * Configuration options for code style. */ interface StylisticOptions { /** * Default indentation (number of space characters) for all file types. * * @default 2 */ indent?: number; /** * Indentation (number of space characters) overrides for specific file * types. * * @default 2 */ indentOverrides?: IndentOverridesOptions; /** * Specifies how to treat semicolons. * * - 'always': Require semicolons following all statements. * - 'never': Require to omit semicolons according to ASI rules. * - 'off': Semicolons will not be checked. * * @default 'never' */ semi?: 'always' | 'never' | 'off'; /** * The type of the string delimiter character. * * @default 'single' */ quotes?: 'single' | 'double' | 'off'; /** * Specifies how to treat dangling commas in multiline lists. * * - 'always': Dangling commas will be required in all multi-line array * literals, object literals, function parameters, template parameters, * imports, and exports. * - 'never': Dangling commas will be forbidden. * - 'off': Dangling commas will not be checked. * * @default 'always' */ dangle?: 'always' | 'never' | 'off'; } /** * Shared options for an environment preset with included and excluded files. */ interface EnvFilesOptions { /** * Path to a sub directory to apply the environment preset to. The options * 'files' and 'ignores' will be interpreted relatively to this path. * * @default '.' */ basePath?: string; /** * Glob patterns for source files to be included into the environment. A file * will be included if it matches one of the patterns. Inner arrays can be * used to express AND conditions for files. */ files: ReadonlyArray; /** * Glob patterns for source files matching `files` to be ignored. * * @default [] */ ignores?: readonly string[]; } /** * Shared options for an environment preset: include and exclude files, and add * more linter rules. */ interface EnvBaseOptions extends EnvFilesOptions { /** * Additional linter rules to be added to the configuration. */ rules?: RulesConfig$1; } //#endregion //#region src/eslint/core/vue.d.ts /** * Configuration options for Vue source files. */ interface VueOptions { /** * Names of all globally registered directives to be ignored by the rule * `vue/no-undef-directives` (without 'v-' prefix). */ globalDirectives?: readonly string[]; } //#endregion //#region src/eslint/shared/restricted.d.ts /** * Configuration for a single banned global or import. */ interface EnvRestrictedName { name: string; message: string; } /** * Configuration for a single banned object property. */ interface EnvRestrictedProperty { object: string; property: string; message: string; } /** * Configuration for a single banned syntax construct. */ interface EnvRestrictedSyntax { selector: string; message: string; } /** * Collection of banned globals, imports, properties, and syntax constructs. */ interface EnvRestrictedItems { /** The global symbols to be banned. */ globals?: EnvRestrictedName[]; /** The module imports to be banned. */ imports?: EnvRestrictedName[]; /** The global object properties to be banned. */ properties?: EnvRestrictedProperty[]; /** The syntax constructs to be banned. */ syntax?: EnvRestrictedSyntax[]; } /** * Collection of banned globals, imports, properties, and syntax constructs, * for a specific subset of the files included in an environment. */ interface EnvRestrictedOverride extends EnvFilesOptions, EnvRestrictedItems {} /** * Type shape of a dedicated environment option 'restricted' with settings for * banned globals, imports, properties, and syntax constructs. */ interface EnvRestrictedOption extends EnvRestrictedItems { /** * Overrides for specific subsets of files in the environment. All restricted * items of overrides will be merged with the common restricted items defined * for the entire environment. */ overrides?: EnvRestrictedOverride[]; } /** * Shared options for an environment preset: include and exclude files, add * more linter rules, and settings for restricted items. */ interface EnvRestrictedOptions extends EnvBaseOptions { /** * All globals, imports, properties, and syntax constructs to be banned for * the files included by the environment. */ restricted?: EnvRestrictedOption; } //#endregion //#region src/eslint/env/node.d.ts type EnvNodeConvertPathPattern = [pattern: string, replacement: string]; /** * Configuration for the record-style setting 'convertPath' of the plugin * `eslint-plugin-n`. */ type EnvNodeConvertPathRecord = Record; /** * Configuration for the elements in the array-style setting 'convertPath' of * the plugin `eslint-plugin-n`. */ interface EnvNodeConvertPathElement { include: string[]; exclude?: string[]; replace: EnvNodeConvertPathPattern; } /** * Shared settings for the plugin `eslint-plugin-n`. */ interface EnvNodeSharedSettings { version?: string; allowModules?: string[]; resolvePaths?: string[]; convertPath?: EnvNodeConvertPathRecord | EnvNodeConvertPathElement[]; tryExtensions?: string[]; tsconfigPath?: string[]; typescriptExtensionMap?: ts.server.protocol.JsxEmit | Array<[string, string]>; } /** * Configuration options for the environment preset 'env.node'. */ interface EnvNodeOptions extends EnvRestrictedOptions { /** * The module mode used by the linted files. * * @default 'module' */ sourceType?: LanguageOptions['sourceType']; /** * Shared settings for the plugin `eslint-plugin-n`. Will be merged into the * settings object with the key 'n'. */ settings?: EnvNodeSharedSettings; } /** * Creates configuration objects with global symbols and linter rules for * NodeJS modules. * * Wraps the following packages: * - `eslint-plugin-n` * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function node(envOptions: EnvNodeOptions): ConfigArg; //#endregion //#region src/eslint/env/browser.d.ts /** * Configuration options for the environment preset 'env.browser'. */ interface EnvBrowserOptions extends EnvRestrictedOptions {} /** * Creates configuration objects with global symbols and linter rules for for * browser modules. * * Wraps the following packages: * - `globals` * - `confusing-browser-globals` * - `eslint-plugin-no-unsanitized` * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function browser(envOptions: EnvBrowserOptions): ConfigArg; //#endregion //#region src/eslint/shared/unittest.d.ts /** * Shared options for environment presets for unit tests. */ interface EnvUnitTestOptions extends EnvBaseOptions { /** * Specifies whether to include `eslint-plugin-jest-extended`. Should only be * used, if the package `jest-extended` has been installed in the project. * * @default false */ jestExtended?: boolean; /** * Specifies whether to include `eslint-plugin-jest-dom`. Should only be * used, if the package `@testing-library/jest-dom` has been installed in the * project. * * @default false */ jestDom?: boolean; /** * Specifies the recommended rule set of `eslint-plugin-testing-library` to * be included. */ testingLib?: 'angular' | 'dom' | 'marko' | 'react' | 'vue'; } //#endregion //#region src/eslint/env/jest.d.ts /** * Configuration options for the environment preset 'env.jest'. */ interface EnvJestOptions extends EnvUnitTestOptions {} /** * Creates configuration objects with global symbols and linter rules for unit * tests using Jest. * * Wraps the following packages: * - `eslint-plugin-jest` * - `eslint-plugin-jest-extended` * - `eslint-plugin-jest-dom` * - `eslint-plugin-testing-library` * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function jest(envOptions: EnvJestOptions): ConfigArg; //#endregion //#region src/eslint/env/vitest.d.ts /** * Configuration options for the environment preset 'env.vitest'. */ interface EnvVitestOptions extends EnvUnitTestOptions {} /** * Creates configuration objects with global symbols and linter rules for unit * tests using Vitest. * * Wraps the following packages: * - `eslint-plugin-vitest` * - `eslint-plugin-jest-extended` * - `eslint-plugin-jest-dom` * - `eslint-plugin-testing-library` * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function vitest(envOptions: EnvVitestOptions): ConfigArg; //#endregion //#region src/eslint/env/codecept.d.ts /** * Configuration options for the environment preset 'env.codecept'. */ interface EnvCodeceptOptions extends EnvBaseOptions {} /** * Creates configuration objects with global symbols and linter rules for E2E * tests using CodeceptJS. * * Wraps the following packages: * - `eslint-plugin-codeceptjs` * - `eslint-plugin-chai-expect` * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function codecept(envOptions: EnvCodeceptOptions): ConfigArg; //#endregion //#region src/eslint/env/react.d.ts /** * Configuration options for the environment preset 'env.react'. */ interface EnvReactOptions extends EnvBaseOptions { /** * Configuration for the rule '@eslint-react/rules-of-hooks'. * * Additional hooks that will be treated as effect hooks, like 'useEffect'. */ effectHooks?: readonly string[]; /** * Configuration for the rule '@eslint-react/set-state-in-effect'. * * Additional hooks that will be treated as state hooks, like 'useState'. */ stateHooks?: readonly string[]; } /** * Creates configuration objects with linter rules for ReactJS. * * Wraps the following packages: * - `@eslint-react/eslint-plugin` * - `eslint-plugin-react-hooks` * - `eslint-plugin-react-refresh` * - `eslint-plugin-jsx-a11y` * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function react(envOptions: EnvReactOptions): ConfigArg; //#endregion //#region src/eslint/env/eslint.d.ts /** * Configuration options for the environment preset 'env.eslint'. */ interface EnvEslintOptions extends EnvBaseOptions {} /** * Adds linter rules for ESLint plugin implementations. * * Wraps the following packages: * - `eslint-plugin-eslint-plugin` * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function eslint(envOptions: EnvEslintOptions): ConfigArg; //#endregion //#region src/eslint/shared/rule-utils.d.ts /** * Shared settings used by multiple rules. */ interface SharedRuleSettings { /** * Maps all alias prefixes to actual paths in the project. */ alias?: Record; } //#endregion //#region src/eslint/rules/project/noInvalidModules.d.ts /** * Configuration for the rule 'env-project/no-invalid-modules'. */ interface RuleNoInvalidModulesOptions { /** * Specifies glob patterns for external modules. */ external?: string[]; } //#endregion //#region src/eslint/rules/project/noInvalidHierarchy.d.ts /** * Configuration for the rule 'env-project/no-invalid-hierarchy' to specify a * sub package inside a project. */ interface RuleNoInvalidHierarchyPackage { /** * Glob patterns selecting all source files that are part of the package. */ files: string[]; /** * Specifies the names of all packages (keys of the `packages` dictionary) * this package depends on. */ extends?: string | string[]; /** * Set to `true` to mark an optional package that may be missing in an * installation. Such a package cannot be imported statically (with `import` * statement) from a non-optional package, but can only be loaded dynamically * at runtime (by calling `import()`). The rule will mark all static imports * of optional code as an error. * * @default false */ optional?: boolean; } type RuleNoInvalidHierarchyOptions = Record; //#endregion //#region src/eslint/env/project.d.ts /** * Configuration options for the environment preset 'env.project'. */ interface EnvProjectOptions extends EnvBaseOptions { /** * Maps all alias prefixes to actual paths in the project. */ alias?: SharedRuleSettings['alias']; /** * Options to be passed to the rule 'env-project/no-invalid-modules'. */ external?: RuleNoInvalidModulesOptions['external']; /** * Options to be passed to the rule 'env-project/no-invalid-hierarchy'. */ hierarchy?: RuleNoInvalidHierarchyOptions; } /** * Adds custom linter rules for checking project setup and module hierarchy. * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function project(envOptions: EnvProjectOptions): ConfigArg; //#endregion //#region src/eslint/env/tsconfig.d.ts /** * Configuration options for the environment preset 'env.tsconfig'. */ interface EnvTSConfigOptions extends EnvBaseOptions { /** * The path to the TypeScript project configuration file (`tsconfig.json`). */ project: string; } /** * Creates configuration objects for TypeScript projects. * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function tsconfig(envOptions: EnvTSConfigOptions): ConfigArg; //#endregion //#region src/eslint/env/decorators.d.ts /** * Adds support for native decorators in JavaScript source files. * * Wraps the following packages: * - `@babel/eslint-parser` * - `@babel/plugin-proposal-decorators` * * @param envOptions * Configuration options for the environment. * * @returns * The configuration entries to be added to the resulting configuration array. */ declare function decorators(envOptions: EnvBaseOptions): ConfigArg; //#endregion //#region src/eslint/index.d.ts /** * Configuration options for linting the entire project with ESLint. */ interface ProjectOptions { /** * The URL of the project root containing the ESLint configuration file. * Should usually be set to `import.meta.url`. */ root: string; /** * Glob patterns with all files and folders to be ignored by ESLint. */ ignores?: readonly string[]; /** * Path to the template file containing the license header to be used in all * source files. May be a path relative to the project root. */ license?: string; /** * Configuration options for language and project setup. */ language?: LanguageOptions; /** * Configuration options for external package dependencies. */ packages?: PackagesOptions; /** * Configuration options for code style. */ stylistic?: StylisticOptions; /** * Additional configuration options for Vue source files. */ vue?: VueOptions; /** * Additional linter rules to be added to the global configuration. */ rules?: RulesConfig; } /** * A collection with all available environment presets. */ declare const env: { readonly node: typeof node; readonly browser: typeof browser; readonly jest: typeof jest; readonly vitest: typeof vitest; readonly codecept: typeof codecept; readonly react: typeof react; readonly eslint: typeof eslint; readonly project: typeof project; readonly tsconfig: typeof tsconfig; readonly decorators: typeof decorators; }; /** * Generates a complete ESLint configuration array. * * @param options * Options for the base configuration that will be generated. * * @param configs * Additional configuration entries: Each parameter may be a callback function * that will be invoked with a `PathResolver` utility. * * @returns * The resulting ESLint configuration array that must be returned from the * `eslint.config.*` file. */ declare function defineConfig(options: ProjectOptions, ...configs: Array ConfigArg)>): ConfigObject[]; //#endregion export { type ConfigObject, type LanguageOptions, type PackagesOptions, ProjectOptions, type RulesConfig, type StylisticOptions, type VueOptions, defineConfig, env }; //# sourceMappingURL=index.d.mts.map