Skip to content

feat(linter-rules/no-unused-vars): declared var must be used #2955

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

Merged
merged 13 commits into from
Jun 17, 2020

Conversation

sidvishnoi
Copy link
Member

@sidvishnoi sidvishnoi commented Jun 8, 2020

@sidvishnoi sidvishnoi force-pushed the linter/no-unused-vars branch from f1a4d0f to 45b51cb Compare June 8, 2020 18:28

const name = "no-unused-vars";

const meta = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure the message here looks like one you would get from ESLint... that is, it should be clear that a "variable X was defined but never used".

Copy link
Member Author

Choose a reason for hiding this comment

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

We won't have access to "X" in linter message, so maybe:
"Variable was defined, but never used. Add a data-ignore-unused attribute to the <var>, or consider using <em>/ <code>"

Copy link
Contributor

@marcoscaceres marcoscaceres Jun 16, 2020

Choose a reason for hiding this comment

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

"Add a data-ignore-unused attribute to the , or consider using / "

Only the "data-ignore-unused" seems like an good suggestion... the other not so much as they are working around the problem, not addressing the problem explicitly.

Copy link
Contributor

Choose a reason for hiding this comment

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

No idea what's going on with my comment's formatting above... 😂

Copy link
Member Author

Choose a reason for hiding this comment

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

Only the "data-ignore-unused" seems like an good suggestion... the other not so much as they are working around the problem, not addressing the problem explicitly.

Maybe author used <var> for its style when they meant <em> or <code> (See https://github.com/w3c/webdriver/pull/1515/files)?

No idea what's going on with my comment's formatting above... 😂

Missed backticks on <em> 🎈

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, we can't add a data-ignore-unused to the var micro-syntax.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using <var> for style is an author error, so let’s not worry about it (or encourage that).

function linterFunction(_, doc) {
const offendingElements = [];

for (const section of doc.querySelectorAll("section")) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we pick only those sections that contain algorithms?
See: https://github.com/w3c/payment-request/blob/e9515622/index.html#L280

Copy link
Contributor

Choose a reason for hiding this comment

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

I think so... we might need to test out a few specs.

@sidvishnoi sidvishnoi marked this pull request as ready for review June 17, 2020 11:25
* ```
* The selector does not match:
* ``` html
* <section><div><ul class="algorithm"></ul></div></section>
Copy link
Member Author

Choose a reason for hiding this comment

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

Should this be supported? Seems unlikely, but possible

Copy link
Contributor

Choose a reason for hiding this comment

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

Heh, commented at the same time 😂 yes, I think we should support it

* ```
* The selector does not match:
* ``` html
* <section><div><ul class="algorithm"></ul></div></section>
Copy link
Contributor

Choose a reason for hiding this comment

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

What’s the rationale for this one?

Copy link
Member Author

Choose a reason for hiding this comment

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

The selector gets complex (match section only if section contains algorithm, but not any subsection). Looking at specs, most .algorithm were in directly section, not wrapped in other elements. Might go the imperative way if selector gets too complex and we want to support it.

Copy link
Contributor

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

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

Let’s do this!

@sidvishnoi sidvishnoi merged commit be52a91 into develop Jun 17, 2020
@sidvishnoi sidvishnoi deleted the linter/no-unused-vars branch June 17, 2020 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants