diff --git a/.changeset/odd-steaks-reply.md b/.changeset/odd-steaks-reply.md new file mode 100644 index 0000000..e3eed6e --- /dev/null +++ b/.changeset/odd-steaks-reply.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-react-native-a11y': patch +--- + +Fix for has-valid-accessibility-ignores-invert-colors with eslint 9 diff --git a/flow/eslint.js b/flow/eslint.js index 1b48a06..06948d7 100644 --- a/flow/eslint.js +++ b/flow/eslint.js @@ -13,4 +13,7 @@ export type ESLintContext = { getSourceCode: () => { text: string, }, + sourceCode: { + text: string, + }, }; diff --git a/src/rules/has-valid-accessibility-ignores-invert-colors.js b/src/rules/has-valid-accessibility-ignores-invert-colors.js index 0c69392..c695666 100644 --- a/src/rules/has-valid-accessibility-ignores-invert-colors.js +++ b/src/rules/has-valid-accessibility-ignores-invert-colors.js @@ -85,11 +85,11 @@ module.exports = { verifyReactNativeImage, }, - create: ({ options, report, getSourceCode }: ESLintContext) => { + create: ({ options, report, getSourceCode, sourceCode }: ESLintContext) => { /** * 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 * */ - const { text } = getSourceCode(); + const { text } = sourceCode || getSourceCode(); const { enableLinting, elementsToCheck } = verifyReactNativeImage(text); // Add in any other invertible components to check for diff --git a/src/util/isTouchable.js b/src/util/isTouchable.js index fdbbb4b..34c5b1c 100644 --- a/src/util/isTouchable.js +++ b/src/util/isTouchable.js @@ -27,6 +27,9 @@ export default function isTouchable( getSourceCode: () => ({ text: '', }), + sourceCode: { + text: '', + }, } ) { const { options } = context;