Giter Club home page Giter Club logo

no-long-import-lines's Introduction

NoLongImportLines

.github/workflows/build.yml

A rule for elm-review that discourages keeping very long one-line import statements.

Some Elm tools will change multi-line import statements back to a single line when modifying the exposing () section.

Usage

After adding elm-review to your project, import this rule from your ReviewConfig.elm file and add it to the config. E.g.:

import NoLongImportLines
import Review.Rule exposing (Rule)

config : List Rule
config =
    [ NoLongImportLines.rule ]

Roadmap

  • Save users from users having to manually break up the line, by adding a fix

no-long-import-lines's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar r-k-b avatar sparksp avatar

Watchers

 avatar  avatar

no-long-import-lines's Issues

Should the fix preview look more like what elm-format would produce?

Currently, the easy fix to make is inserting a newline before the closing parenthesis, and elm-format will do the heavy lifting of breaking the items within to individual lines. But, the preview doesn't suggest that:

image

Should the preview look more like what elm-format would produce?

These wide lines will typically become many long lines, will that be presentable in the preview?

(The example becomes 23 lines high)

A mockup:

-- ELM-REVIEW ERROR ----------------------------------- app/DefaultData.elm:24:1

NoLongImportLines: Do not keep `import` lines longer than 120 characters.

23| import Set
24| import Types exposing (Action, ActionOutcome(..), Agent, Consideration, ConsiderationInput(..), Fire, FireExtinguisher, Food, GeneratorType(..), Growable, GrowableState(..), Hitpoints(..), Holding(..), InputFunction(..), Portable(..), Range(..), ReferenceToPortable(..), Signal(..), Species(..), YDownCoords)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
25| import Vector2d

Even though `elm-format` keeps the items sorted, having very long lines like
this invites merge conflicts, and reduces readability.

I think I can fix this. Here is my proposal:

 23| import Set
 24| import Types exposing (Action, ActionOutcome(..), Agent, Consideration, ConsiderationInput(..), Fire, FireExtinguisher, Food, GeneratorType(..), Growable, GrowableState(..), Hitpoints(..), Holding(..), InputFunction(..), Portable(..), Range(..), ReferenceToPortable(..), Signal(..), Species(..), YDownCoords)
 25| import Types
 26|     exposing
 27|         ( Action
 28|         , ActionOutcome(..)
 29|         , Agent
 30|         , Consideration
 31|         , ConsiderationInput(..)
 32|         , Fire
 33|         , FireExtinguisher
 34|         , Food
 35|         , GeneratorType(..)
 36|         , Growable
 37|         , GrowableState(..)
 38|         , Hitpoints(..)
 39|         , Holding(..)
 40|         , InputFunction(..)
 41|         , Portable(..)
 42|         , Range(..)
 43|         , ReferenceToPortable(..)
 44|         , Signal(..)
 45|         , Species(..)
 46|         , YDownCoords
 47|         )
 48| import Vector2d

? Do you wish to apply this fix? › (Y/n)

Do I need to dive into the nodes and apply that whitespace in the fix, or can I leverage elm-format for the preview somehow?

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.