Skip to content

Commit d9120ae

Browse files
fix: tests incompatible with Rule.RuleModule
1 parent 4b72915 commit d9120ae

File tree

2 files changed

+61
-58
lines changed

2 files changed

+61
-58
lines changed

src/index.ts

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { ESLint } from 'eslint';
1+
import type { TSESLint } from '@typescript-eslint/utils';
2+
import type { ESLint, Rule } from 'eslint';
23
import { name, version } from '../package.json';
34
import { createRecommendedConfig } from './configs/recommended';
45
import { createStrictConfig } from './configs/strict';
@@ -49,55 +50,58 @@ import { preferRootOperatorsRule } from './rules/prefer-root-operators';
4950
import { suffixSubjectsRule } from './rules/suffix-subjects';
5051
import { throwErrorRule } from './rules/throw-error';
5152

53+
const allRules = {
54+
'ban-observables': banObservablesRule,
55+
'ban-operators': banOperatorsRule,
56+
'finnish': finnishRule,
57+
'just': justRule,
58+
'macro': macroRule,
59+
'no-async-subscribe': noAsyncSubscribeRule,
60+
'no-compat': noCompatRule,
61+
'no-connectable': noConnectableRule,
62+
'no-create': noCreateRule,
63+
'no-cyclic-action': noCyclicActionRule,
64+
'no-explicit-generics': noExplicitGenericsRule,
65+
'no-exposed-subjects': noExposedSubjectsRule,
66+
'no-finnish': noFinnishRule,
67+
'no-floating-observables': noFloatingObservablesRule,
68+
'no-ignored-default-value': noIgnoredDefaultValueRule,
69+
'no-ignored-error': noIgnoredErrorRule,
70+
'no-ignored-notifier': noIgnoredNotifierRule,
71+
'no-ignored-replay-buffer': noIgnoredReplayBufferRule,
72+
'no-ignored-subscribe': noIgnoredSubscribeRule,
73+
'no-ignored-subscription': noIgnoredSubscriptionRule,
74+
'no-ignored-takewhile-value': noIgnoredTakewhileValueRule,
75+
'no-implicit-any-catch': noImplicitAnyCatchRule,
76+
'no-index': noIndexRule,
77+
'no-internal': noInternalRule,
78+
'no-misused-observables': noMisusedObservablesRule,
79+
'no-nested-subscribe': noNestedSubscribeRule,
80+
'no-redundant-notify': noRedundantNotifyRule,
81+
'no-sharereplay': noSharereplayRule,
82+
'no-subclass': noSubclassRule,
83+
'no-subject-unsubscribe': noSubjectUnsubscribeRule,
84+
'no-subject-value': noSubjectValueRule,
85+
'no-subscribe-handlers': noSubscribeHandlersRule,
86+
'no-subscribe-in-pipe': noSubscribeInPipeRule,
87+
'no-tap': noTapRule,
88+
'no-topromise': noTopromiseRule,
89+
'no-unbound-methods': noUnboundMethodsRule,
90+
'no-unsafe-catch': noUnsafeCatchRule,
91+
'no-unsafe-first': noUnsafeFirstRule,
92+
'no-unsafe-subject-next': noUnsafeSubjectNext,
93+
'no-unsafe-switchmap': noUnsafeSwitchmapRule,
94+
'no-unsafe-takeuntil': noUnsafeTakeuntilRule,
95+
'prefer-observer': preferObserverRule,
96+
'prefer-root-operators': preferRootOperatorsRule,
97+
'suffix-subjects': suffixSubjectsRule,
98+
'throw-error': throwErrorRule,
99+
} satisfies TSESLint.FlatConfig.Plugin['rules'];
100+
52101
const plugin = {
53102
meta: { name, version },
54-
rules: {
55-
'ban-observables': banObservablesRule,
56-
'ban-operators': banOperatorsRule,
57-
'finnish': finnishRule,
58-
'just': justRule,
59-
'macro': macroRule,
60-
'no-async-subscribe': noAsyncSubscribeRule,
61-
'no-compat': noCompatRule,
62-
'no-connectable': noConnectableRule,
63-
'no-create': noCreateRule,
64-
'no-cyclic-action': noCyclicActionRule,
65-
'no-explicit-generics': noExplicitGenericsRule,
66-
'no-exposed-subjects': noExposedSubjectsRule,
67-
'no-finnish': noFinnishRule,
68-
'no-floating-observables': noFloatingObservablesRule,
69-
'no-ignored-default-value': noIgnoredDefaultValueRule,
70-
'no-ignored-error': noIgnoredErrorRule,
71-
'no-ignored-notifier': noIgnoredNotifierRule,
72-
'no-ignored-replay-buffer': noIgnoredReplayBufferRule,
73-
'no-ignored-subscribe': noIgnoredSubscribeRule,
74-
'no-ignored-subscription': noIgnoredSubscriptionRule,
75-
'no-ignored-takewhile-value': noIgnoredTakewhileValueRule,
76-
'no-implicit-any-catch': noImplicitAnyCatchRule,
77-
'no-index': noIndexRule,
78-
'no-internal': noInternalRule,
79-
'no-misused-observables': noMisusedObservablesRule,
80-
'no-nested-subscribe': noNestedSubscribeRule,
81-
'no-redundant-notify': noRedundantNotifyRule,
82-
'no-sharereplay': noSharereplayRule,
83-
'no-subclass': noSubclassRule,
84-
'no-subject-unsubscribe': noSubjectUnsubscribeRule,
85-
'no-subject-value': noSubjectValueRule,
86-
'no-subscribe-handlers': noSubscribeHandlersRule,
87-
'no-subscribe-in-pipe': noSubscribeInPipeRule,
88-
'no-tap': noTapRule,
89-
'no-topromise': noTopromiseRule,
90-
'no-unbound-methods': noUnboundMethodsRule,
91-
'no-unsafe-catch': noUnsafeCatchRule,
92-
'no-unsafe-first': noUnsafeFirstRule,
93-
'no-unsafe-subject-next': noUnsafeSubjectNext,
94-
'no-unsafe-switchmap': noUnsafeSwitchmapRule,
95-
'no-unsafe-takeuntil': noUnsafeTakeuntilRule,
96-
'prefer-observer': preferObserverRule,
97-
'prefer-root-operators': preferRootOperatorsRule,
98-
'suffix-subjects': suffixSubjectsRule,
99-
'throw-error': throwErrorRule,
100-
},
103+
/** Compatibility with `defineConfig` until https://github.com/typescript-eslint/typescript-eslint/issues/11543 is addressed. */
104+
rules: allRules as { [K in keyof typeof allRules]: (typeof allRules)[K] & Rule.RuleModule },
101105
} satisfies ESLint.Plugin;
102106

103107
const rxjsX = {

src/utils/rule-creator.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import { ESLintUtils } from '@typescript-eslint/utils';
2-
import type { Rule } from 'eslint';
1+
import { ESLintUtils, TSESLint } from '@typescript-eslint/utils';
32
import { version } from '../../package.json';
43

5-
export interface RxjsXRuleDocs<Options extends readonly unknown[] = []> {
4+
export interface RxjsXRuleDocs<Options extends readonly unknown[]> {
65
description: string;
7-
recommended?: 'recommended' | 'strict' | {
8-
recommended?: true;
9-
strict: Partial<Options>;
10-
};
6+
recommended?: TSESLint.RuleRecommendation | TSESLint.RuleRecommendationAcrossConfigs<Options>;
117
requiresTypeChecking?: boolean;
128
}
139

1410
const REPO_URL = 'https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x';
1511

16-
export const ruleCreator = ESLintUtils.RuleCreator<RxjsXRuleDocs>(
12+
export const ruleCreator = ESLintUtils.RuleCreator<RxjsXRuleDocs<unknown[]>>(
1713
(name) =>
1814
`${REPO_URL}/blob/v${version}/docs/rules/${name}.md`,
19-
// Compatibility until https://github.com/typescript-eslint/typescript-eslint/issues/11543 is addressed.
20-
) as unknown as <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, RxjsXRuleDocs<Options>>>) => Rule.RuleModule;
15+
// Ensure the Options type is passed to RxjsXRuleDocs.
16+
) as <
17+
Options extends readonly unknown[],
18+
MessageIds extends string,
19+
>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, RxjsXRuleDocs<Options>>>) => TSESLint.RuleModule<MessageIds, Options, RxjsXRuleDocs<Options>>;

0 commit comments

Comments
 (0)