Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upPreact `'h' is defined but never used. (no-unused-vars)` #1231
Comments
This comment has been minimized.
This comment has been minimized.
|
I think that there is a special comment that you can use to instruct eslint of the pragma you are using |
This comment has been minimized.
This comment has been minimized.
stevenzeck
commented
Nov 26, 2018
|
I'm receiving somewhat similar errors with probot work using standard and typescript-eslint-parser. I'll import classes, such as
|
This comment has been minimized.
This comment has been minimized.
|
@LinusU It doesn't seem to have any effect in /* @jsx h */
import { h, render } from 'preact' // 'h' is defined but never usedBesides, it also requires to be added to every file. It's surely a bit more succinct than import { h, render } from 'preact' // eslint-disable-line no-unused-varsbut still, annoying. Tbh, I'm sure most people can live with that, but couldn't we have a config option for this? |
This comment has been minimized.
This comment has been minimized.
|
@alex996 did you try having some JSX in the file as well? Otherwise, I think that it will, correctly, warn for no usage... /* @jsx h */
import { h } from 'preact' // 'h' is defined but never used
module.exports = function test () {
return <div>Test</div>
}edit: just tried it, doesn't work: |
This comment has been minimized.
This comment has been minimized.
|
@LinusU Same, it doesn't work with JSX either. /* @jsx h */
import { h, render } from 'preact' // 'h' is defined but never used
export const Component = props => <div /> |
This comment has been minimized.
This comment has been minimized.
JerryGreen
commented
Dec 28, 2018
|
It definitely needs a setting for that. I think this should ideally be an environment config's part, like this:
But these environments are part of eslint, not standard. And, unfortunately, looks like it's not possible to add custom environments yet (I haven't found such a documentation, also - look this and that) |
This comment has been minimized.
This comment has been minimized.
doubleswirve
commented
Jan 11, 2019
This comment has been minimized.
This comment has been minimized.
|
Ahhhhhh, that's it @doubleswirve good find |
This comment has been minimized.
This comment has been minimized.
|
Nice, the only downside is you have to copy-paste this to every component file. Instead, I ended up using |
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
Apr 12, 2019
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
stale
bot
added
the
stale
label
Apr 12, 2019
stale
bot
closed this
Apr 19, 2019
This comment has been minimized.
This comment has been minimized.
kilgarenone
commented
Jun 8, 2019
|
I add this to my eslintrc to fix it:
|

alex996 commentedNov 26, 2018
I have a Preact project that defines an
hpragma, as per the docsUnfortunately, this pragma raises
no-unused-varserror, as inAt the same time,
Reactpragma inreactis auto-magically ignored, which is correctThe only known workaround in Preact is to include
/* eslint-disable no-unused-vars */at the top of each component file, which is redundant. I tried other options, including.eslintrcwith"rules"key, but Standard ignores it by design"rules": {"no-unused-vars": [0, { "varsIgnorePattern": "^h$" }]}inpackage.json, no effect"globals": ["h"]- of course, no effect either"settings"key, suggested here, but it also seems to be ignoredIs there anything at that can be done about this? It not only affects
preact, but other libs likedekuorhyperapp. The way I see it, Standard couldhby default, just likeReactAny thoughts? Thanks
What version of standard?
^12.0.1What operating system, Node.js, and npm version?
node -v:11.2.0npm -v:6.4.1What did you expect to happen?
It should ignore the
hpragma.What actually happened?
It reports
'h' is defined but never used. (no-unused-vars)