Can't use Pascal case when declaring a stateless functional component (SFC)
See original GitHub issueI’m currently having issues declaring SFCs when using the following tslint configuration:
{
"extends": ["tslint-config-airbnb", "tslint-react", "tslint-config-prettier"]
}
and here is a sample component
import * as React from 'react';
const DummyComponent = () => <div>Hello World!</div>;
export default DummyComponent;
which results in the error
[tslint] variable name must be in lowerCamelCase or UPPER_CASE (variable-name)
const DummyComponent: () => JSX.Element
I know that it is the tslint-config-airbnb
causing the issue, but I would have thought that tslint-react would have a rule for Pascal cased SFCs.
I think that this rule is missing. I’d be happy to throw up a PR if that’s the case. I just need to read up a bit on creating rules.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:67
- Comments:14 (1 by maintainers)
Top Results From Across the Web
TSLint and React stateless component naming (PascalCase ...
I found a compromise, using a function declaration instead of a variable declaration for my component: enter image description here.
Read more >dsny_dashboard - npm
SFC <P>. Type representing stateless functional component ... Reference Naming: Use PascalCase for React components and camelCase for their ...
Read more >React Stateless Functional Component with TypeScript
Use React Stateless Functional Component when you don't need to manage states in a component. TypeScript supports SFC type that is the alias ......
Read more >Building React Stateless Functional Components ... - Pluralsight
Stateless functional components are an awesome way to decouple complex architecture from the design of a component's output.
Read more >Stateless component in React and "Props is defined but never ...
Coding example for the question Stateless component in React and "Props is defined but never used" ESLint error-Reactjs.
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 Free
Top 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
You can do this:
For now, I’m doing this, but it’s just a hack, as it allows people to write all vars as Pascal case.