Skip to content

eslint-disable directives require C-style comments #645

Closed
@danvk

Description

@danvk

🐛 Bug Report

  • tslint-to-eslint-config version: 1.0.0
  • ESLint version: v7.5.0
  • Node version: v12.16.3

Actual Behavior

I had some code like this:

// See https://github.com/mikolalysenko/hash-int
export function hashInt(x: number) {
  // tslint:disable:no-bitwise
  const HASH = new Uint32Array(1);
  HASH[0] = x | 0;
  HASH[0] -= HASH[0] << 6;
  HASH[0] ^= HASH[0] >>> 17;
  HASH[0] -= HASH[0] << 9;
  HASH[0] ^= HASH[0] << 4;
  HASH[0] -= HASH[0] << 3;
  HASH[0] ^= HASH[0] << 10;
  HASH[0] ^= HASH[0] >>> 15;
  return HASH[0];
  // tslint:enable
}

When I migrate with --comments, this becomes:

export function hashInt(x: number) {
  // eslint-disable no-bitwise
  const HASH = new Uint32Array(1);
  HASH[0] = x | 0;
  HASH[0] -= HASH[0] << 6;
  HASH[0] ^= HASH[0] >>> 17;
  HASH[0] -= HASH[0] << 9;
  HASH[0] ^= HASH[0] << 4;
  HASH[0] -= HASH[0] << 3;
  HASH[0] ^= HASH[0] << 10;
  HASH[0] ^= HASH[0] >>> 15;
  return HASH[0];
  // eslint-enable
}

Unfortunately this allows all the no-bitwise errors to surface in eslint.

Expected Behavior

It seems that eslint requires C-style comments for eslint-disable directives:

export function hashInt(x: number) {
  /* eslint-disable no-bitwise */
  const HASH = new Uint32Array(1);
  HASH[0] = x | 0;
  HASH[0] -= HASH[0] << 6;
  HASH[0] ^= HASH[0] >>> 17;
  HASH[0] -= HASH[0] << 9;
  HASH[0] ^= HASH[0] << 4;
  HASH[0] -= HASH[0] << 3;
  HASH[0] ^= HASH[0] << 10;
  HASH[0] ^= HASH[0] >>> 15;
  return HASH[0];
  /* eslint-enable */
}

Note that this doesn't seem to be the case for eslint-disable-line or eslint-disable-next-line.

Reproduction

Metadata

Metadata

Assignees

Labels

status: accepting prsPlease, send in a PR to resolve this! ✨type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions