Skip to content

Commit 006d74f

Browse files
feat: add type declaration file (#279)
* Add type declaration file Hand roll a type declaration file for `flat.js` that accurately reflects the exported plugin. This resolves type errors when attempting to use `globals` and `recommended` configs in type-checked eslint configs and also aids in autocomplete when typing (as in keyboard button press, not "does it satisfy expected type") properties of the plugin. * (Revisions) Add type declaration file Update code style from review Co-authored-by: Mike McCready <[email protected]> --------- Co-authored-by: Mike McCready <[email protected]>
1 parent 9015c2e commit 006d74f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/flat.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { ESLint, Linter } from 'eslint'
2+
3+
declare const plugin: {
4+
meta: { name: string, version: string }
5+
configs: {
6+
globals: Linter.Config<Linter.RulesRecord>
7+
recommended: Linter.Config<Linter.RulesRecord>
8+
}
9+
rules: NonNullable<ESLint.Plugin['rules']>
10+
}
11+
12+
export = plugin

0 commit comments

Comments
 (0)