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
[New] add no-namespace
rule
#2640
Conversation
Are there any concerns about this Pull Request? |
#1334 can't truly be fixed except by modifying jsx-pascal-case somehow. I'll take a look at this PR tho. |
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 make sure we have test cases that also run in babel-eslint, and also in the typescript parser.
docs/rules/jsx-no-namespace.md
Outdated
|
||
## When not to use | ||
|
||
If you are not using JSX. |
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.
this seems like it shouldn't be jsx-specific, since it can still apply to React.createElement
when called with a string literal.
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 am willing to make the linting rule work with React.createElement
.
It wouldn't be called jsx-no-namespace
anymore though. Do you have a suggestion for a name?
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 just no-namespace
would work?
index.js
Outdated
@@ -126,6 +127,7 @@ module.exports = { | |||
'react/jsx-key': 2, | |||
'react/jsx-no-comment-textnodes': 2, | |||
'react/jsx-no-duplicate-props': 2, | |||
'react/jsx-no-namespace': 2, |
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.
adding anything to the recommended config is a breaking change.
'react/jsx-no-namespace': 2, |
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'll remove it then.
@yacinehmito are you interested in landing this PR? it seems almost ready, pending the review comments. |
Hello @ljharb. My apologies, I am not using GitHub much anymore. Other people are free to build upon this work. |
I’ll try to finish it myself then. |
…agmaImport` utils This should improve detection in the following rules: - `button-has-type` - `forbid-elements` - `no-adjacent-inline-elements` - `no-children-prop` - `style-prop-object`
Co-authored-by: Yacine Hmito <yacine.hmito@gmail.com> Co-authored-by: Jordan Harband <ljharb@gmail.com>
fbd325a
to
1e4dd5b
Compare
Codecov Report
@@ Coverage Diff @@
## master #2640 +/- ##
=======================================
Coverage 97.43% 97.43%
=======================================
Files 111 114 +3
Lines 7522 7536 +14
Branches 2763 2750 -13
=======================================
+ Hits 7329 7343 +14
Misses 193 193
Continue to review full report at Codecov.
|
1e4dd5b
to
53a0d84
Compare
Following the discussion in #1334 (comment), I am submitting the introduction of the rule
jsx-no-namespace
.Summary: JSX namespaces are not supported by React. When a JSX namespace is used in a JSX component, the rules
jsx-no-undef
orjsx-pascal-case
raise an error, which is unfortunate because none of them explain what is happening.This rule is not of critical importance because the error is flagged at runtime by React. Still, I believe it to be a valuable inclusion.