Skip to content

Commit 2fee9bb

Browse files
authored
feat: export ConfigObject from eslint/config (#21082)
1 parent e7d1e43 commit 2fee9bb

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

lib/types/config-api.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55

66
import {
77
type Config,
8+
type ConfigObject,
89
defineConfig,
910
globalIgnores,
1011
includeIgnoreFile,
1112
} from "@eslint/config-helpers";
1213

13-
export { type Config, defineConfig, globalIgnores, includeIgnoreFile };
14+
export {
15+
type Config,
16+
type ConfigObject,
17+
defineConfig,
18+
globalIgnores,
19+
includeIgnoreFile,
20+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"@eslint-community/eslint-utils": "^4.8.0",
130130
"@eslint-community/regexpp": "^4.12.2",
131131
"@eslint/config-array": "^0.23.5",
132-
"@eslint/config-helpers": "^0.6.0",
132+
"@eslint/config-helpers": "^0.7.0",
133133
"@eslint/core": "^1.2.1",
134134
"@eslint/plugin-kit": "^0.7.2",
135135
"@humanfs/node": "^0.16.6",

tests/lib/types/types.test.mts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ import {
3737
type Rule,
3838
type Scope,
3939
} from "eslint";
40-
import { defineConfig, globalIgnores, includeIgnoreFile } from "eslint/config";
40+
import {
41+
type Config,
42+
type ConfigObject,
43+
defineConfig,
44+
globalIgnores,
45+
includeIgnoreFile,
46+
} from "eslint/config";
4147
import type { ESLintRules } from "eslint/rules";
4248
import { Linter as ESLinter } from "eslint/universal";
4349
import { builtinRules, shouldUseFlatConfig } from "eslint/use-at-your-own-risk";
@@ -2464,7 +2470,32 @@ shouldUseFlatConfig(); // $ExpectType Promise<true>
24642470

24652471
// #endregion
24662472

2467-
// #region defineConfig
2473+
// #region eslint/config
2474+
2475+
const configObject: ConfigObject = {
2476+
name: "example config",
2477+
files: ["**/*.js", ["**/*.ts", "**/src/*.*"]],
2478+
ignores: ["**/vendor/**"],
2479+
language: "js/js",
2480+
languageOptions: {
2481+
ecmaVersion: 2022,
2482+
sourceType: "module",
2483+
},
2484+
linterOptions: {
2485+
noInlineConfig: false,
2486+
reportUnusedDisableDirectives: true,
2487+
},
2488+
plugins: {
2489+
custom: { meta: { name: "custom-plugin", version: "1.0.0" } },
2490+
},
2491+
rules: {
2492+
"no-console": "warn",
2493+
eqeqeq: ["error", "always"],
2494+
},
2495+
settings: {
2496+
foo: "bar",
2497+
},
2498+
} satisfies Config;
24682499

24692500
defineConfig([
24702501
{

0 commit comments

Comments
 (0)