Skip to content

Bug: RuleCreator leaks internal meta.docs, meta.type types #8695

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

utils

Playground Link

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgUQMoBlgDsYFUbAA2AznAL5wBmUEIcA5AAIwCeYApsQMZTBgwBaToWwwA9AFcCJegG4AUPPYAPSLDhcIWYvCgTC7OAF4UGUfiLEAdACV97AMJR2AQxjQrAd2AwAFhCkAEQguYgAKBHk4DWc3djDNHBUYAEpEKOi4ZxgJKCx0zMyASQATdhxgSmB2KDCsCDK0yMLCxJhkq2c1GAi4EE5iFwBzdlKALjgAIhUXcANJgBo4erLyFIUW8gzosgyyBYyyyhd9GAB5fmAtYgmAbQBdA+j+mBcJ5sySkJuClrLuXiXLQTej0J4tZyaED9LBlEogyG0GFwsHbTIQPw1CYwPTscE7fF9AbDTjvNHRGZzdgTSZnXzLCAAQkmaP2aNYHBBhBcLACMFRhW4vnYIDecAeewOZHWiiAA

Repro Code

import { ESLintUtils } from '@typescript-eslint/utils';

export const rule = ESLintUtils.RuleCreator.withoutDocs({
  create(context) {
    return {
      Identifier(node) {
        context.report({ messageId: "example", node });
      }
    }
  },
  defaultOptions: [],
  meta: {
    docs: {
      description: '',
      recommended: 'recommended',
      other: true,
    },
    messages: {
      example: "Oh no!"
    },
    type: 'layout',
    schema: []
  },
});

ESLint Config

n/a

tsconfig

n/a

Expected Result

Custom rules in community plugins shouldn't be tied into our types for what goes into a rule's meta.docs. Plugins might define their own, potentially different documentation metadata & strategies.

Maybe we should make meta.docs type... Record<string, unknown> for consumers? Or a type parameter on RuleCreator that defaults to Record<string, unknown>?

Actual Result

Additional Info

See also:

Versions

package version
@typescript-eslint/utils 7.2.0

💖

Metadata

Metadata

Labels

accepting prsGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedbugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions