Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

U - Write a linter ingredient handler for class and namespace members #348

Closed
wbamberg opened this issue Mar 9, 2020 · 3 comments · Fixed by #374
Closed

U - Write a linter ingredient handler for class and namespace members #348

wbamberg opened this issue Mar 9, 2020 · 3 comments · Fixed by #374
Assignees

Comments

@wbamberg
Copy link

wbamberg commented Mar 9, 2020

The linter should validate the following ingredients:

  • data.class_properties
  • data.static_methods
  • data.static_properties
  • data.instance_methods
  • data.instance_properties

I think it should be practical to do these all together, since they are very similar.

Acceptance criteria

The linter checks that 'javascript-class' and 'javascript-namespace' pages contain the correct structures for these ingredients, according to the specification agreed in mdn/sprints#3075.

@wbamberg wbamberg self-assigned this Mar 9, 2020
@chinikes chinikes added this to the Charlie -Delta (Q2 2020) milestone Mar 10, 2020
@wbamberg
Copy link
Author

wbamberg commented Mar 17, 2020

I've been thinking a bit about this today and it raises a question. So far the linter only lints mandatory ingredients, so the ingredient must (1) exist and (2) be well-formed to pass, and there isn't really a separation between these questions.

But for optional ingredients: they don't have to exist, but if they do, they must be well-formed. So the linter has to ask, first, does this page try to include static methods (say) or an interactive example? If it doesn't, move on, but if it does, check it's valid.

A question here is: is it likely that a given ingredient will be mandatory in one recipe but optional in another? If the answer is no (which I think it is) we could push this problem into the ingredient handlers. So, say, the data.static_methods handler could have some heuristic to tell it whether this page seems to be trying to include this ingredient (e.g. does it contain the "Static methods" H2). If it doesn't, move on, otherwise validate (check the contents of the H2).

Then requireRecipeIngredientsPlugin could pass both mandatory and optional ingredients into the handlers.

It might still be worth logging missing optional ingredients, to help us catch false negatives.

Thoughts @ddbeck , @Elchi3 ?

@Elchi3
Copy link
Member

Elchi3 commented Mar 17, 2020

A question here is: is it likely that a given ingredient will be mandatory in one recipe but optional in another? If the answer is no (which I think it is) we could push this problem into the ingredient handlers.

I also believe the answer is no. It looks like we have prose.description? and prose.description right now, but I think this is a bug. It should probably be optional everywhere.

So, say, the data.static_methods handler could have some heuristic to tell it whether this page seems to be trying to include this ingredient (e.g. does it contain the "Static methods" H2). If it doesn't, move on, otherwise validate (check the contents of the H2).

I think this makes sense.

@ddbeck
Copy link
Contributor

ddbeck commented Mar 17, 2020

Yeah, that sounds reasonable to me. If we wanted to support optional and required ingredients with the same handler, we could have the plugin pass an argument to the handler.

@wbamberg wbamberg changed the title Lint class methods and properties Write a linter ingredient handler for class and namespace members Apr 7, 2020
@wbamberg wbamberg changed the title Write a linter ingredient handler for class and namespace members U - Write a linter ingredient handler for class and namespace members Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants