Skip to content

Commit 54920ed

Browse files
authored
test: switch to Linter.Config in ESLintRules type tests (#19977)
1 parent e8a6914 commit 54920ed

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

tests/lib/types/types.test.ts

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,35 +1824,40 @@ for (const result of results) {
18241824

18251825
// #region ESLintRules
18261826

1827-
let eslintConfig: Linter.LegacyConfig<ESLintRules>;
1827+
let eslintConfig: Linter.Config<ESLintRules>[];
18281828

1829-
eslintConfig = {
1830-
rules: {
1831-
"capitalized-comments": [2, "always", { ignorePattern: "const|let" }],
1832-
"no-promise-executor-return": [2, { allowVoid: true }],
1833-
"sort-keys": [2, "asc", { allowLineSeparatedGroups: true }],
1829+
eslintConfig = [
1830+
{
1831+
rules: {
1832+
"capitalized-comments": [
1833+
2,
1834+
"always",
1835+
{ ignorePattern: "const|let" },
1836+
],
1837+
"no-promise-executor-return": [2, { allowVoid: true }],
1838+
"sort-keys": [2, "asc", { allowLineSeparatedGroups: true }],
1839+
},
18341840
},
1835-
overrides: [
1836-
{
1837-
files: "*.json",
1838-
rules: {
1839-
"max-len": 0,
1840-
},
1841+
{
1842+
files: ["**/*.json"],
1843+
rules: {
1844+
"no-restricted-syntax": 0,
18411845
},
1842-
{
1843-
files: "*.ts",
1844-
rules: {
1845-
"@typescript-eslint/no-invalid-void-type": [
1846-
2,
1847-
{ allowAsThisParameter: true },
1848-
],
1849-
},
1846+
},
1847+
{
1848+
files: ["**/*.ts"],
1849+
rules: {
1850+
"@typescript-eslint/no-invalid-void-type": [
1851+
2,
1852+
{ allowAsThisParameter: true },
1853+
],
18501854
},
1851-
],
1852-
};
1855+
},
1856+
];
18531857

1854-
eslintConfig.rules; // $ExpectType Partial<ESLintRules> | undefined
1855-
eslintConfig.overrides?.[0].rules; // $ExpectType Partial<ESLintRules> | undefined
1858+
(configIndex: number) => {
1859+
eslintConfig[configIndex].rules; // $ExpectType Partial<ESLintRules> | undefined
1860+
};
18561861

18571862
interface TSLinterRules {
18581863
"@typescript-eslint/no-invalid-void-type"?: Linter.RuleEntry<
@@ -1865,19 +1870,17 @@ interface TSLinterRules {
18651870
>;
18661871
}
18671872

1868-
const eslintConfig2: Linter.LegacyConfig<
1869-
ESLintRules,
1870-
ESLintRules & TSLinterRules
1871-
> = eslintConfig;
1873+
const eslintConfig2: Linter.Config<ESLintRules & TSLinterRules>[] =
1874+
eslintConfig;
18721875

1873-
eslintConfig2.rules; // $ExpectType Partial<ESLintRules> | undefined
1874-
eslintConfig2.overrides?.[1].rules; // $ExpectType Partial<ESLintRules & TSLinterRules> | undefined
1875-
1876-
const eslintConfig3: Linter.LegacyConfig<ESLintRules & TSLinterRules> =
1877-
eslintConfig2;
1876+
(configIndex: number) => {
1877+
eslintConfig2[configIndex].rules; // $ExpectType Partial<ESLintRules & TSLinterRules> | undefined
1878+
};
18781879

1879-
eslintConfig3.rules; // $ExpectType Partial<ESLintRules & TSLinterRules> | undefined
1880-
eslintConfig3.overrides?.[1].rules; // $ExpectType Partial<ESLintRules & TSLinterRules> | undefined
1880+
(configIndex: number) => {
1881+
const rules: Partial<Linter.RulesRecord> | undefined =
1882+
eslintConfig2[configIndex].rules;
1883+
};
18811884

18821885
// #endregion
18831886

0 commit comments

Comments
 (0)