Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lue-bird/elm-review-predefine
move expression parts that don't rely on arguments to module scope
https://github.com/lue-bird/elm-review-predefine
elm elm-review false-positive performance
Last synced: 6 days ago
JSON representation
move expression parts that don't rely on arguments to module scope
- Host: GitHub
- URL: https://github.com/lue-bird/elm-review-predefine
- Owner: lue-bird
- Created: 2024-07-28T04:08:46.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-11T10:48:27.000Z (3 months ago)
- Last Synced: 2025-01-12T11:52:19.149Z (15 days ago)
- Topics: elm, elm-review, false-positive, performance
- Language: Elm
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# elm-review-predefine
The [`elm-review`](https://package.elm-lang.org/packages/jfmengels/elm-review/latest/) rule `Review.Predefine` which reports values that are constructed lazily but could be defined at the module level to save calculations and allocations.
```bash
elm-review --template lue-bird/elm-review-predefine/preview
```**This will not be released** because it inherently has lots of false positives, makes your code ugly and is rarely necessary in the first place. However, feel free to use the template for a quick manual review or adapt with more restrictions for when it reports.
Keep in mind:- if you use a function with arguments _exclusively in fully applied style_ and not lazily, pre-defining has no benefit. This rule makes no effort to check for cases like that. Ignore it in that case!
- certain values like simple calculations _might be fine_ to construct again and again on the fly. Ignore it in that case!
- the rule does not detect or suggest moving let value/function declarations. For that, use [`NoPrematureLetComputation`](https://dark.elm.dmy.fr/packages/jfmengels/elm-review-common/latest/NoPrematureLetComputation)## add to your project
Copy `src/Review/Predefine.elm` over to your `review/src/` and add```elm
module ReviewConfig exposing (config)import Review.Predefine
import Review.Rule exposing (Rule)config : List Rule
config =
[ Review.Predefine.rule
]
```