Rule proposal: displayName matches filename
See original GitHub issueAs often happens in code copy-pasting, some component invariably has a displayName
copied from another file.
It’d be fantastic to have a rule that requires the component name match the filename.
Positive tests:
Foo.js
:React.createClass({ displayName:"Foo", ... })
Foo.jsx
:React.createClass({ displayName:"Foo", ... })
Foo.es
:React.createClass({ displayName:"Foo", ... })
FooComponent.jsx
:React.createClass({ displayName:"FooComponent", ... })
Foo.js
:React.createClass({ ... }) // no displayName specified — validated by separate rule
Negative tests:
FooComponent.js
:React.createClass({ displayName:"Foo", ... })
Bar.js
:React.createClass({ displayName:"Foo", ... })
Bar.js
:React.createClass({ displayName:"", ... })
Issue Analytics
- State:
- Created 8 years ago
- Reactions:9
- Comments:19 (12 by maintainers)
Top Results From Across the Web
Rule proposal: displayName matches filename #157 - GitHub
It'd be fantastic to have a rule that requires the component name match the filename. Positive tests: Foo.js : React.createClass({ displayName:" ...
Read more >Why does a saved attachment's file name include the name of ...
The method will search the attachment display name for a string match anywhere in the name, and assign it an ID accordingly. It...
Read more >Windows Defender Firewall with Advanced Security ...
You can change the rule to match a different remote IP address of a Web ... –DisplayName “ah:sha1+esp:sha1-des3” -Proposal $AHandESPQM ...
Read more >Naming Conventions · Styleguide JavaScript
Incorrect code for this rule: function s() { // ... } ... Filename Export Matching. A base filename should exactly match the name...
Read more >How To: Search For Multiple Filenames At Once? - Capture One
Advanced Search with "Match Any of the following rules", and then each rule identifies one filename. E.G. "Display Name equals 20180823_SHOT_01_0036".
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The same naming convention should apply to an SFC as to a class component.
For the old createClass pattern, yes, but that’s not something that’s reasonable for this lint rule to know about.