Skip to content

Commit aa97582

Browse files
authored
fix: update TypedFlatConfigItem to provide rules auto-completion (#742)
1 parent 8ecfdde commit aa97582

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/cli/constants-generated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const versionsMap = {
22
"@eslint-react/eslint-plugin": "^1.52.3",
3-
"@next/eslint-plugin-next": "^15.4.0-canary.115",
3+
"@next/eslint-plugin-next": "^15.4.3",
44
"@unocss/eslint-plugin": "^66.3.3",
55
"astro-eslint-parser": "^1.2.2",
66
"eslint": "^9.31.0",

src/configs/nextjs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export async function nextjs(
4141
},
4242
sourceType: 'module',
4343
},
44+
name: 'antfu/nextjs/rules',
4445
rules: {
4546
...normalizeRules(pluginNextJS.configs.recommended.rules),
4647
...normalizeRules(pluginNextJS.configs['core-web-vitals'].rules),

src/types.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,29 @@ import type { VendoredPrettierOptions } from './vender/prettier-types'
88

99
export type Awaitable<T> = T | Promise<T>
1010

11-
export interface Rules extends RuleOptions {}
11+
export type Rules = Record<string, Linter.RuleEntry<any> | undefined> & RuleOptions
1212

1313
export type { ConfigNames }
1414

15-
export type TypedFlatConfigItem = Omit<Linter.Config<Linter.RulesRecord & Rules>, 'plugins' | 'rules'> & {
16-
// Relax plugins type limitation, as most of the plugins did not have correct type info yet.
15+
/**
16+
* An updated version of ESLint's `Linter.Config`, which provides autocompletion
17+
* for `rules` and relaxes type limitations for `plugins` and `rules`, because
18+
* many plugins still lack proper type definitions.
19+
*/
20+
export type TypedFlatConfigItem = Omit<Linter.Config, 'plugins' | 'rules'> & {
1721
/**
18-
* An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files.
22+
* An object containing a name-value mapping of plugin names to plugin objects.
23+
* When `files` is specified, these plugins are only available to the matching files.
1924
*
2025
* @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
2126
*/
2227
plugins?: Record<string, any>
2328

2429
/**
25-
* Rules configuration. More flexible to allow plugin rules that may not be perfectly typed.
30+
* An object containing the configured rules. When `files` or `ignores` are
31+
* specified, these rule configurations are only available to the matching files.
2632
*/
27-
rules?: Record<string, Linter.RuleEntry<any> | undefined>
33+
rules?: Rules
2834
}
2935

3036
export interface OptionsFiles {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy