Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 6 Examples of "jsx-ast-utils in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'jsx-ast-utils' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

enter(path) {
          const { node } = path
          // 排除 Fragment
          // TODO: 考虑 Fragment 重命名情况
          if (jsxHelpers.elementType(node).includes('Fragment')) {
            return
          }

          const hasKey = jsxHelpers.hasProp(node.attributes, 'key')
          const keyAttr = jsxHelpers.getProp(node.attributes, 'key')
          const keyAttrValue = get(keyAttr, 'value.value')

          // 排除 key 为以下的项,保证 SSR 时两端结果一致
          if (
            hasKey &&
            ['keep-alive-placeholder', 'keeper-container'].includes(
              keyAttrValue
            )
          ) {
            return
          }

          const isArrayElement = node.__isArrayElement

          // 不允许自定义 _ka 属性
          // DONE: 使用 key 属性替换,需考虑不覆盖 array 结构中的 key 属性,array 结构中保持 _ka 属性
enter(path) {
          const { node } = path
          // 排除 Fragment
          // TODO: 考虑 Fragment 重命名情况
          if (jsxHelpers.elementType(node).includes('Fragment')) {
            return
          }

          const hasKey = jsxHelpers.hasProp(node.attributes, 'key')
          const keyAttr = jsxHelpers.getProp(node.attributes, 'key')
          const keyAttrValue = get(keyAttr, 'value.value')

          // 排除 key 为以下的项,保证 SSR 时两端结果一致
          if (
            hasKey &&
            ['keep-alive-placeholder', 'keeper-container'].includes(
              keyAttrValue
            )
          ) {
            return
          }
JSXAttribute: (node: JSXAttribute) => {
      const attrName = elementType(node);
      if (attrName === propName) {
        // ensure we are only checking literal prop values
        const attrValue = getLiteralPropValue(node);
        let invalid = false;

        if (Array.isArray(attrValue)) {
          const validate = attrValue.map(strValue =>
            isOneOf(strValue, validValues)
          );
          invalid = validate.indexOf(false) > -1;
        } else {
          invalid = !isOneOf(attrValue, validValues);
        }

        if (invalid) {
          context.report({
var _isNonLiteralProperty = _interopRequireDefault(require("../util/isNonLiteralProperty"));

var _isPresentationRole = _interopRequireDefault(require("../util/isPresentationRole"));

/**
 * @fileoverview Enforce static elements have no interactive handlers.
 * @author Ethan Cohen
 * 
 */
// ----------------------------------------------------------------------------
// Rule Definition
// ----------------------------------------------------------------------------
var errorMessage = 'Static HTML elements with event handlers require a role.';
var domElements = (0, _toConsumableArray2["default"])(_ariaQuery.dom.keys());
var defaultInteractiveProps = [].concat((0, _toConsumableArray2["default"])(_jsxAstUtils.eventHandlersByType.focus), (0, _toConsumableArray2["default"])(_jsxAstUtils.eventHandlersByType.keyboard), (0, _toConsumableArray2["default"])(_jsxAstUtils.eventHandlersByType.mouse));
var schema = (0, _schemas.generateObjSchema)({
  handlers: _schemas.arraySchema
});
module.exports = {
  meta: {
    docs: {
      url: 'https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules/no-static-element-interactions.md'
    },
    schema: [schema]
  },
  create: function create(context) {
    var options = context.options;
    return {
      JSXOpeningElement: function JSXOpeningElement(node) {
        var attributes = node.attributes;
        var type = (0, _jsxAstUtils.elementType)(node);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } /**
                                                                                                                                                                                                     * @fileoverview Enforce static elements have no interactive handlers.
                                                                                                                                                                                                     * @author Ethan Cohen
                                                                                                                                                                                                     * 
                                                                                                                                                                                                     */

// ----------------------------------------------------------------------------
// Rule Definition
// ----------------------------------------------------------------------------

var errorMessage = 'Static HTML elements with event handlers require a role.';

var domElements = [].concat(_toConsumableArray(_ariaQuery.dom.keys()));
var defaultInteractiveProps = [].concat(_toConsumableArray(_jsxAstUtils.eventHandlersByType.focus), _toConsumableArray(_jsxAstUtils.eventHandlersByType.keyboard), _toConsumableArray(_jsxAstUtils.eventHandlersByType.mouse));
var schema = (0, _schemas.generateObjSchema)({
  handlers: _schemas.arraySchema
});

module.exports = {
  meta: {
    docs: {},
    schema: [schema]
  },

  create: function create(context) {
    var options = context.options;

    return {
      JSXOpeningElement: function JSXOpeningElement(node) {
        var attributes = node.attributes;
enter(path) {
          const { node } = path
          // 排除 Fragment
          // TODO: 考虑 Fragment 重命名情况
          if (jsxHelpers.elementType(node).includes('Fragment')) {
            return
          }

          const hasKey = jsxHelpers.hasProp(node.attributes, 'key')
          const keyAttr = jsxHelpers.getProp(node.attributes, 'key')
          const keyAttrValue = get(keyAttr, 'value.value')

          // 排除 key 为以下的项,保证 SSR 时两端结果一致
          if (
            hasKey &&
            ['keep-alive-placeholder', 'keeper-container'].includes(
              keyAttrValue
            )
          ) {
            return
          }

          const isArrayElement = node.__isArrayElement

          // 不允许自定义 _ka 属性

Is your System Free of Underlying Vulnerabilities?
Find Out Now