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

Allow additional types of dynamic schemas in require-meta-schema rule #277

Merged
merged 1 commit into from
Aug 4, 2022

Conversation

bmish
Copy link
Member

@bmish bmish commented Aug 3, 2022

The goal is to ban obviously-invalid types like Literal (string/number) for meta.schema, while allowing any kind of variables/function calls/dynamic calculation of the schema.

Previously, a simple variable was allowed, but now these are also allowed:

{
  schema: baseRule.meta.schema
}
{
  schema: getSchema()
}

Fixes #273.

@bmish bmish added the bug label Aug 3, 2022
'MemberExpression',
'ObjectExpression',
].includes(value.type)
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

just wondering we can explicitly say what we want to check - as more expressions could be added in future es.

e.g some new added expressions:

  • ChainExpression
  • LogicalAssignmentExpression

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I'm worried about this too. I think I should update this to instead only check a few common invalid types like Literal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Switched to only checking for literals / null / undefined to be safe.

@bmish bmish force-pushed the require-meta-schema-types branch from f63c013 to 664128d Compare August 3, 2022 13:50
@aladdin-add aladdin-add merged commit 5bf0648 into eslint-community:main Aug 4, 2022
bmish added a commit to bmish/eslint-plugin-eslint-plugin that referenced this pull request Aug 4, 2022
* main:
  fix: clarify report messages for no-missing-placeholders and no-unused-placeholders (eslint-community#278)
  fix: allow additional schema types in require-meta-schema (eslint-community#277)
bmish added a commit to bmish/eslint-plugin-eslint-plugin that referenced this pull request Aug 4, 2022
* main:
  fix: reporting location in no-missing-placeholders (eslint-community#280)
  fix: clarify report messages for no-missing-placeholders and no-unused-placeholders (eslint-community#278)
  fix: allow additional schema types in require-meta-schema (eslint-community#277)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

require-meta-schema should allow variable schema
2 participants