Skip to content

Commit b945d94

Browse files
Fix: Eslint 9 crash in has-valid-accessibility-ignores-invert-colors (#162)
1 parent 8b41fb1 commit b945d94

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

.changeset/odd-steaks-reply.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-react-native-a11y': patch
3+
---
4+
5+
Fix for has-valid-accessibility-ignores-invert-colors with eslint 9

flow/eslint.js

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ export type ESLintContext = {
1313
getSourceCode: () => {
1414
text: string,
1515
},
16+
sourceCode: {
17+
text: string,
18+
},
1619
};

src/rules/has-valid-accessibility-ignores-invert-colors.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ module.exports = {
8585
verifyReactNativeImage,
8686
},
8787

88-
create: ({ options, report, getSourceCode }: ESLintContext) => {
88+
create: ({ options, report, getSourceCode, sourceCode }: ESLintContext) => {
8989
/**
9090
* Checks to see if there are valid imports and if so verifies that those imports related to 'react-native' or if a custom module exists
9191
* */
92-
const { text } = getSourceCode();
92+
const { text } = sourceCode || getSourceCode();
9393
const { enableLinting, elementsToCheck } = verifyReactNativeImage(text);
9494

9595
// Add in any other invertible components to check for

src/util/isTouchable.js

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export default function isTouchable(
2727
getSourceCode: () => ({
2828
text: '',
2929
}),
30+
sourceCode: {
31+
text: '',
32+
},
3033
}
3134
) {
3235
const { options } = context;

0 commit comments

Comments
 (0)