Skip to content

Commit 9ff0f5f

Browse files
talentlessguyljharb
authored andcommitted
[flow] update flow so there are no errors
1 parent 0298c54 commit 9ff0f5f

14 files changed

+23
-19
lines changed

__mocks__/genInteractives.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export function genInteractiveElements(): Array<JSXElementMockType> {
170170
if (bracketIndex > -1) {
171171
name = elementSymbol.slice(0, bracketIndex);
172172
}
173-
const attributes = interactiveElementsMap[elementSymbol].map(({ prop, value }) => JSXAttributeMock(prop, value));
173+
const attributes = interactiveElementsMap[(elementSymbol: any)].map(({ prop, value }) => JSXAttributeMock(prop, value));
174174
return JSXElementMock(name, attributes);
175175
});
176176
}

__tests__/__util__/ruleOptionsMapperFactory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function ruleOptionsMapperFactory(ruleOptions: Array<mixed> = [])
2323
code,
2424
errors,
2525
// Flatten the array of objects in an array of one object.
26-
options: [fromEntries((options || []).concat(ruleOptions).flatMap((item) => entries(item)))],
26+
options: [fromEntries((options || []).concat(ruleOptions).flatMap((item) => entries((item: any))))],
2727
parserOptions,
2828
settings,
2929
};

flow/eslint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
export type ESLintReport = {
55
node: any,
66
message: string,
7+
data?: any
78
};
89

910
export type ESLintSettings = {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"eslint-plugin-flowtype": "^5.8.0 || ^8.0.3",
5757
"eslint-plugin-import": "^2.31.0",
5858
"estraverse": "^5.3.0",
59-
"flow-bin": "^0.147.0",
59+
"flow-bin": "^0.250.0",
6060
"in-publish": "^2.0.1",
6161
"jackspeak": "=2.1.1",
6262
"jscodeshift": "^17.0.0",

src/rules/anchor-ambiguous-text.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// ----------------------------------------------------------------------------
88
// Rule Definition
99
// ----------------------------------------------------------------------------
10-
1110
import type { ESLintConfig, ESLintContext } from '../../flow/eslint';
1211
import { arraySchema, generateObjSchema } from '../util/schemas';
1312
import getAccessibleChildText from '../util/getAccessibleChildText';
@@ -44,7 +43,7 @@ export default ({
4443
const ambiguousWords = new Set(words);
4544

4645
return {
47-
JSXOpeningElement: (node) => {
46+
JSXOpeningElement: (node: any) => {
4847
const nodeType = elementType(node);
4948

5049
// Only check anchor elements and custom types.

src/rules/anchor-is-valid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default ({
6060

6161
// Create active aspect flag object. Failing checks will only report
6262
// if the related flag is set to true.
63-
const activeAspects = {};
63+
const activeAspects: Object = {};
6464
allAspects.forEach((aspect) => {
6565
activeAspects[aspect] = aspects.indexOf(aspect) !== -1;
6666
});

src/rules/control-has-associated-label.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
import { getProp, getLiteralPropValue } from 'jsx-ast-utils';
1313
import type { JSXElement } from 'ast-types-flow';
1414
import { generateObjSchema, arraySchema } from '../util/schemas';
15-
import type { ESLintConfig, ESLintContext, ESLintVisitorSelectorConfig } from '../../flow/eslint';
15+
import type {
16+
ESLintConfig,
17+
ESLintContext,
18+
ESLintVisitorSelectorConfig,
19+
} from '../../flow/eslint';
1620
import getElementType from '../util/getElementType';
1721
import isDOMElement from '../util/isDOMElement';
1822
import isHiddenFromScreenReader from '../util/isHiddenFromScreenReader';

src/rules/label-has-associated-control.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const schema = generateObjSchema({
3636
},
3737
});
3838

39-
function validateID(node, context) {
39+
function validateID(node: Object, context: Object) {
4040
const { settings } = context;
4141
const htmlForAttributes = settings['jsx-a11y']?.attributes?.for ?? ['htmlFor'];
4242

src/rules/media-has-caption.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const schema = generateObjSchema({
2525
track: arraySchema,
2626
});
2727

28-
const isMediaType = (context, type) => {
28+
const isMediaType = (context: Object, type: string) => {
2929
const options = context.options[0] || {};
3030
return MEDIA_TYPES
3131
.concat(MEDIA_TYPES.flatMap((mediaType) => options[mediaType]))
3232
.some((typeToCheck) => typeToCheck === type);
3333
};
3434

35-
const isTrackType = (context, type) => {
35+
const isTrackType = (context: Object, type: string) => {
3636
const options = context.options[0] || {};
3737
return ['track'].concat(options.track || []).some((typeToCheck) => typeToCheck === type);
3838
};

src/rules/mouse-events-have-key-events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default ({
4040
},
4141

4242
create: (context: ESLintContext) => ({
43-
JSXOpeningElement: (node) => {
43+
JSXOpeningElement: (node: Object) => {
4444
const { name } = node.name;
4545

4646
if (!dom.get(name)) {

src/rules/no-redundant-roles.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import getImplicitRole from '../util/getImplicitRole';
1717

1818
const { hasOwn } = Object;
1919

20-
const errorMessage = (element, implicitRole) => (
20+
const errorMessage = (element: string, implicitRole: string) => (
2121
`The element ${element} has an implicit role of ${implicitRole}. Defining this explicitly is redundant and should be avoided.`
2222
);
2323

@@ -46,7 +46,7 @@ export default ({
4646
const elementType = getElementType(context);
4747
return {
4848
JSXOpeningElement: (node: JSXOpeningElement) => {
49-
const type = elementType(node);
49+
const type: any = elementType(node);
5050
const implicitRole = getImplicitRole(type, node.attributes);
5151
const explicitRole = getExplicitRole(type, node.attributes);
5252

src/util/getExplicitRole.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function getExplicitRole(
1515
tag: string,
1616
attributes: Array<Node>,
1717
): ?string {
18-
const explicitRole = (function toLowerCase(role) {
18+
const explicitRole = (function toLowerCase(role: any) {
1919
if (typeof role === 'string') {
2020
return role.toLowerCase();
2121
}

src/util/isInteractiveElement.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ const interactiveAXObjects = new Set(AXObjects.keys().filter((name) => AXObjects
5757

5858
const interactiveElementAXObjectSchemas = [...elementAXObjects].flatMap(([elementSchema, AXObjectsArr]) => (AXObjectsArr.every((role): boolean => interactiveAXObjects.has(role)) ? [elementSchema] : []));
5959

60-
function checkIsInteractiveElement(tagName, attributes): boolean {
61-
function elementSchemaMatcher(elementSchema) {
60+
function checkIsInteractiveElement(tagName: string, attributes: Object): boolean {
61+
function elementSchemaMatcher(elementSchema: Object) {
6262
return (
6363
tagName === elementSchema.name
6464
&& attributesComparator(elementSchema.attributes, attributes)

src/util/isNonInteractiveElement.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ const nonInteractiveElementRoleSchemas = elementRoleEntries.flatMap(([elementSch
6262

6363
const nonInteractiveAXObjects = new Set(AXObjects.keys().filter((name) => ['window', 'structure'].includes(AXObjects.get(name).type)));
6464

65-
const nonInteractiveElementAXObjectSchemas = elementAXObjects.flatMap(([elementSchema, AXObjectsArr]) => (AXObjectsArr.every((role): boolean => nonInteractiveAXObjects.has(role)) ? [elementSchema] : []));
65+
const nonInteractiveElementAXObjectSchemas = [...elementAXObjects].flatMap(([elementSchema, AXObjectsArr]) => (AXObjectsArr.every((role): boolean => nonInteractiveAXObjects.has(role)) ? [elementSchema] : []));
6666

67-
function checkIsNonInteractiveElement(tagName, attributes): boolean {
68-
function elementSchemaMatcher(elementSchema) {
67+
function checkIsNonInteractiveElement(tagName: string, attributes: Object): boolean {
68+
function elementSchemaMatcher(elementSchema: Object) {
6969
return (
7070
tagName === elementSchema.name
7171
&& tagName !== 'td' // TODO: investigate why this is needed

0 commit comments

Comments
 (0)