Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

馃悰 noUnreachableSuper incorrectly being triggered #4674

Closed
1 task done
peniqliotuv opened this issue Jul 9, 2023 · 1 comment
Closed
1 task done

馃悰 noUnreachableSuper incorrectly being triggered #4674

peniqliotuv opened this issue Jul 9, 2023 · 1 comment
Labels
A-Linter Area: linter S-Bug: confirmed Status: report has been confirmed as a valid bug

Comments

@peniqliotuv
Copy link

peniqliotuv commented Jul 9, 2023

Environment information

Running rome rage reveals some sensitive information. Instead, I'll share some system and environment information.
arch: arm64

Node version: 16.18.0
Rome version: 12.1.3

Rome.json:

{
  "$schema": "https://docs.rome.tools/schemas/12.1.3/schema.json",
  "organizeImports": {
    "enabled": true
  },
  "files": {
    "ignore": [
      "**/coverage/**",
      "node_modules/**",
      ".sst/**",
      "**/sdk/**",
      "**/out/_next/**",
      "**/.next/**",
      "**/node_modules/**",
      "**/.build/**",
      "**/dist/**",
      "**/storybook/**",
      "**/*.bundle.js"
    ]
  },
  "linter": {
    "enabled": true,
    "rules": {
      "suspicious": {
        "noExplicitAny": "off"
      },
      "style": {
        "noNonNullAssertion": "off"
      },
      "recommended": true,
      "nursery": {
        "noConsoleLog": "warn"
      }
    }
  },
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "space",
    "indentSize": 2,
    "lineWidth": 80,
    "ignore": []
  },
  "javascript": {
    "formatter": {
      "semicolons": "always",
      "trailingComma": "es5",
      "quoteStyle": "single"
    }
  }
}

I also have Rome's VSCode extension installed.

What happened?

I have a custom AWS CDK Construct that extends a class and implements another.
Rome is incorrectly telling me that I'm calling super() in a loop.
Here is an example that fails Rome's lint/correctness/noUnreachableSuper lint rule

export class S3Event extends Construct implements EventBridgeEvent {
  public readonly bucketNames?: string[];

  public readonly keyPrefixes?: string[];

  public readonly eventType?: string[];

  public readonly targetProps: {
    message: RuleTargetInput;
  };

  public readonly eventPattern: KeyedRequired<EventPattern, 'source'>;

  /**
   *
   * @param scope The stack from which you are instantiating a MonitoredQueue
   * @param name A name for the event
   */

  constructor(scope: Stack, name: string, options: S3EventOptions) {
    super(scope, name);

    this.bucketNames = options.bucketNames;
    this.keyPrefixes = options.keyPrefixes;
    this.eventType = options.eventType;

    // We don't want _all_ the fields, but we do at least the detail-type in
    // addition the event details itself, as it contains the S3 event-type.
    this.targetProps = {
      message: RuleTargetInput.fromObject({
        s3Event: EventField.fromPath('$.detail'),
        s3EventType: EventField.detailType,
      }),
    };

    // See supported event patterns: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html
    const details: S3DetailPattern = {};
    if (this.bucketNames) {
      details.bucket = { name: this.bucketNames };
    }
    if (this.keyPrefixes) {
      const rules = this.keyPrefixes.map((p) => ({
        prefix: p,
      }));
      details.object = { key: rules };
    }

    this.eventPattern = {
      source: ['aws.s3'],
      detailType: this.eventType,
      detail: Object.keys(details).length === 0 ? undefined : details,
    };
  }
}
image

Expected result

It should not give me a lint error

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@peniqliotuv peniqliotuv added the S-To triage Status: user report of a possible bug that needs to be triaged label Jul 9, 2023
@ematipico ematipico added S-Bug: confirmed Status: report has been confirmed as a valid bug A-Linter Area: linter and removed S-To triage Status: user report of a possible bug that needs to be triaged labels Jul 11, 2023
@Conaclos
Copy link
Contributor

Closed because the bug is no longer present on the playground.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter S-Bug: confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

3 participants