Comments (6)
I found a thread in compose slack in which Google's Leland Richardson said that the convention is to have the default value be simply Modifier
, not Modifier.fillMaxWidth()
or something else, as this could lead to unwanted problems, as that thread indicates.
This rule can check this also, and report error a) in case there's no default value b) in case default value is something more than Modifier
from detekt-rules-compose.
Hah, nice! No need then, it's on my TODO list also, will do soon.
from detekt-rules-compose.
I have actually made two new rules:
ModifierDefaultValue
checks that default value (if present) is nothing other thanModifier
, having a complex expressions there can lead to issues as I described in the comment aboveMissingModifierDefaultValue
which reports an error if modifier has no default value. Lint rules bundled with compose do not enforce modifier having a default value, so I thought that some folks might want to disable this rule.
from detekt-rules-compose.
I have also thought about adding a separate rule which would enforce putting optional parameters after required parameters, (+not allowing to intersperse them). Looks like this makes sense specifically for composable functions (not generally) and follows Compose internal style: so that you can write e.g. Text("Hello", TextStyle.H2)
. This would require named args if at least one optional parameter is present before required ones. Not yet sure how useful such rule would be, thought about trying it on our private codebases first.
from detekt-rules-compose.
😂 I had on my TODO list "Open an issue to enforce required parameters first". I just crosslined it (Unless you want the issue to track this kind of things)
from detekt-rules-compose.
Sounds good!
from detekt-rules-compose.
Related Issues (20)
- Add ignoreOverridden support for MissingModifierDefaultValue rule HOT 6
- ComposableParametersOrdering: Ignore trailing lambda parameters HOT 4
- False positive on `UnnecessaryEventHandlerParameter` HOT 4
- `UnnecessaryEventHandlerParameter` raises an exception HOT 1
- False positive on `ModifierParameterPosition` and `ComposableParametersOrdering` HOT 6
- [Question] No Compose in the report HOT 1
- Add "UnusedModifierParameter" rule HOT 5
- Not detekt on CompositionLocalProvider due to Modifier wrong level HOT 1
- Fat jar HOT 4
- False positive in ModifierHeightWithText rule
- Private Composable Previews and UnusedPrivateMember conflict HOT 3
- False positive on ReusedModifierInstance with theme as direct child HOT 1
- `TopLevelComposableFunctions` and `inteface`s HOT 2
- False positive on `ReusedModifierInstance` when shadowing modifier HOT 1
- False positive for "ConditionCouldBeLifted": lambda with parameter
- Outdated wiki? HOT 2
- False positive for `UnnecessaryEventHandlerParameter`? HOT 4
- ModifierHeightWithText should not apply when Modifier.height(Intrinsic.Min) HOT 1
- False positive on ComposableFunctionName when using single expression functions HOT 3
- ComposableParametersOrdering should not consider one last function parameter HOT 3
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 detekt-rules-compose.