Skip to content

Commit c591da6

Browse files
authored
feat: Add language to types (#18917)
1 parent 91cbd18 commit c591da6

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

lib/types/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727

2828
import * as ESTree from "estree";
29+
import { Language } from "@eslint/core";
2930
import { JSONSchema4 } from "json-schema";
3031
import { LegacyESLint } from "./use-at-your-own-risk.js";
3132

@@ -1265,6 +1266,13 @@ export namespace Linter {
12651266
*/
12661267
ignores?: string[];
12671268

1269+
/**
1270+
* The name of the language used for linting. This is used to determine the
1271+
* parser and other language-specific settings.
1272+
* @since 9.7.0
1273+
*/
1274+
language?: string;
1275+
12681276
/**
12691277
* An object containing settings related to how JavaScript is configured for
12701278
* linting.
@@ -1441,6 +1449,7 @@ export namespace ESLint {
14411449
interface Plugin extends ObjectMetaProperties {
14421450
configs?: Record<string, Linter.LegacyConfig | Linter.Config | Linter.Config[]> | undefined;
14431451
environments?: Record<string, Environment> | undefined;
1452+
languages?: Record<string, Language> | undefined;
14441453
processors?: Record<string, Linter.Processor> | undefined;
14451454
rules?: Record<string, Rule.RuleModule> | undefined;
14461455
}

tests/lib/types/types.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
shouldUseFlatConfig,
3636
} from "eslint/use-at-your-own-risk";
3737
import { Comment, PrivateIdentifier, PropertyDefinition, StaticBlock, WhileStatement } from "estree";
38+
import { Language } from "@eslint/core";
3839

3940
const SOURCE = `var foo = bar;`;
4041

@@ -1354,6 +1355,15 @@ ruleTester.run("simple-valid-test", rule, {
13541355

13551356
// #region Config
13561357

1358+
((): Linter.Config => ({
1359+
language: "js/js"
1360+
}));
1361+
1362+
((): Linter.Config => ({
1363+
// @ts-expect-error
1364+
language: null
1365+
}));
1366+
13571367
((): Linter.Config => ({
13581368
languageOptions: {
13591369
parser: {
@@ -1496,6 +1506,16 @@ flatConfig = config;
14961506

14971507
// #endregion Config
14981508

1509+
// #region Plugins
1510+
1511+
((): ESLint.Plugin => ({
1512+
languages: {
1513+
"js": {} as Language
1514+
}
1515+
}));
1516+
1517+
// #endregion Plugins
1518+
14991519
(async (useFlatConfig?: boolean) => {
15001520
await loadESLint(); // $ExpectType typeof ESLint | typeof LegacyESLint
15011521
await loadESLint({}); // $ExpectType typeof ESLint | typeof LegacyESLint

0 commit comments

Comments
 (0)