Skip to content

Commit eff5077

Browse files
committed
Merge branch 'main' into user/harshmodi/ProgressBarLintRules
2 parents a8e536f + 19c4a1a commit eff5077

File tree

5 files changed

+62
-63
lines changed

5 files changed

+62
-63
lines changed

COVERAGE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ We currently cover the following components:
7575
- [] Tree
7676
- [x] Datepicker
7777
- [] Calendar
78-
- [] Timepicker
78+
- [x] Timepicker

docs/rules/avoid-using-aria-describedby-for-primary-labelling.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# aria-describedby provides additional context and is not meant for primary labeling. (`avoid-using-aria-describedby-for-primary-labelling`)
1+
# Aria-describedby provides additional context and is not meant for primary labeling (`@microsoft/fluentui-jsx-a11y/avoid-using-aria-describedby-for-primary-labelling`)
2+
3+
⚠️ This rule _warns_ in the ✅ `recommended` config.
4+
5+
<!-- end auto-generated rule header -->
26

37
You should avoid using `aria-describedby` as a primary labeling mechanism because it is intended to provide supplementary or additional information, not to act as the main label for an element.
48

docs/rules/badge-needs-accessible-name.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
<!-- end auto-generated rule header -->
66

7+
💼 This rule is enabled in the ✅ `recommended` config.
8+
9+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
10+
11+
<!-- end auto-generated rule header -->
12+
713
Badge information should be surfaced as part of the control that it is associated with, because, badges themselves do not receive focus meaning they are not directly accessible by screen readers. If the combination of icon and badge communicates some meaningful information, that information should be surfaced in another way through screenreader or tooltip on the component the badge is associated with.
814

915
Badge content is exposed as text, and is treated by screen readers as if it were inline content of the control it is associated with.

lib/applicableComponents/inputBasedComponents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
const applicableComponents = ["Input", "Slider", "DatePicker", "TextArea", "TextField"];
4+
const applicableComponents = ["Input", "Slider", "DatePicker", "TextArea", "TextField", "TimePicker"];
55

66
module.exports = {
77
applicableComponents

tests/lib/rules/input-missing-label.js

Lines changed: 49 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
"use strict";
55

6+
const { applicableComponents } = require("../../../lib/applicableComponents/inputBasedComponents");
7+
68
//------------------------------------------------------------------------------
79
// Requirements
810
//------------------------------------------------------------------------------
@@ -20,70 +22,57 @@ RuleTester.setDefaultConfig({
2022
}
2123
});
2224

25+
//------------------------------------------------------------------------------
26+
// Helper function to generate test cases
27+
//------------------------------------------------------------------------------
28+
function generateTestCases(componentName) {
29+
return {
30+
valid: [
31+
`<><Label htmlFor="some-id">Some Label</Label><${componentName} id="some-id"/></>`,
32+
`<><Label id="test-span">Some Label</Label><${componentName} id="some-id" aria-labelledby="test-span"/></>`,
33+
`<Label>test</Label>`,
34+
`<Label>test<${componentName} /></Label>`,
35+
`<Label>test<SomeNesting><${componentName} /></SomeNesting></Label>`,
36+
`<Field label="${componentName}"><${componentName} /></Field>`
37+
],
38+
invalid: [
39+
{
40+
code: `<><${componentName}/></>`,
41+
errors: [{ messageId: "missingLabelOnInput" }]
42+
},
43+
{
44+
code: `<><Label/><${componentName}/></>`,
45+
errors: [{ messageId: "missingLabelOnInput" }]
46+
},
47+
{
48+
code: `<><Label htmlFor="id"/><${componentName} /></>`,
49+
errors: [{ messageId: "missingLabelOnInput" }]
50+
},
51+
{
52+
code: `<${componentName} id="some-id"/>`,
53+
errors: [{ messageId: "missingLabelOnInput" }]
54+
},
55+
{
56+
code: `<><Label>Some Label</Label><${componentName} id="some-id"/></>`,
57+
errors: [{ messageId: "missingLabelOnInput" }]
58+
},
59+
{
60+
code: `<><Field></Field><${componentName} id="some-id"/></>`,
61+
errors: [{ messageId: "missingLabelOnInput" }]
62+
}
63+
]
64+
};
65+
}
66+
67+
// Collect all test cases for all applicable components
68+
const allTestCases = applicableComponents.flatMap(component => generateTestCases(component));
69+
2370
//------------------------------------------------------------------------------
2471
// Tests
2572
//------------------------------------------------------------------------------
2673

2774
const ruleTester = new RuleTester();
2875
ruleTester.run("input-missing-label", rule, {
29-
valid: [
30-
'<><Label htmlFor="some-id">Some Label</Label><Input id="some-id"/></>',
31-
'<><Label id="test-span">Some Label</Label><Input id="some-id" aria-labelledby="test-span"/></>',
32-
"<Label>test</Label>",
33-
"<Label>test<Input/></Label>",
34-
"<Label>test<SomeNesting><Input/></SomeNesting></Label>",
35-
'<><Label htmlFor="some-id">Some Label</Label><Slider size="medium" defaultValue={20} id="some-id"/></>',
36-
'<><Label id="test-span">Some Label</Label><Slider size="medium" defaultValue={20} id="some-id" aria-labelledby="test-span"/></>',
37-
'<Label>test<Slider size="medium" defaultValue={20}/></Label>',
38-
'<Label>test<SomeNesting><Slider size="medium" defaultValue={20}/></SomeNesting></Label>',
39-
'<Field label="Input"><Input /></Field>',
40-
'<Field label="Slider"><Slider defaultValue={25} /></Field>'
41-
],
42-
43-
invalid: [
44-
{
45-
code: "<><Input/></>",
46-
errors: [{ messageId: "missingLabelOnInput" }]
47-
},
48-
{
49-
code: "<><Label/><Input/></>",
50-
errors: [{ messageId: "missingLabelOnInput" }]
51-
},
52-
{
53-
code: '<><Label htmlFor="id"/><Input /></>',
54-
errors: [{ messageId: "missingLabelOnInput" }]
55-
},
56-
{
57-
code: '<Input id="some-id"/>',
58-
errors: [{ messageId: "missingLabelOnInput" }]
59-
},
60-
{
61-
code: '<><Label>Some Label</Label><Input id="some-id"/></>',
62-
errors: [{ messageId: "missingLabelOnInput" }]
63-
},
64-
{
65-
code: '<><Label/><Slider size="medium" defaultValue={20}/></>',
66-
errors: [{ messageId: "missingLabelOnInput" }]
67-
},
68-
{
69-
code: '<><Label htmlFor="id"/><Slider size="medium" defaultValue={20} /></>',
70-
errors: [{ messageId: "missingLabelOnInput" }]
71-
},
72-
{
73-
code: '<Slider id="some-id"/>',
74-
errors: [{ messageId: "missingLabelOnInput" }]
75-
},
76-
{
77-
code: '<><Label>Some Label</Label><Slider id="some-id"/></>',
78-
errors: [{ messageId: "missingLabelOnInput" }]
79-
},
80-
{
81-
code: '<><Field></Field><Slider id="some-id"/></>',
82-
errors: [{ messageId: "missingLabelOnInput" }]
83-
},
84-
{
85-
code: "<><Field></Field><Input /></>",
86-
errors: [{ messageId: "missingLabelOnInput" }]
87-
}
88-
]
76+
valid: allTestCases.flatMap(test => test.valid),
77+
invalid: allTestCases.flatMap(test => test.invalid)
8978
});

0 commit comments

Comments
 (0)