Skip to content

Commit dfb0df6

Browse files
authored
fix: support rules without meta (#15)
1 parent c34631b commit dfb0df6

File tree

6 files changed

+117
-1
lines changed

6 files changed

+117
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"eslint-plugin-antfu": "catalog:test",
5757
"eslint-plugin-import-x": "catalog:test",
5858
"eslint-plugin-jsx-a11y": "catalog:test",
59+
"eslint-plugin-you-dont-need-lodash-underscore": "catalog:test",
5960
"lint-staged": "catalog:dev",
6061
"pnpm": "catalog:dev",
6162
"simple-git-hooks": "catalog:dev",

pnpm-lock.yaml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ catalogs:
2626
eslint-plugin-antfu: ^3.1.1
2727
eslint-plugin-import-x: ^4.11.1
2828
eslint-plugin-jsx-a11y: ^6.10.2
29+
eslint-plugin-you-dont-need-lodash-underscore: ^6.14.0
2930
vitest: ^3.1.3
3031
onlyBuiltDependencies:
3132
- esbuild

src/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export async function pluginsToRulesDTS(
109109

110110
for (const [pluginName, plugin] of Object.entries(plugins)) {
111111
for (const [ruleName, rule] of Object.entries(plugin.rules || {})) {
112-
if (rule?.meta) {
112+
if (rule?.meta == null || typeof rule.meta === 'object') {
113113
rules.push([
114114
pluginName
115115
? `${pluginName}/${ruleName}`

test/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ it('jsx-a11y', async () => {
5555
}))
5656
.toMatchFileSnapshot('./output/jsx-a11y.d.ts')
5757
})
58+
59+
it('no rule `meta`', async () => {
60+
await expect(await pluginsToRulesDTS({
61+
// @ts-expect-error missing types
62+
'you-dont-need-lodash-underscore': await import('eslint-plugin-you-dont-need-lodash-underscore').then(m => m.default),
63+
}))
64+
.toMatchFileSnapshot('./output/no-rule-meta.d.ts')
65+
})

test/output/no-rule-meta.d.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/* eslint-disable */
2+
/* prettier-ignore */
3+
import type { Linter } from 'eslint'
4+
5+
declare module 'eslint' {
6+
namespace Linter {
7+
interface RulesRecord extends RuleOptions {}
8+
}
9+
}
10+
11+
export interface RuleOptions {
12+
'you-dont-need-lodash-underscore/all'?: Linter.RuleEntry<[]>
13+
'you-dont-need-lodash-underscore/any'?: Linter.RuleEntry<[]>
14+
'you-dont-need-lodash-underscore/assign'?: Linter.RuleEntry<[]>
15+
'you-dont-need-lodash-underscore/bind'?: Linter.RuleEntry<[]>
16+
'you-dont-need-lodash-underscore/capitalize'?: Linter.RuleEntry<[]>
17+
'you-dont-need-lodash-underscore/cast-array'?: Linter.RuleEntry<[]>
18+
'you-dont-need-lodash-underscore/clone-deep'?: Linter.RuleEntry<[]>
19+
'you-dont-need-lodash-underscore/collect'?: Linter.RuleEntry<[]>
20+
'you-dont-need-lodash-underscore/concat'?: Linter.RuleEntry<[]>
21+
'you-dont-need-lodash-underscore/contains'?: Linter.RuleEntry<[]>
22+
'you-dont-need-lodash-underscore/defaults'?: Linter.RuleEntry<[]>
23+
'you-dont-need-lodash-underscore/detect'?: Linter.RuleEntry<[]>
24+
'you-dont-need-lodash-underscore/drop'?: Linter.RuleEntry<[]>
25+
'you-dont-need-lodash-underscore/drop-right'?: Linter.RuleEntry<[]>
26+
'you-dont-need-lodash-underscore/each'?: Linter.RuleEntry<[]>
27+
'you-dont-need-lodash-underscore/ends-with'?: Linter.RuleEntry<[]>
28+
'you-dont-need-lodash-underscore/entries'?: Linter.RuleEntry<[]>
29+
'you-dont-need-lodash-underscore/every'?: Linter.RuleEntry<[]>
30+
'you-dont-need-lodash-underscore/extend-own'?: Linter.RuleEntry<[]>
31+
'you-dont-need-lodash-underscore/fill'?: Linter.RuleEntry<[]>
32+
'you-dont-need-lodash-underscore/filter'?: Linter.RuleEntry<[]>
33+
'you-dont-need-lodash-underscore/find'?: Linter.RuleEntry<[]>
34+
'you-dont-need-lodash-underscore/find-index'?: Linter.RuleEntry<[]>
35+
'you-dont-need-lodash-underscore/first'?: Linter.RuleEntry<[]>
36+
'you-dont-need-lodash-underscore/flatten'?: Linter.RuleEntry<[]>
37+
'you-dont-need-lodash-underscore/foldl'?: Linter.RuleEntry<[]>
38+
'you-dont-need-lodash-underscore/foldr'?: Linter.RuleEntry<[]>
39+
'you-dont-need-lodash-underscore/for-each'?: Linter.RuleEntry<[]>
40+
'you-dont-need-lodash-underscore/get'?: Linter.RuleEntry<[]>
41+
'you-dont-need-lodash-underscore/head'?: Linter.RuleEntry<[]>
42+
'you-dont-need-lodash-underscore/includes'?: Linter.RuleEntry<[]>
43+
'you-dont-need-lodash-underscore/index-of'?: Linter.RuleEntry<[]>
44+
'you-dont-need-lodash-underscore/inject'?: Linter.RuleEntry<[]>
45+
'you-dont-need-lodash-underscore/is-array'?: Linter.RuleEntry<[]>
46+
'you-dont-need-lodash-underscore/is-array-buffer'?: Linter.RuleEntry<[]>
47+
'you-dont-need-lodash-underscore/is-date'?: Linter.RuleEntry<[]>
48+
'you-dont-need-lodash-underscore/is-finite'?: Linter.RuleEntry<[]>
49+
'you-dont-need-lodash-underscore/is-function'?: Linter.RuleEntry<[]>
50+
'you-dont-need-lodash-underscore/is-integer'?: Linter.RuleEntry<[]>
51+
'you-dont-need-lodash-underscore/is-nan'?: Linter.RuleEntry<[]>
52+
'you-dont-need-lodash-underscore/is-nil'?: Linter.RuleEntry<[]>
53+
'you-dont-need-lodash-underscore/is-null'?: Linter.RuleEntry<[]>
54+
'you-dont-need-lodash-underscore/is-string'?: Linter.RuleEntry<[]>
55+
'you-dont-need-lodash-underscore/is-undefined'?: Linter.RuleEntry<[]>
56+
'you-dont-need-lodash-underscore/join'?: Linter.RuleEntry<[]>
57+
'you-dont-need-lodash-underscore/keys'?: Linter.RuleEntry<[]>
58+
'you-dont-need-lodash-underscore/last'?: Linter.RuleEntry<[]>
59+
'you-dont-need-lodash-underscore/last-index-of'?: Linter.RuleEntry<[]>
60+
'you-dont-need-lodash-underscore/map'?: Linter.RuleEntry<[]>
61+
'you-dont-need-lodash-underscore/omit'?: Linter.RuleEntry<[]>
62+
'you-dont-need-lodash-underscore/pad-end'?: Linter.RuleEntry<[]>
63+
'you-dont-need-lodash-underscore/pad-start'?: Linter.RuleEntry<[]>
64+
'you-dont-need-lodash-underscore/pairs'?: Linter.RuleEntry<[]>
65+
'you-dont-need-lodash-underscore/reduce'?: Linter.RuleEntry<[]>
66+
'you-dont-need-lodash-underscore/reduce-right'?: Linter.RuleEntry<[]>
67+
'you-dont-need-lodash-underscore/repeat'?: Linter.RuleEntry<[]>
68+
'you-dont-need-lodash-underscore/replace'?: Linter.RuleEntry<[]>
69+
'you-dont-need-lodash-underscore/reverse'?: Linter.RuleEntry<[]>
70+
'you-dont-need-lodash-underscore/select'?: Linter.RuleEntry<[]>
71+
'you-dont-need-lodash-underscore/size'?: Linter.RuleEntry<[]>
72+
'you-dont-need-lodash-underscore/slice'?: Linter.RuleEntry<[]>
73+
'you-dont-need-lodash-underscore/some'?: Linter.RuleEntry<[]>
74+
'you-dont-need-lodash-underscore/split'?: Linter.RuleEntry<[]>
75+
'you-dont-need-lodash-underscore/starts-with'?: Linter.RuleEntry<[]>
76+
'you-dont-need-lodash-underscore/take-right'?: Linter.RuleEntry<[]>
77+
'you-dont-need-lodash-underscore/throttle'?: Linter.RuleEntry<[]>
78+
'you-dont-need-lodash-underscore/to-lower'?: Linter.RuleEntry<[]>
79+
'you-dont-need-lodash-underscore/to-pairs'?: Linter.RuleEntry<[]>
80+
'you-dont-need-lodash-underscore/to-upper'?: Linter.RuleEntry<[]>
81+
'you-dont-need-lodash-underscore/trim'?: Linter.RuleEntry<[]>
82+
'you-dont-need-lodash-underscore/union-by'?: Linter.RuleEntry<[]>
83+
'you-dont-need-lodash-underscore/uniq'?: Linter.RuleEntry<[]>
84+
'you-dont-need-lodash-underscore/values'?: Linter.RuleEntry<[]>
85+
}
86+
87+
/* ======= Declarations ======= */

0 commit comments

Comments
 (0)