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.

Handle custom groups

See original GitHub issue

Nowadays, absolute imports is a very popular thing, as well as monorepos with different features “stored” as a separate packages. However they are not packages.

Webpack aliases and yarn workspaces are breaking original idea behind the “groups” feature.

import React from 'react';              // 1. "external" package
import Button from 'components/Button'; // 2. "internal" package (or just an absolute URL)
import style from './style';            // 3. "relative" module
import "./messages";                    // 4. side effect

Technically these are:

  1. packages in node_modules
  2. packages not in node_modules
  3. relative path
  4. no import
  • 2 could be distinguished from 1 by calling require.resolve and checking path to include node_modules (obvious)
  • 2 could be distinguished from 1 by having some configuration rules, but I reckon it’s not feature proof and quite fragile.

I could work on PR if you’ll accept the idea

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lydellcommented, Nov 22, 2019

This is now possible in v5.0.0 using custom grouping.

For example:

{
  "rules": {
    "simple-import-sort/sort": [
      "error",
      {
        "groups": [["^\\u0000"], ["^@?\\w"], ["^components(/.*|$)"], ["^\\."]]
      }
    ]
  }
}
0reactions
theKasheycommented, Sep 12, 2019
  • get the module name
  • if it seems to me a “package” (or absolute)
  • call require.resolve.
  • if call was _unsuccessful, or does not contain node_modules(but I think it would be the first case) - it is an absolute import. Only the “real packages” would be resolved.

Thus the problem could be solved without any configuration needed from a user.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage custom groups (beta) - Mattermost Documentation
To manage a custom user group, select User Groups from the Products menu, then select the group you want to modify.
Read more >
Create and Manage Custom Groups | Dell US
This article provides information about how to create and manage custom groups to help customize your online support experience.
Read more >
How to manage custom groups - NWEA Connection
How to manage custom groups for use in MAP Skills. ... Select Manage Custom Groups in the main navigation menu.
Read more >
Create & Manage Custom Groups - Teamworks Support
To create a custom group, log into your Teamworks account in a web browser and navigate to the Profiles tab. Select the “Custom...
Read more >
Creating custom groups - ManageEngine Device Control Plus
Create a Custom Group · Select the Admin tab · Click the Custom Groups link available under the Global Settings. This will list...
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