eslint-plugin-react-native-a11y
Version:
React Native specific accessibility linting rules.
33 lines (30 loc) • 1.06 kB
JavaScript
;
var _jsxAstUtils = require("jsx-ast-utils");
var _schemas = require("../util/schemas");
/**
* @fileoverview An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not apparent from the accessibility label.
* @author JP Driver
*
*/
// ----------------------------------------------------------------------------
// Rule Definition
// ----------------------------------------------------------------------------
var schema = (0, _schemas.generateObjSchema)();
module.exports = {
meta: {
docs: {},
schema: [schema]
},
create: function create(context) {
return {
JSXOpeningElement: function JSXOpeningElement(node) {
if ((0, _jsxAstUtils.hasProp)(node.attributes, 'accessibilityLabel') && !(0, _jsxAstUtils.hasProp)(node.attributes, 'accessibilityHint')) {
context.report({
node,
message: 'has accessibilityLabel prop but no accessibilityHint'
});
}
}
};
}
};