Skip to content

Commit 1082df4

Browse files
Fix eslint issues.
1 parent 138c400 commit 1082df4

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

lib/util/labelUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const extractCapturedId = (match: RegExpExecArray): string | undefined => {
4444
/**
4545
* New small helper: normalize attribute value (string list vs identifier vs empty/none)
4646
* Keeps getProp/getPropValue usage isolated and provides a single place to trim/split.
47-
* Return shape (for consumers):
47+
* Return shape (for consumers):
4848
* { kind: "string", raw: string, tokens: string[] }
4949
* { kind: "identifier", name: string }
5050
* { kind: "empty" }

tests/lib/rules/utils/labelUtils.test.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,9 @@ describe("labelUtils", () => {
143143
});
144144

145145
describe("hasAssociatedLabelViaAriaDescribedby", () => {
146-
let context: TSESLint.RuleContext<string, unknown[]>;
147146
let openingElement: TSESTree.JSXOpeningElement;
148147

149148
beforeEach(() => {
150-
context = mockContext();
151149
openingElement = { attributes: [] } as unknown as TSESTree.JSXOpeningElement;
152150
});
153151

@@ -187,14 +185,20 @@ describe("labelUtils", () => {
187185
expect(hasAssociatedLabelViaHtmlFor(openingExpr, ctxExpr)).toBe(true);
188186

189187
const ctxIdent = mockContext("<Label htmlFor={idVar}>L</Label>");
190-
const openingIdent = { attributes: [createJSXAttributeExpressionIdentifier("id", "idVar")] } as unknown as TSESTree.JSXOpeningElement;
188+
const openingIdent = {
189+
attributes: [createJSXAttributeExpressionIdentifier("id", "idVar")]
190+
} as unknown as TSESTree.JSXOpeningElement;
191191
expect(hasAssociatedLabelViaHtmlFor(openingIdent, ctxIdent)).toBe(true);
192192
});
193193
});
194194

195195
describe("low-level helpers", () => {
196196
test("isInsideLabelTag true/false and hasBracedAttrId behavior", () => {
197-
const ctxLabel = { getAncestors: () => [{ type: "JSXElement", openingElement: { name: { type: AST_NODE_TYPES.JSXIdentifier, name: "Label" } } }] } as unknown as TSESLint.RuleContext<string, unknown[]>;
197+
const ctxLabel = {
198+
getAncestors: () => [
199+
{ type: "JSXElement", openingElement: { name: { type: AST_NODE_TYPES.JSXIdentifier, name: "Label" } } }
200+
]
201+
} as unknown as TSESLint.RuleContext<string, unknown[]>;
198202
expect(isInsideLabelTag(ctxLabel)).toBe(true);
199203

200204
const ctxNot = { getAncestors: () => [{ type: "NotJSX" }] } as unknown as TSESLint.RuleContext<string, unknown[]>;
@@ -218,7 +222,7 @@ describe("labelUtils", () => {
218222
describe("additional alternation & loop-branch coverage", () => {
219223
test("combined alternation forms for labels/htmlFor/other elements", () => {
220224
const src = [
221-
"<Label id=\"a\"></Label>",
225+
'<Label id="a"></Label>',
222226
"<Label id='b'></Label>",
223227
'<Label id={"c"}></Label>',
224228
"<Label id={'d'}></Label>",
@@ -232,7 +236,7 @@ describe("labelUtils", () => {
232236
expect(hasLabelWithHtmlId("e", ctx)).toBe(true);
233237

234238
const srcFor = [
235-
"<Label htmlFor=\"A1\"></Label>",
239+
'<Label htmlFor="A1"></Label>',
236240
"<Label htmlFor='B1'></Label>",
237241
'<Label htmlFor={"C1"}></Label>',
238242
"<Label htmlFor={'D1'}></Label>",
@@ -259,7 +263,9 @@ describe("labelUtils", () => {
259263

260264
describe("getAttributeValueInfo helper", () => {
261265
test("parses string-valued attribute into tokens and trims", () => {
262-
const opening = { attributes: [createJSXAttributeLiteral("aria-labelledby", " a b ")] } as unknown as TSESTree.JSXOpeningElement;
266+
const opening = {
267+
attributes: [createJSXAttributeLiteral("aria-labelledby", " a b ")]
268+
} as unknown as TSESTree.JSXOpeningElement;
263269
const ctx = mockContext("<Label id='a'></Label><div id='b'></div>");
264270
const info = getAttributeValueInfo(opening, ctx, "aria-labelledby") as any;
265271
expect(info.kind).toBe("string");
@@ -268,7 +274,9 @@ describe("labelUtils", () => {
268274
});
269275

270276
test("detects identifier expression form on a JSXExpressionContainer", () => {
271-
const opening = { attributes: [createJSXAttributeExpressionIdentifier("aria-labelledby", "someId")] } as unknown as TSESTree.JSXOpeningElement;
277+
const opening = {
278+
attributes: [createJSXAttributeExpressionIdentifier("aria-labelledby", "someId")]
279+
} as unknown as TSESTree.JSXOpeningElement;
272280
const ctx = mockContext("<div id={someId}></div>");
273281
const info = getAttributeValueInfo(opening, ctx, "aria-labelledby") as any;
274282
expect(info.kind).toBe("identifier");

0 commit comments

Comments
 (0)