Git Product home page Git Product logo

Comments (6)

dimsuz avatar dimsuz commented on September 14, 2024 2

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.

dimsuz avatar dimsuz commented on September 14, 2024 1

Hah, nice! No need then, it's on my TODO list also, will do soon.

from detekt-rules-compose.

dimsuz avatar dimsuz commented on September 14, 2024 1

I have actually made two new rules:

  • ModifierDefaultValue checks that default value (if present) is nothing other than Modifier, having a complex expressions there can lead to issues as I described in the comment above
  • MissingModifierDefaultValue 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.

dimsuz avatar dimsuz commented on September 14, 2024

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.

BraisGabin avatar BraisGabin commented on September 14, 2024

😂 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.

BraisGabin avatar BraisGabin commented on September 14, 2024

Sounds good!

from detekt-rules-compose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.