Skip to content

Commit d70ac7d

Browse files
leosbeefancohen
authored andcommitted
[fix] - Resolve flow issues by explicitly importing types (#243)
Fixing #241
1 parent 9971241 commit d70ac7d

11 files changed

+26
-7
lines changed

.flowconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@
22
<PROJECT_ROOT>/lib/.*
33
<PROJECT_ROOT>/docs/.*
44
<PROJECT_ROOT>/reports/.*
5-
6-
[libs]
7-
flow

__tests__/src/rules/no-interactive-element-to-noninteractive-role-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ const alwaysValid = [
288288
{ code: '<div role="term" />;' },
289289
{ code: '<div role="timer" />;' },
290290
{ code: '<div role="tooltip" />;' },
291+
/* Namespaced roles are not checked */
292+
{ code: '<div mynamespace:role="term" />' },
293+
{ code: '<input mynamespace:role="img" />' },
291294
];
292295

293296
const neverValid = [

flow/eslint-jsx.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
/*
2+
* @flow
3+
*/
14
import type {
25
JSXAttribute,
36
JSXOpeningElement,
47
} from 'ast-types-flow';
58

6-
type ESLintJSXAttribute = {
9+
export type ESLintJSXAttribute = {
710
parent: JSXOpeningElement
811
} & JSXAttribute;

flow/eslint.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
type ESLintReport = {
1+
/*
2+
* @flow
3+
*/
4+
export type ESLintReport = {
25
node: any,
36
message: string,
47
};
58

6-
type ESLintContext = {
9+
export type ESLintContext = {
710
options: Array<Object>,
811
report: (ESLintReport) => void,
912
};

src/rules/interactive-supports-focus.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from 'jsx-ast-utils';
1414
import type { JSXOpeningElement } from 'ast-types-flow';
1515
import includes from 'array-includes';
16+
import type { ESLintContext } from '../../flow/eslint';
1617
import { generateObjSchema } from '../util/schemas';
1718
import isHiddenFromScreenReader from '../util/isHiddenFromScreenReader';
1819
import isInteractiveElement from '../util/isInteractiveElement';

src/rules/media-has-caption.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import type { JSXElement, JSXOpeningElement } from 'ast-types-flow';
1212
import { elementType, getProp, getLiteralPropValue } from 'jsx-ast-utils';
13+
import type { ESLintContext } from '../../flow/eslint';
1314
import { generateObjSchema, arraySchema } from '../util/schemas';
1415

1516
const errorMessage = 'Media elements such as <audio> and <video> must have a <track> for captions.';

src/rules/no-interactive-element-to-noninteractive-role.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
} from 'jsx-ast-utils';
2121
import type { JSXIdentifier } from 'ast-types-flow';
2222
import includes from 'array-includes';
23+
import type { ESLintContext } from '../../flow/eslint';
24+
import type { ESLintJSXAttribute } from '../../flow/eslint-jsx';
2325
import isInteractiveElement from '../util/isInteractiveElement';
2426
import isNonInteractiveRole from '../util/isNonInteractiveRole';
2527
import isPresentationRole from '../util/isPresentationRole';

src/rules/no-noninteractive-element-interactions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from 'jsx-ast-utils';
2020
import type { JSXOpeningElement } from 'ast-types-flow';
2121
import includes from 'array-includes';
22+
import type { ESLintContext } from '../../flow/eslint';
2223
import { arraySchema, generateObjSchema } from '../util/schemas';
2324
import isAbstractRole from '../util/isAbstractRole';
2425
import isHiddenFromScreenReader from '../util/isHiddenFromScreenReader';

src/rules/no-noninteractive-element-to-interactive-role.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ import {
1616
elementType,
1717
getProp,
1818
getLiteralPropValue,
19+
propName,
1920
} from 'jsx-ast-utils';
2021
import type {
2122
JSXIdentifier,
2223
} from 'ast-types-flow';
2324
import includes from 'array-includes';
25+
import type { ESLintContext } from '../../flow/eslint';
26+
import type { ESLintJSXAttribute } from '../../flow/eslint-jsx';
2427
import isNonInteractiveElement from '../util/isNonInteractiveElement';
2528
import isInteractiveRole from '../util/isInteractiveRole';
2629

@@ -50,7 +53,7 @@ module.exports = {
5053
JSXAttribute: (
5154
attribute: ESLintJSXAttribute,
5255
) => {
53-
const attributeName: JSXIdentifier = attribute.name.name;
56+
const attributeName: JSXIdentifier = propName(attribute);
5457
if (attributeName !== 'role') {
5558
return;
5659
}

src/rules/no-noninteractive-tabindex.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
import {
1212
dom,
1313
} from 'aria-query';
14+
import type {
15+
JSXOpeningElement,
16+
} from 'ast-types-flow';
1417
import {
1518
elementType,
1619
getProp,
1720
getLiteralPropValue,
1821
} from 'jsx-ast-utils';
1922
import includes from 'array-includes';
23+
import type { ESLintContext } from '../../flow/eslint';
2024
import isInteractiveElement from '../util/isInteractiveElement';
2125
import isInteractiveRole from '../util/isInteractiveRole';
2226
import { generateObjSchema, arraySchema } from '../util/schemas';

0 commit comments

Comments
 (0)