Skip to content

[no-duplicates] invalid fix when there are 3 imports with named imports and dangling commas #2840

@bradzacher

Description

@bradzacher

Input:

import {A1,} from 'foo';
import {B1,} from 'foo';
import {C1,} from 'foo';

import {
  A2,
} from 'bar';
import {
  B2,
} from 'bar';
import {
  C2,
} from 'bar';

Expected:

Error and fixed to

import {A1,B1,C1,} from 'foo';
import {
  A2,
  B2,
  C2,
} from 'bar';

(or something similar)

Actual:

Error and fixed to

import {A1,B1,,C1,} from 'foo';
              ^ SYNTAX ERROR
import {
  A2,

  B2,
,
^ SYNTAX ERROR
  C2,
} from 'bar';

Interestingly this bug requires 3 (or more) duplicate declarations to trigger.

I haven't looked yet - but given it happens for 3 and not 2 - I'd assume that ESLint is merging the distinct fixes poorly - leading to the syntax error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions