-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Conversation
f1a4d0f
to
45b51cb
Compare
|
||
const name = "no-unused-vars"; | ||
|
||
const meta = { |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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>
"
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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... 😂
There was a problem hiding this comment.
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>
🎈
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
* ``` | ||
* The selector does not match: | ||
* ``` html | ||
* <section><div><ul class="algorithm"></ul></div></section> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
Based on feedback from speced/bikeshed#655 (comment)
Wiki: https://github.com/w3c/respec/wiki/no-unused-vars