How to use the @typescript-eslint/experimental-utils.AST_NODE_TYPES.TSAbstractClassProperty 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 / member-ordering.ts View on Github external
function getNodeType(
      node: TSESTree.ClassElement | TSESTree.TypeElement,
    ): string | null {
      // TODO: add missing TSCallSignatureDeclaration
      switch (node.type) {
        case AST_NODE_TYPES.TSAbstractMethodDefinition:
        case AST_NODE_TYPES.MethodDefinition:
          return node.kind;
        case AST_NODE_TYPES.TSMethodSignature:
          return 'method';
        case AST_NODE_TYPES.TSConstructSignatureDeclaration:
          return 'constructor';
        case AST_NODE_TYPES.TSAbstractClassProperty:
        case AST_NODE_TYPES.ClassProperty:
          return node.value && functionExpressions.includes(node.value.type)
            ? 'method'
            : 'field';
        case AST_NODE_TYPES.TSPropertySignature:
          return 'field';
        case AST_NODE_TYPES.TSIndexSignature:
          return 'signature';
        default:
          return null;
      }
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent.ts View on Github external
// ts keywords
  AST_NODE_TYPES.TSAbstractKeyword,
  AST_NODE_TYPES.TSAnyKeyword,
  AST_NODE_TYPES.TSBooleanKeyword,
  AST_NODE_TYPES.TSNeverKeyword,
  AST_NODE_TYPES.TSNumberKeyword,
  AST_NODE_TYPES.TSStringKeyword,
  AST_NODE_TYPES.TSSymbolKeyword,
  AST_NODE_TYPES.TSUndefinedKeyword,
  AST_NODE_TYPES.TSUnknownKeyword,
  AST_NODE_TYPES.TSVoidKeyword,
  AST_NODE_TYPES.TSNullKeyword,

  // ts specific nodes we want to support
  AST_NODE_TYPES.TSAbstractClassProperty,
  AST_NODE_TYPES.TSAbstractMethodDefinition,
  AST_NODE_TYPES.TSArrayType,
  AST_NODE_TYPES.TSAsExpression,
  AST_NODE_TYPES.TSCallSignatureDeclaration,
  AST_NODE_TYPES.TSConditionalType,
  AST_NODE_TYPES.TSConstructorType,
  AST_NODE_TYPES.TSConstructSignatureDeclaration,
  AST_NODE_TYPES.TSDeclareFunction,
  AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
  AST_NODE_TYPES.TSEnumDeclaration,
  AST_NODE_TYPES.TSEnumMember,
  AST_NODE_TYPES.TSExportAssignment,
  AST_NODE_TYPES.TSExternalModuleReference,
  AST_NODE_TYPES.TSFunctionType,
  AST_NODE_TYPES.TSImportType,
  AST_NODE_TYPES.TSIndexedAccessType,
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / camelcase.ts View on Github external
create(context, [options]) {
    const rules = baseRule.create(context);
    const TS_PROPERTY_TYPES = [
      AST_NODE_TYPES.TSPropertySignature,
      AST_NODE_TYPES.ClassProperty,
      AST_NODE_TYPES.TSParameterProperty,
      AST_NODE_TYPES.TSAbstractClassProperty,
    ];

    const genericType = options.genericType;
    const properties = options.properties;
    const allow =
      options.allow?.map(entry => ({
        name: entry,
        regex: new RegExp(entry),
      })) ?? [];

    /**
     * Checks if a string contains an underscore and isn't all upper-case
     * @param  name The string to check.
     */
    function isUnderscored(name: string): boolean {
      // if there's an underscore, it might be A_CONSTANT, which is okay
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent-new-do-not-use / index.ts View on Github external
// ts keywords
  AST_NODE_TYPES.TSAbstractKeyword,
  AST_NODE_TYPES.TSAnyKeyword,
  AST_NODE_TYPES.TSBooleanKeyword,
  AST_NODE_TYPES.TSNeverKeyword,
  AST_NODE_TYPES.TSNumberKeyword,
  AST_NODE_TYPES.TSStringKeyword,
  AST_NODE_TYPES.TSSymbolKeyword,
  AST_NODE_TYPES.TSUndefinedKeyword,
  AST_NODE_TYPES.TSUnknownKeyword,
  AST_NODE_TYPES.TSVoidKeyword,
  AST_NODE_TYPES.TSNullKeyword,

  // ts specific nodes we want to support
  AST_NODE_TYPES.TSAbstractClassProperty,
  AST_NODE_TYPES.TSAbstractMethodDefinition,
  AST_NODE_TYPES.TSArrayType,
  AST_NODE_TYPES.TSAsExpression,
  AST_NODE_TYPES.TSCallSignatureDeclaration,
  AST_NODE_TYPES.TSConditionalType,
  AST_NODE_TYPES.TSConstructorType,
  AST_NODE_TYPES.TSConstructSignatureDeclaration,
  AST_NODE_TYPES.TSDeclareFunction,
  AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
  AST_NODE_TYPES.TSEnumDeclaration,
  AST_NODE_TYPES.TSEnumMember,
  AST_NODE_TYPES.TSExportAssignment,
  AST_NODE_TYPES.TSExternalModuleReference,
  AST_NODE_TYPES.TSFunctionType,
  AST_NODE_TYPES.TSImportType,
  AST_NODE_TYPES.TSIndexedAccessType,
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / naming-convention.ts View on Github external
| TSESTree.TSParameterProperty,
    ): Set {
      const modifiers = new Set();
      if (node.accessibility) {
        modifiers.add(Modifiers[node.accessibility]);
      } else {
        modifiers.add(Modifiers.public);
      }
      if (node.static) {
        modifiers.add(Modifiers.static);
      }
      if ('readonly' in node && node.readonly) {
        modifiers.add(Modifiers.readonly);
      }
      if (
        node.type === AST_NODE_TYPES.TSAbstractClassProperty ||
        node.type === AST_NODE_TYPES.TSAbstractMethodDefinition
      ) {
        modifiers.add(Modifiers.abstract);
      }

      return modifiers;
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / semi.ts View on Github external
const rules = baseRule.create(context);
    const checkForSemicolon = rules.ExpressionStatement as TSESLint.RuleFunction<
      TSESTree.Node
    >;

    /*
      The following nodes are handled by the member-delimiter-style rule
      AST_NODE_TYPES.TSCallSignatureDeclaration,
      AST_NODE_TYPES.TSConstructSignatureDeclaration,
      AST_NODE_TYPES.TSIndexSignature,
      AST_NODE_TYPES.TSMethodSignature,
      AST_NODE_TYPES.TSPropertySignature,
    */
    const nodesToCheck = [
      AST_NODE_TYPES.ClassProperty,
      AST_NODE_TYPES.TSAbstractClassProperty,
      AST_NODE_TYPES.TSAbstractMethodDefinition,
      AST_NODE_TYPES.TSDeclareFunction,
      AST_NODE_TYPES.TSExportAssignment,
      AST_NODE_TYPES.TSImportEqualsDeclaration,
      AST_NODE_TYPES.TSTypeAliasDeclaration,
    ].reduce((acc, node) => {
      acc[node as string] = checkForSemicolon;
      return acc;
    }, {});

    return {
      ...rules,
      ...nodesToCheck,
      ExportDefaultDeclaration(node): void {
        if (node.declaration.type !== AST_NODE_TYPES.TSInterfaceDeclaration) {
          rules.ExportDefaultDeclaration(node);
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / quotes.ts View on Github external
function isAllowedAsNonBacktick(node: TSESTree.Literal): boolean {
      const parent = node.parent;

      switch (parent?.type) {
        case AST_NODE_TYPES.TSAbstractMethodDefinition:
        case AST_NODE_TYPES.TSMethodSignature:
        case AST_NODE_TYPES.TSPropertySignature:
        case AST_NODE_TYPES.TSModuleDeclaration:
        case AST_NODE_TYPES.TSLiteralType:
          return true;

        case AST_NODE_TYPES.TSEnumMember:
          return node === parent.id;

        case AST_NODE_TYPES.TSAbstractClassProperty:
        case AST_NODE_TYPES.ClassProperty:
          return node === parent.key;

        default:
          return false;
      }
    }

@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