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.

Make a new group for the built-in native node packages

See original GitHub issue

For example I want to have those imports into a new separated group:

import crypto from 'crypto';
import fs from 'fs';
import path from 'path';
import util from 'util';

Those packages are node built-in.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
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"],
          [
            "^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)"
          ],
          ["^@?\\w"],
          ["^[^.]"],
          ["^\\."]
        ]
      }
    ]
  }
}

You could also generate this regex if you use a .js config. For example:

`^(${require("module").builtinModules.join("|")})(/|$)`;
2reactions
bfmivcommented, Dec 9, 2019

@lydell this is perfect, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing Native Node.js Modules - RisingStack Engineering
This article explains how native Node.js modules work, and how you can use them to increase the performance of your application.
Read more >
How To Use Node.js Modules with npm and package.json
First, set up a project so you can practice managing modules. In your shell, create a new folder called locator : mkdir locator....
Read more >
Native Node Modules | Electron
Manually building for a custom build of Electron​ ... To compile native Node modules against a custom build of Electron that doesn't match...
Read more >
Modules: Packages | Node.js v19.3.0 Documentation
Introduction#. A package is a folder tree described by a package.json file. The package consists of the folder containing the package.json file and...
Read more >
Creating Node.js modules - npm Docs
To create a package.json file, on the command line, in the root directory of your Node.js module, run npm init : · Provide...
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