How to use the @typescript-eslint/experimental-utils.AST_NODE_TYPES.ClassProperty 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 / indent-new-do-not-use / index.ts View on Github external
AST_NODE_TYPES.JSXClosingElement,
  AST_NODE_TYPES.JSXOpeningElement,
  AST_NODE_TYPES.JSXAttribute,
  AST_NODE_TYPES.JSXSpreadAttribute,
  AST_NODE_TYPES.JSXText,
  AST_NODE_TYPES.ExportDefaultDeclaration,
  AST_NODE_TYPES.ExportNamedDeclaration,
  AST_NODE_TYPES.ExportAllDeclaration,
  AST_NODE_TYPES.ExportSpecifier,
  AST_NODE_TYPES.ImportDeclaration,
  AST_NODE_TYPES.ImportSpecifier,
  AST_NODE_TYPES.ImportDefaultSpecifier,
  AST_NODE_TYPES.ImportNamespaceSpecifier,

  // Class properties aren't yet supported by eslint...
  AST_NODE_TYPES.ClassProperty,

  // 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,
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent.ts View on Github external
*/
/* eslint-disable @typescript-eslint/no-explicit-any */

import {
  TSESTree,
  AST_NODE_TYPES,
} from '@typescript-eslint/experimental-utils';
import baseRule from 'eslint/lib/rules/indent';
import * as util from '../util';

type Options = util.InferOptionsTypeFromRule;
type MessageIds = util.InferMessageIdsTypeFromRule;

const KNOWN_NODES = new Set([
  // Class properties aren't yet supported by eslint...
  AST_NODE_TYPES.ClassProperty,

  // 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,
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / explicit-function-return-type.ts View on Github external
function isClassPropertyWithTypeAnnotation(node: TSESTree.Node): boolean {
      return (
        node.type === AST_NODE_TYPES.ClassProperty && !!node.typeAnnotation
      );
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / no-magic-numbers.ts View on Github external
function isParentTSReadonlyClassProperty(node: TSESTree.Node): boolean {
      if (
        node.parent &&
        node.parent.type === AST_NODE_TYPES.UnaryExpression &&
        ['-', '+'].includes(node.parent.operator)
      ) {
        node = node.parent;
      }

      if (
        node.parent &&
        node.parent.type === AST_NODE_TYPES.ClassProperty &&
        node.parent.readonly
      ) {
        return true;
      }

      return false;
    }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / semi.ts View on Github external
create(context) {
    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) {
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;
      }
    }
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.
     */

@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