Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-named-as-default] Add ignorePaths option #3131

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sahar541998
Copy link

@Sahar541998 Sahar541998 commented Dec 26, 2024

Adding Ignore Paths Option to no-named-as-default Rule

Summary

This PR introduces an ignorePaths option to the no-named-as-default ESLint rule.

The purpose of this enhancement is to provide flexibility in cases where certain packages, like styled-components, require importing a named export as a default export. These imports are valid but may be incorrectly flagged by the current rule.

Use Case

For example, the following import is valid in the context of styled-components, but it may be flagged by the no-named-as-default rule:

import styled from 'styled-components';

With the new ignorePaths option, you can specify patterns to exclude such packages or paths from this rule's validation.

Changes

Added ignorePaths configuration to the no-named-as-default rule.
Updated rule documentation to reflect the new option and its usage.

Configuration Example

To use this new option, include it in your ESLint configuration file:

module.exports = {
  rules: {
    'import/no-named-as-default': [
      'error',
      {
        ignorePaths: ['styled-components', 'some-other-package']
      }
    ]
  }
};

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.47%. Comparing base (e5edf49) to head (32173f1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3131      +/-   ##
==========================================
+ Coverage   95.08%   95.47%   +0.39%     
==========================================
  Files          83       83              
  Lines        3618     3623       +5     
  Branches     1276     1280       +4     
==========================================
+ Hits         3440     3459      +19     
+ Misses        178      164      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Sahar541998
Copy link
Author

I noticed that [Native and WSL / build (windows-2019, 4, wsl)] failed due to the use of includes.
Should I use import includes from 'array-includes'; instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant