Closed jamesmortensen closed 1 year ago
Can you provide a snippet of the jsx that these warnings are appearing on?
To move forward, I configured the react/no-unknown-property rule in .eslintrc.json as a warning:
"react/no-unknown-property": "warn"
I can build, but this seems like a temporary patch rather than a full resolution. I believe the behavior should be the same regardless of platform. Hope this information helps. If you need anything else, please let me know!
@jamesmortensen see https://github.com/jsx-eslint/eslint-plugin-react/issues/3517#issuecomment-1376673939
(either way, building should never be gated by linting - linting is part of tests, which is an entirely distinct thing from build)
Hi @ljharb please let me know if this is what you are looking for:
src/components/mainContainer/DateAndTime/Slots.js Line 164:15: Unknown property 'staffkey' found react/no-unknown-property Line 165:15: Unknown property 'sessionkey' found react/no-unknown-property
return slots && slots.length > 0 ? (
<>
<h4>{`${window.lang.book_on} ${dateTitle}`}</h4>
<ul>
{slots.map((slot) => (
<li
id={slot.id}
data-testid={slot.id ? slot.id.toString() : ''}
key={slot.id}
staffkey={slot.staffKey}
sessionkey={slot.sessionKey}
onClick={handleSlotSelect}
>
{slot.value}
</li>
))}
</ul>
</>
...building should never be gated by linting - linting is part of tests, which is an entirely distinct thing from build)
@ljharb I guess it depends on the type of linting being done. I created a linting plugin for WebdriverIO that looks for unresolved imports because require('../modulea')
and require('../moduleA')
will work great on Windows/macOS, but on Linux filesystems, Linux will see it as two completely distinct paths. So instead of waiting to discover the issues in the tests on the CI server, maybe even 10 minutes into the tests, we discover it immediately on the local machine before the tests even execute. It saves a ton of time and avoids confusion.
Of course, that was for WebdriverIO tests, not a React App. I'm not familiar enough with React to have strong opinions on mixing linting and building together.
Hope the jsx snippet is helpful. Please let me know if you need anything else!
Yes, thanks. So, that's a nonstandard html attribute - staffkey
and sessionkey
, for example, are invalid there. you'd need to prefix it with data-
to be able to use a custom attribute. Unfortunately it was a bug to allow these in past versions, that has now been fixed.
Alternatively, you can configure the eslint rule to ignore the attribute, but i'd suggest avoiding nonstandard attribute names if possible.
@ljharb Ah, makes sense about needing the data-*. Thank you. But I wonder why it only comes up as an issue on Linux?
That is very strange indeed. The only differences between platforms should be based on file paths and/or case sensitivity. Are you sure node_modules
is the same on both machines?
The macOS node_modules won't be compatible with Linux if they contain any platform-specific binaries, so I only copied the source code (including package.json) to the Linux instance and then did an npm install
on both after clearing the node_modules folder on the Mac. This ensures that the versions of all of the modules pulled on the Mac is the same as on Linux.
I did a diff of the eslint-plugin-react module on Linux with the one on macOS. They're both identical. Identical versions, identical anything...
It sounds like the long-term answer is for us to use valid attribute/property names, so I'm happy for it to be one of those "unsolved mysteries" for now. Thanks again for the help!
Certainly! I remain very confused why the linting would differ here, assuming eslint is actually linting the files in question.
Either way, I think that the primary issue here is indeed the invalid attribute names, so I'll close.
Is there an existing issue for this?
Description Overview
I observed on GitHub Actions, the build process would fail due to react/no-unknown-property errors, even if CI is explicitly set to failse. However, the same code on the local machine (macOS M1 v13.0.1) would build with warnings (and the warnings were related to other issues, not the no-unknown-property errors).
In order to debug the issue further, I booted up an Ubuntu 22.04 instance and ran the build process with the same code and same Node version, and I see the same result as on GitHub Actions. Thus, I've ruled out the issue being related to the CI environment variable or something specific to GitHub Actions. It seems as if the rules are applied differently on Linux vs macOS.
The error is generated by just running your standard scripts/build.js script:
Or variations of the above command, like:
scripts/build.js:
Error Output:
Keep in mind that the error only happens on Linux (Ubuntu 22.04). On macOS, it "compiles with warnings".
Do we know what's different about the Linux environment that's causing this to fail? Thank you!
Expected Behavior
eslint-plugin-react version
v7.31.11
eslint version
7.32.0
node version
v14.21.1