Skip to content

Conversation

kripod
Copy link
Contributor

@kripod kripod commented Sep 17, 2024

Prerequisites checklist

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

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

Tell us about your environment (npx eslint --env-info):

  • Node version: v22.8.0
  • npm version: v10.8.2
  • Local ESLint version: v9.10.0 (Currently used)
  • Global ESLint version: Not found
  • Operating System: darwin 23.6.0

What parser are you using (place an "X" next to just one item)?

N/A

Please show your full configuration:

N/A

What did you do? Please include the actual source code causing the issue.

import type { Linter } from "eslint";
import type { ESLintRules } from "eslint/rules";

export default {
  rules: {
    "no-restricted-exports": [
      "error",
      {
        restrictedNamedExports: [
          // Ambiguous with dynamic imports
          // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#module_namespace_object
          "then",
        ],
        restrictDefaultExports: {
          // Prefer `export default` expressions
          named: true,

          // Avoid re-exporting entire modules as is
          namespaceFrom: true,
        },
      },
    ],
  },
} satisfies Linter.Config<ESLintRules>;

What did you expect to happen?

Autocompletion and type checking should be in place for the no-restricted-exports rule.

What actually happened? Please include the actual, raw output from ESLint.

No assistance was given by TypeScript.

What changes did you make? (Give an overview)

Added type declarations for the no-restricted-exports rule.

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

N/A

@kripod kripod requested a review from a team as a code owner September 17, 2024 03:59
@eslint-github-bot eslint-github-bot bot added the bug ESLint is working incorrectly label Sep 17, 2024
Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 6e55adb
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/66e8febfada51000081464a0
😎 Deploy Preview https://deploy-preview-18914--docs-eslint.netlify.app
📱 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 configuration.

/**
* @since 8.33.0
*/
restrictDefaultExports: Partial<{
Copy link
Contributor

@snitin315 snitin315 Sep 19, 2024

Choose a reason for hiding this comment

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

This option works only if the restrictedNamedExports option does not contain the "default" value. Can that be checked via typescript too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not really 😕. There are no "negated" types in TypeScript (microsoft/TypeScript#4196), so you can't say "this type is all strings except some literal".

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, it should be fine then.

@snitin315 snitin315 added the accepted There is consensus among the team that this change meets the criteria for inclusion label Sep 19, 2024
Copy link
Contributor

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you.

@snitin315 snitin315 merged commit 5e5f39b into eslint:main Sep 20, 2024
23 checks passed
@kripod kripod deleted the patch-1 branch September 21, 2024 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly contributor pool

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants