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

feat: add restrictDefaultExports option to no-restricted-exports rule #16785

Merged
merged 14 commits into from Jan 28, 2023

Conversation

snitin315
Copy link
Contributor

@snitin315 snitin315 commented Jan 14, 2023

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[x] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Resolve #15617

  • "restrictDefaultExports" is an object option with boolean properties to restrict certain default export declarations. The option works only if the restrictedNamedExports option does not contain the "default" value. The following properties are allowed:
    • direct: restricts export default declarations.
    • named: restricts export { foo as default }; declarations.
    • defaultFrom: restricts export { default } from 'foo';, export { default as default } from 'foo'; declarations.
    • namedFrom: restricts export { foo as default } from 'foo'; declarations.
    • namespaceFrom: restricts export * as default from 'foo'; declarations.

Is there anything you'd like reviewers to focus on?

Open to suggestions for the error message, if it should be different for each property.

@eslint-github-bot eslint-github-bot bot added the triage An ESLint team member will look at this issue soon label Jan 14, 2023
@eslint-github-bot

This comment was marked as resolved.

@netlify
Copy link

netlify bot commented Jan 14, 2023

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 5bf2be1
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/63cf4144194a7b000891322a
😎 Deploy Preview https://deploy-preview-16785--docs-eslint.netlify.app/rules/no-restricted-exports
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Jan 14, 2023
@eslint-github-bot

This comment was marked as resolved.

@snitin315 snitin315 changed the title feat: add restrictDefaultExports option to no-restricted-exports rule feat: add restrictDefaultExports option to no-restricted-exports rule Jan 14, 2023
@snitin315 snitin315 marked this pull request as ready for review January 15, 2023 03:18
@snitin315 snitin315 requested a review from a team as a code owner January 15, 2023 03:18
@mdjermanovic mdjermanovic added rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jan 15, 2023
lib/rules/no-restricted-exports.js Outdated Show resolved Hide resolved
lib/rules/no-restricted-exports.js Outdated Show resolved Hide resolved
lib/rules/no-restricted-exports.js Outdated Show resolved Hide resolved
lib/rules/no-restricted-exports.js Outdated Show resolved Hide resolved
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two small suggestions, then LGTM.

docs/src/rules/no-restricted-exports.md Outdated Show resolved Hide resolved
lib/rules/no-restricted-exports.js Outdated Show resolved Hide resolved
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

I'll leave this open for a few days in case someone else wants to review it before merging.

@btmills btmills merged commit 2cc7954 into main Jan 28, 2023
21 checks passed
@btmills btmills deleted the add-restrictedDefaultExports branch January 28, 2023 22:14
@elyobo
Copy link

elyobo commented Feb 2, 2023

@snitin315 @mdjermanovic @btmills does the new validation rules for no-restricted-exports options introduce a backwards compatible break here? Users with default in the restrictedNamedExports (which is the case in the popular airbnb / airbnb-base config) will be hit with an error in a minor release if I'm reading that correctly?

@mdjermanovic
Copy link
Member

@snitin315 @mdjermanovic @btmills does the new validation rules for no-restricted-exports options introduce a backwards compatible break here? Users with default in the restrictedNamedExports (which is the case in the popular airbnb / airbnb-base config) will be hit with an error in a minor release if I'm reading that correctly?

This change shouldn't break existing configs, because "default" in restrictedNamedExports is still allowed if the configuration object does not have restrictDefaultExports key. Configuration object without restrictDefaultExports will match this alternative where there are no pattern restrictions on restrictedNamedExports.

@elyobo
Copy link

elyobo commented Feb 2, 2023

Thanks, makes sense.

crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Feb 2, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint](https://eslint.org) ([source](https://github.com/eslint/eslint)) | devDependencies | minor | [`8.32.0` -> `8.33.0`](https://renovatebot.com/diffs/npm/eslint/8.32.0/8.33.0) |

---

### Release Notes

<details>
<summary>eslint/eslint</summary>

### [`v8.33.0`](https://github.com/eslint/eslint/releases/tag/v8.33.0)

[Compare Source](eslint/eslint@v8.32.0...v8.33.0)

#### Features

-   [`2cc7954`](eslint/eslint@2cc7954) feat: add `restrictDefaultExports` option to no-restricted-exports rule ([#&#8203;16785](eslint/eslint#16785)) (Nitin Kumar)

#### Documentation

-   [`17f4be2`](eslint/eslint@17f4be2) docs: Fix examples in no-multiple-empty-lines rule ([#&#8203;16835](eslint/eslint#16835)) (jonz94)
-   [`9c7cfe3`](eslint/eslint@9c7cfe3) docs: 'Source Code' content in 'Set up Development Environment' page ([#&#8203;16780](eslint/eslint#16780)) (Ben Perlmutter)
-   [`ede5c64`](eslint/eslint@ede5c64) docs: Custom processors page ([#&#8203;16802](eslint/eslint#16802)) (Ben Perlmutter)
-   [`2620614`](eslint/eslint@2620614) docs: Code of Conduct page ([#&#8203;16781](eslint/eslint#16781)) (Ben Perlmutter)
-   [`50a8efd`](eslint/eslint@50a8efd) docs: report a sec vulnerability page ([#&#8203;16808](eslint/eslint#16808)) (Ben Perlmutter)
-   [`ed60afd`](eslint/eslint@ed60afd) docs: Update page titles, section landing pages, and side TOC ([#&#8203;16760](eslint/eslint#16760)) (Ben Perlmutter)
-   [`333c712`](eslint/eslint@333c712) docs: add background to code-path-diagrams for dark-mode ([#&#8203;16822](eslint/eslint#16822)) (Tanuj Kanti)
-   [`f5f7b9b`](eslint/eslint@f5f7b9b) docs: Update README (GitHub Actions Bot)
-   [`2aa4f5f`](eslint/eslint@2aa4f5f) docs: no-constant-condition: Add multi-comparison example ([#&#8203;16776](eslint/eslint#16776)) (Sebastian Simon)
-   [`40287db`](eslint/eslint@40287db) docs: Remove Google Group icon ([#&#8203;16779](eslint/eslint#16779)) (Nicholas C. Zakas)
-   [`ea10ca5`](eslint/eslint@ea10ca5) docs: 'a .eslint' -> 'an .eslint' for consistency ([#&#8203;16809](eslint/eslint#16809)) (Ben Perlmutter)
-   [`3be0748`](eslint/eslint@3be0748) docs: add example for nodejs lintText api ([#&#8203;16789](eslint/eslint#16789)) (Siva K)
-   [`ce4f5ff`](eslint/eslint@ce4f5ff) docs: Replace removed related rules with a valid rule ([#&#8203;16800](eslint/eslint#16800)) (Ville Saalo)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMTUuMSIsInVwZGF0ZWRJblZlciI6IjM0LjExOS4yIn0=-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1759
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jul 28, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: no-restricted-exports fails on export { default, ... } from ...
4 participants