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 rule could allow grouping

See original GitHub issue

What rule do you want to change? We like to group imports by what’s an external dependency versus what is in our application. It would be nice if the sort-imports allowed for groupings with a blank line in between.

Does this change cause the rule to produce more or fewer warnings? Fewer, I think.

How will the change be implemented? (New option, new default behavior, etc.)? New option, something like allow-grouping or sort-within-groups. Maybe default as well, but not necessary.

Please provide some example code that this change will affect:

import React from 'react';
import {shallow} from 'enzyme';

import PagesList from 'js/admin/pages/components/list';

What does the rule currently do for this code? It complains about sort order, as import PagesList should be above import React.

What will the rule do after it’s changed? It will allow for groups of imports separated by blank lines and run on each group separately.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mockdeepcommented, Dec 14, 2016

Alright, @platinumazure, I’ve updated the description.

1reaction
mockdeepcommented, Dec 14, 2016

The last would be great, but the second one is what I had imagined. Basically I’d like for the rule to enforce sorting within groupings, but not across them. Enforcing grouping based on what is local vs external seems like potentially an entirely different rule. I’ll update a little later with the template.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[sort-imports] Allow the users to group their imports in a simple ...
What will the rule do after it's changed? After the change, the new option will allow grouping of imports, each of which will...
Read more >
sort-imports - ESLint - Pluggable JavaScript Linter
This rule checks all import declarations and verifies that all imports are first sorted by the used member syntax and then alphabetically by...
Read more >
How to quickly configure ESLint for import sorting
This particular rule can help us circumvent these particular edge cases by specifying something called pathGroups. "groups": [ "external", " ...
Read more >
ESLint import sort grouping - Stack Overflow
I want to sort imports. I configured it and now everything works fine. But, I can't group imports and sort. import request from ......
Read more >
How to Sort Imports in React Project - Level Up Coding
I prefer to use eslint-plugin-simple-import-sort which is easier and just one option for configuring the group. In follow content we will learn how...
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