Skip to content

Commit 42e2bf3

Browse files
test: don't cast, we want to catch type errors
1 parent 20e821e commit 42e2bf3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/package.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import fs from 'node:fs/promises';
22
import path from 'node:path';
33
import plugin from '../src';
4-
import { RxjsXRuleDocs } from '../src/utils';
54

65
function isSourceFile(value: string): boolean {
76
const ext = path.extname(value);
@@ -52,7 +51,7 @@ describe('package', () => {
5251
const namespace = 'rxjs-x';
5352
const fullRuleName = `${namespace}/${ruleName}`;
5453

55-
const ruleRec = (rule.meta.docs as RxjsXRuleDocs<unknown[], string>)?.recommended;
54+
const ruleRec = rule.meta.docs?.recommended;
5655

5756
if (!ruleRec) {
5857
// Rule is not included in any configuration.
@@ -70,9 +69,12 @@ describe('package', () => {
7069
// Strict configuration always includes all recommended rules.
7170
// Not allowed to specify non-default options since rule only specifies a configuration name.
7271
expect(plugin.configs.strict.rules).toHaveProperty(fullRuleName, expect.any(String));
72+
} else if (typeof ruleRec !== 'object' || !('strict' in ruleRec && Array.isArray(ruleRec.strict))) {
73+
// Rule has invalid recommended configuration.
74+
expect.fail(`Unexpected type for 'rule.meta.docs.recommended': '${typeof ruleRec}'.`);
7375
} else {
7476
// Rule specifies non-default options for strict.
75-
if (ruleRec.recommended) {
77+
if ('recommended' in ruleRec) {
7678
expect(plugin.configs.recommended.rules).toHaveProperty(fullRuleName);
7779
} else {
7880
expect(plugin.configs.recommended.rules).not.toHaveProperty(fullRuleName);

0 commit comments

Comments
 (0)