How to use the @typescript-eslint/experimental-utils.AST_NODE_TYPES.Identifier 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 / explicit-member-accessibility.ts View on Github external
function checkParameterPropertyAccessibilityModifier(
      node: TSESTree.TSParameterProperty,
    ): void {
      const nodeType = 'parameter property';
      // HAS to be an identifier or assignment or TSC will throw
      if (
        node.parameter.type !== AST_NODE_TYPES.Identifier &&
        node.parameter.type !== AST_NODE_TYPES.AssignmentPattern
      ) {
        return;
      }

      const nodeName =
        node.parameter.type === AST_NODE_TYPES.Identifier
          ? node.parameter.name
          : // has to be an Identifier or TSC will throw an error
            (node.parameter.left as TSESTree.Identifier).name;

      switch (paramPropCheck) {
        case 'explicit': {
          if (!node.accessibility) {
            reportIssue('missingAccessibility', nodeType, node, nodeName);
          }
github jest-community / eslint-plugin-jest / src / rules / no-focused-tests.ts View on Github external
CallExpression(node) {
      const callee =
        node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression
          ? node.callee.tag
          : node.callee;

      if (callee.type === AST_NODE_TYPES.MemberExpression) {
        if (
          callee.object.type === AST_NODE_TYPES.Identifier &&
          isCallToFocusedTestFunction(callee.object)
        ) {
          context.report({ messageId: 'focusedTest', node: callee.object });
          return;
        }

        if (
          callee.object.type === AST_NODE_TYPES.MemberExpression &&
          isCallToTestOnlyFunction(callee.object)
        ) {
          context.report({
            messageId: 'focusedTest',
            node: callee.object.property,
          });
          return;
        }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / no-unnecessary-qualifier.ts View on Github external
function isEntityNameExpression(node: TSESTree.Node): boolean {
      return (
        node.type === AST_NODE_TYPES.Identifier ||
        (isPropertyAccessExpression(node) &&
          isEntityNameExpression(node.object))
      );
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / util / misc.ts View on Github external
function getNameFromMember(
  member:
    | TSESTree.MethodDefinition
    | TSESTree.TSMethodSignature
    | TSESTree.TSAbstractMethodDefinition
    | TSESTree.ClassProperty
    | TSESTree.TSAbstractClassProperty
    | TSESTree.Property
    | TSESTree.TSPropertySignature,
  sourceCode: TSESLint.SourceCode,
): string {
  if (member.key.type === AST_NODE_TYPES.Identifier) {
    return member.key.name;
  }
  if (member.key.type === AST_NODE_TYPES.Literal) {
    return `${member.key.value}`;
  }

  return sourceCode.text.slice(...member.key.range);
}
github jest-community / eslint-plugin-jest / src / rules / prefer-to-contain.ts View on Github external
const isFixableIncludesCallExpression = (
  node: TSESTree.Node,
): node is FixableIncludesCallExpression =>
  node.type === AST_NODE_TYPES.CallExpression &&
  node.callee.type === AST_NODE_TYPES.MemberExpression &&
  isSupportedAccessor(node.callee.property, 'includes') &&
  node.callee.property.type === AST_NODE_TYPES.Identifier &&
  hasOnlyOneArgument(node);
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / prefer-for-of.ts View on Github external
function isMatchingIdentifier(
      node: TSESTree.Expression,
      name: string,
    ): boolean {
      return node.type === AST_NODE_TYPES.Identifier && node.name === name;
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / unified-signatures.ts View on Github external
function isIdentifier(node: TSESTree.Node): node is TSESTree.Identifier {
  return node.type === AST_NODE_TYPES.Identifier;
}
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / prefer-optional-chain.ts View on Github external
node.callee,
            closingParenToken,
            isOpeningParenToken,
          ),
          util.NullThrowsReasons.MissingToken('opening parenthesis', node.type),
        );

        const argumentsText = sourceCode.text.substring(
          openingParenToken.range[0],
          closingParenToken.range[1],
        );

        return `${calleeText}${argumentsText}`;
      }

      if (node.type === AST_NODE_TYPES.Identifier) {
        return node.name;
      }

      if (node.type === AST_NODE_TYPES.ThisExpression) {
        return 'this';
      }

      return getMemberExpressionText(node);
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / no-inferrable-types.ts View on Github external
function isIdentifier(
      init: TSESTree.Expression,
      ...names: string[]
    ): boolean {
      return (
        init.type === AST_NODE_TYPES.Identifier && names.includes(init.name)
      );
    }
    function hasUnaryPrefix(
github jest-community / eslint-plugin-jest / src / rules / prefer-spy-on.ts View on Github external
fix(fixer) {
            const leftPropQuote =
              left.property.type === AST_NODE_TYPES.Identifier ? "'" : '';
            const [arg] = jestFnCall.arguments;
            const argSource = arg && context.getSourceCode().getText(arg);
            const mockImplementation = argSource
              ? `.mockImplementation(${argSource})`
              : '.mockImplementation()';

            return [
              fixer.insertTextBefore(left, `jest.spyOn(`),
              fixer.replaceTextRange(
                [left.object.range[1], left.property.range[0]],
                `, ${leftPropQuote}`,
              ),
              fixer.replaceTextRange(
                [left.property.range[1], jestFnCall.range[1]],
                `${leftPropQuote})${mockImplementation}`,
              ),

@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