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.

Split both options of no-unused-modules into 2 rules

See original GitHub issue

Apologies if there is already a ticket for this.

I find no-unused-modules a very powerful rule however very confusing due to its options. It seems to me missingExports and unusedExports effectively respond to 2 different use cases.

Additionally, the ignoreExports option applies to both options, but sometimes it makes sense to ignore patterns for one but not for the other. For example, it might be ok for everything under test/ to not export anything but we still might want to make sure that anything exported in a test file is imported somewhere (another test file for example). For this use case, my organization uses a dedicated .eslintrc.yml file in test/, but people locating their test files next to their source files will not have this chance.

I believe I saw a ticket suggesting an additional ignore list to address this, which would help making my case, but I can’t seem to find it anymore so maybe I just saw what I wanted to see 😅

Lastly, I find this rule difficult to configure and predict: it respects .eslintignore patters, nested ESLint configurations, has an additional src options to find further patterns, but also an ignore list on its own, and will even honor files listed in package.json (which is potentially great) if and only if the project is not private (which is less great). I feel like splitting this rule in 2 would help reduce the confusion and may offer a way to simplify branches of configuration/ignores.

Thoughts?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
astorijecommented, Mar 12, 2020

I agree, which is why I think it would be nice to be able to configure those 2 things separately, since even the rule description explains the rule in 2 different parts: “Forbid modules without any export, and exports not imported by any modules”.

0reactions
ljharbcommented, Mar 12, 2020

Files without exports can still be used for side effects, and be entry points of a package (or, tbh, entry points in a browser in an app).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Split string with multiple delimiters in Python - Stack Overflow
I have a string that needs to be split by either a ';' or ', ' That is, it has to be either...
Read more >
String.Split Method (System) - Microsoft Learn
Split (Char, Int32, StringSplitOptions). Splits a string into a maximum number of substrings based on a specified delimiting character and, optionally, options.
Read more >
Splitting a Java String by Multiple Delimiters - Baeldung
Learn different options for splitting an input string by multiple delimiters using regular expressions, Google Guava, and Apache Commons.
Read more >
How to use Split in Python Explained - KnowledgeHut
The Split function takes whitespace (“ ”) as a separator and the maximum number of splits or maxsplit is 2. The first two...
Read more >
String.prototype.split() - JavaScript - MDN Web Docs
The split() method takes a pattern and divides a String into an ordered list of substrings by searching for the pattern, ...
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