Skip to content

Commit 7977e5f

Browse files
authored
fix: string array schema validation for meta-property-ordering and test-case-property-ordering rules (#650)
1 parent a19cec0 commit 7977e5f

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

lib/rules/meta-property-ordering.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const rule: Rule.RuleModule = {
3737
{
3838
type: 'array',
3939
description: 'What order to enforce for meta properties.',
40-
elements: { type: 'string' },
40+
items: { type: 'string' },
4141
},
4242
],
4343
defaultOptions: [defaultOrder],

lib/rules/test-case-property-ordering.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const rule: Rule.RuleModule = {
4040
{
4141
type: 'array',
4242
description: 'What order to enforce for test case properties.',
43-
elements: { type: 'string' },
43+
items: { type: 'string' },
4444
},
4545
],
4646
defaultOptions: [defaultOrder],
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Linter, type Rule } from 'eslint';
2+
import { describe, it, expect } from 'vitest';
3+
import metaPropertyOrdering from '../../lib/rules/meta-property-ordering.ts';
4+
import testCasePropertyOrdering from '../../lib/rules/test-case-property-ordering.ts';
5+
6+
const linter = new Linter();
7+
8+
function invalidOptionConfig(
9+
ruleName: string,
10+
rule: Rule.RuleModule,
11+
option: unknown,
12+
): Linter.Config {
13+
return {
14+
plugins: { test: { rules: { [ruleName]: rule } } },
15+
rules: { [`test/${ruleName}`]: ['error', option] as Linter.RuleEntry },
16+
};
17+
}
18+
19+
describe('array option schemas reject non-string items', () => {
20+
it('meta-property-ordering', () => {
21+
expect(() =>
22+
linter.verify(
23+
'foo;',
24+
invalidOptionConfig(
25+
'meta-property-ordering',
26+
metaPropertyOrdering,
27+
[1, 2, 3],
28+
),
29+
),
30+
).toThrow(/should be string/i);
31+
});
32+
33+
it('test-case-property-ordering', () => {
34+
expect(() =>
35+
linter.verify(
36+
'foo;',
37+
invalidOptionConfig(
38+
'test-case-property-ordering',
39+
testCasePropertyOrdering,
40+
[1, 2, 3],
41+
),
42+
),
43+
).toThrow(/should be string/i);
44+
});
45+
});

0 commit comments

Comments
 (0)