question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sort-imports should treat single import of multiple style as "multiple" type

See original GitHub issue

What version of ESLint are you using? HEAD

What rule do you want to change? sort-imports

What code should no longer be flagged as incorrect with this change?

import * as bar from 'bar.js';
import { a } from 'foo';

What happens when the rule is applied to this code now? X:Y error Imports should be sorted alphabetically

Root cause The rule uses node.specifiers.length to determine if an import is of type multiple or single. The bug is that imports of multiple-style with a single import (import { a } from 'foo';) are treated as single.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
btmillscommented, Sep 4, 2016

@LegNeato thanks for your patience and for putting together that repro. I’m getting the same results now.

Before I consider the bug verified and accept the issue, are we comfortable treating the “single” option as a synonym for default imports and the “multiple” option as a synonym for named imports?

If accepted as stated, this would be a semver-minor change, as it could result in more errors in the following case:

// test6736_reversed.js
import { a } from 'foo'; // Multiple
import bar from 'bar.js'; // Single

Currently, the above case does not error. After this change, it would warn.

0reactions
kaicataldocommented, Jan 8, 2017

I’m closing this issue because it looks like consensus couldn’t be reached. While we wish we could accommodate all requests, we have limited resources and do need to prioritize. We’ve found that issues failing to reach consensus after 21 days tend to never reach consensus, and as a team have decided to close such issues. This doesn’t mean the idea isn’t interesting or valuable, only that it’s not something the team can commit to at the moment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expected 'multiple' syntax before 'single' syntax - Stack Overflow
Both import { getModule } from 'vuex-module-decorators'; and import { INavs } from '@/types'; are only importing a single named export. That ...
Read more >
Configuration options for isort
If you want to skip multiple files you should specify twice: --skip file1 --skip file2. Values can be file names, directory names or...
Read more >
sort-imports - Visual Studio Marketplace
Use a different style or parser. Styles (and parsers) can be configured on a per-project basis including support for different types of files...
Read more >
Optimize Imports in WebStorm - The JetBrains Blog
It merges multiple imports from the same file. It can sort imports – and members inside them – by module name. To run...
Read more >
Configuration · Scalafmt - Scalameta
When this parameter is disabled, no indentation is added for same-line single-arg cases; the assumption is that if the argument expression spans multiple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found