jsx-ast-utils
jsx-ast-utils
Installation
$ npm i jsx-ast-utils --saveUsage
ESLint example
import { hasProp } from 'jsx-ast-utils';
// OR: var hasProp = require('jsx-ast-utils').hasProp;
// OR: const hasProp = require('jsx-ast-utils/hasProp');
// OR: import hasProp from 'jsx-ast-utils/hasProp';
module.exports = context => ({
JSXOpeningElement: node => {
const onChange = hasProp(node.attributes, 'onChange');
if (onChange) {
context.report({
node,
message: `No onChange!`
});
}
}
});API
AST Resources
hasProp
hasAnyProp
hasEveryProp
getProp
elementType
getPropValue
getLiteralPropValue
propName
eventHandlers
Last updated