Comments (8)
@adidahiya Could you please recommend a way for the 2 cases you gave above. I got this rules triggered a lot and I'm not sure how to improve them. Thanks.
from tslint-react.
@MiguelMadero eh, that wouldn't really solve my use case because so much of JS syntax is a valid expression. My primary motivation for using this rule was to ban multiline ternarys and function calls (primarily .map
, since it's used to generate lists)
// bad
<div className={
someComplicatedCondition
? "positive-case"
: "positive-case"}
otherProp={true}
/>
// bad
<div>
{this.props.foo.map((f) => {
return <span>{f}</span>;
})}
</div>
I could imagine another option here for stylistic preference, however, ignore-conditional-expressions
, to allow multiline ternarys like in my first example ^
from tslint-react.
How lenient do you think it should be? Should we just allow object literals, or do you think this should allow things like
popoverProps={this.computePopoverProps({
popoverClassName: "docs-dropdown-ramen-popover",
})}
Also, this rule currently doesn't care about spread attributes, eg
<Dropdown {...{
items: mocks.groups(),
placeholder: "Ramen joint",
}} />
but that's probably a separate issue.
from tslint-react.
@adidahiya @markwongsk this is hanging for quite some time, can we push for this change?
I really need this configurability and I think that disable for object literals is enough for a start.
Checking tslint conventions suggested name might be: "ignore-object-literal"
from tslint-react.
@markwongsk I guess we could break down the use cases into "be lenient on multiline functions / lambdas" and "be lenient on object or array literals". so this rule could have two new options: ignore-functions
and ignore-literals
@piotrwitek open to PRs, as always :)
from tslint-react.
Would it be a simpler distinction between JS statements and expressions? It seems like multline expressions (object literals, ternary, function calls, etc) make more sense than multiple statements.
from tslint-react.
Is there any plan or update about this topic?
from tslint-react.
Closing due to deprecation, see #210
from tslint-react.
Related Issues (20)
- React must be in scope in tsx file HOT 4
- Feature request: pair ReactDOM.unmountComponentAtNode with ReactDOM.render calls. HOT 1
- Why jsx-alignment do not includes automatic code fix? HOT 1
- Rule suggestion: no unneeded <React.Fragment> or <> HOT 1
- jsx-wrap-multiline does not enforce end-paren if begin-paren is valid HOT 1
- jsx-no-bind bug? HOT 5
- Pull in rules from tslint-microsoft-contrib HOT 3
- Cannot set "jsx-boolean-value" to 'never' ? HOT 1
- jsx-wrap-multiline does not check nested JSX HOT 2
- New rule suggestion: jsx-singleline-no-parens HOT 1
- jsx-no-multiline-js: allow multiline block comments HOT 2
- Migrate to eslint-plugin-react HOT 2
- react-ssr-friendly HOT 3
- Roadmap: tslint-react -> eslint-plugin-react HOT 1
- jsx-self-close rule doesn't actually support autofix HOT 1
- jsx-wrap-multiline issue with trailing-comma HOT 2
- Automatically ignore null keyword usage within getDerivedStateFromProps method HOT 3
- Allow/disallow curly braces for string literal attributes (enforce double/single quotes only) HOT 1
- Missing LICENSE file in npm package HOT 1
- jsx-curly-spacing accepted formats HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tslint-react.