Skip to main content
The other answers are not always "above". Sure, they are while you type your answer - but then they're sorted in the page once posted. Criteria are "Trending", "Highest score", "Date modified", "Date created". Your answer will be placed in the page according to this parameter.
Source Link
Eric Aya
  • 70.2k
  • 36
  • 190
  • 266

the aboveFarzad's solution gave me some problems like false positive or does not work in:

the above solution gave me some problems like false positive or does not work in:

Farzad's solution gave me some problems like false positive or does not work in:

added 299 characters in body
Source Link
Source Link

the above solution gave me some problems like false positive or does not work in:

import "package"; import PackageDefault, {} from "package"; 

I solved it with:

  1. Run
npm install eslint-plugin-regex 
  1. Change you eslintrc
{ "plugins": [ "regex" ], "rules": { "regex/invalid": [ "error", [ { "id": "EmptyImport", "message": "errorMessageN", "regex": "import(.*{\\s*}.*)from", "replacement": { "function": "return $[1].replace(/\\s/g, '') !== '{}' ? $[0].replace(/,?\\s{\\s*},?\\s/, ' ') : $[0]" } } ] ], } } 
### This rule suport eslint --fix 
import {} from "package"; // manual fixable import package, {} from "package"; // import package from "package"; 

to automatically remove import voids during eslint fix:

import {} from "package"; 
  1. Use this rule in place of the other
{ "id": "EmptyImport", "message": "errorMessageN", "regex": "import(.*{\\s*}.*)from.*\\n", "replacement": { "function": "return $[1].replace(/\\s/g, '') !== '{}' ? $[0].replace(/,?\\s{\\s*}\\s/, ' ') : ''" } }