How to use the @typescript-eslint/experimental-utils.AST_NODE_TYPES.Property function in @typescript-eslint/experimental-utils

To help you get started, we’ve selected a few @typescript-eslint/experimental-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / prefer-for-of.ts View on Github external
return true;
      }

      // [a[i]] = [0]
      if (parent.type === AST_NODE_TYPES.ArrayPattern) {
        return true;
      }

      // [...a[i]] = [0]
      if (parent.type === AST_NODE_TYPES.RestElement) {
        return true;
      }

      // ({ foo: a[i] }) = { foo: 0 }
      if (
        parent.type === AST_NODE_TYPES.Property &&
        parent.value === node &&
        parent.parent?.type === AST_NODE_TYPES.ObjectExpression &&
        isAssignee(parent.parent)
      ) {
        return true;
      }

      return false;
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / explicit-function-return-type.ts View on Github external
function getLocStart(
      node:
        | TSESTree.ArrowFunctionExpression
        | TSESTree.FunctionDeclaration
        | TSESTree.FunctionExpression,
    ): TSESTree.LineAndColumnData {
      /* highlight method name */
      const parent = node.parent;
      if (
        parent &&
        (parent.type === AST_NODE_TYPES.MethodDefinition ||
          (parent.type === AST_NODE_TYPES.Property && parent.method))
      ) {
        return parent.loc.start;
      }

      return node.loc.start;
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent.ts View on Github external
key: null as any,
        value: null as any,

        // Property flags
        computed: false,
        method: false,
        kind: 'init',
        // this will stop eslint from interrogating the type literal
        shorthand: true,

        // location data
        parent: node.parent,
        range: node.range,
        loc: node.loc,
      };
      if (type === AST_NODE_TYPES.Property) {
        return {
          type,
          ...base,
        } as TSESTree.Property;
      } else {
        return {
          type,
          static: false,
          readonly: false,
          declare: false,
          ...base,
        } as TSESTree.ClassProperty;
      }
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent.ts View on Github external
function TSPropertySignatureToProperty(
      node:
        | TSESTree.TSPropertySignature
        | TSESTree.TSEnumMember
        | TSESTree.TypeElement,
      type:
        | AST_NODE_TYPES.ClassProperty
        | AST_NODE_TYPES.Property = AST_NODE_TYPES.Property,
    ): TSESTree.Node | null {
      const base = {
        // indent doesn't actually use these
        key: null as any,
        value: null as any,

        // Property flags
        computed: false,
        method: false,
        kind: 'init',
        // this will stop eslint from interrogating the type literal
        shorthand: true,

        // location data
        parent: node.parent,
        range: node.range,
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / promise-function-async.ts View on Github external
}
      const returnType = checker.getReturnTypeOfSignature(signatures[0]);

      if (
        !util.containsAllTypesByName(
          returnType,
          allowAny!,
          allAllowedPromiseNames,
        )
      ) {
        return;
      }

      if (
        node.parent &&
        (node.parent.type === AST_NODE_TYPES.Property ||
          node.parent.type === AST_NODE_TYPES.MethodDefinition) &&
        (node.parent.kind === 'get' || node.parent.kind === 'set')
      ) {
        return;
      }

      context.report({
        messageId: 'missingAsync',
        node,
      });
    }
github jonaskello / eslint-plugin-functional / src / util / typeguard.ts View on Github external
export function isProperty(node: TSESTree.Node): node is TSESTree.Property {
  return node.type === AST_NODE_TYPES.Property;
}
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent-new-do-not-use / index.ts View on Github external
AST_NODE_TYPES.ForOfStatement,
  AST_NODE_TYPES.FunctionDeclaration,
  AST_NODE_TYPES.FunctionExpression,
  AST_NODE_TYPES.Identifier,
  AST_NODE_TYPES.IfStatement,
  AST_NODE_TYPES.Literal,
  AST_NODE_TYPES.LabeledStatement,
  AST_NODE_TYPES.LogicalExpression,
  AST_NODE_TYPES.MemberExpression,
  AST_NODE_TYPES.MetaProperty,
  AST_NODE_TYPES.MethodDefinition,
  AST_NODE_TYPES.NewExpression,
  AST_NODE_TYPES.ObjectExpression,
  AST_NODE_TYPES.ObjectPattern,
  AST_NODE_TYPES.Program,
  AST_NODE_TYPES.Property,
  AST_NODE_TYPES.RestElement,
  AST_NODE_TYPES.ReturnStatement,
  AST_NODE_TYPES.SequenceExpression,
  AST_NODE_TYPES.SpreadElement,
  AST_NODE_TYPES.Super,
  AST_NODE_TYPES.SwitchCase,
  AST_NODE_TYPES.SwitchStatement,
  AST_NODE_TYPES.TaggedTemplateExpression,
  AST_NODE_TYPES.TemplateElement,
  AST_NODE_TYPES.TemplateLiteral,
  AST_NODE_TYPES.ThisExpression,
  AST_NODE_TYPES.ThrowStatement,
  AST_NODE_TYPES.TryStatement,
  AST_NODE_TYPES.UnaryExpression,
  AST_NODE_TYPES.UpdateExpression,
  AST_NODE_TYPES.VariableDeclaration,
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / space-before-function-paren.ts View on Github external
function isNamedFunction(
      node:
        | TSESTree.ArrowFunctionExpression
        | TSESTree.FunctionDeclaration
        | TSESTree.FunctionExpression,
    ): boolean {
      if (node.id) {
        return true;
      }

      const parent = node.parent!;

      return (
        parent.type === AST_NODE_TYPES.MethodDefinition ||
        (parent.type === AST_NODE_TYPES.Property &&
          (parent.kind === 'get' || parent.kind === 'set' || parent.method))
      );
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / explicit-function-return-type.ts View on Github external
function isSetter(node: TSESTree.Node | undefined): boolean {
      return (
        !!node &&
        (node.type === AST_NODE_TYPES.MethodDefinition ||
          node.type === AST_NODE_TYPES.Property) &&
        node.kind === 'set'
      );
    }

@typescript-eslint/experimental-utils

(Experimental) Utilities for working with TypeScript + ESLint together

MIT
Latest version published 10 months ago

Package Health Score

85 / 100
Full package analysis