Tiny Robots Credo Checks

CIHex versionHex downloadsLicense

Highly opinionatedCredo checks used by Tiny Robots. They encode the Elixir / Phoenix / LiveView conventions we rely on across our apps.

These checks are opinionated by design — they enforce the Tiny Robots house style and may not be suitable (or desired) for contribution upstream to mainline Credo. They're published here so our projects can share them, but anyone sharing our conventions is welcome to use them.

Available checks

See the individual modules for full descriptions and examples.

Design

Readability

Refactor

Warning

Installation and configuration

  1. Add rbtz_credo_checks to your mix.exs dependencies:

    def deps do
      [
        {:rbtz_credo_checks, "~> 0.1", only: [:dev, :test], runtime: false}
      ]
    end
  2. Run mix deps.get.

  3. Add the desired checks to your .credo.exs:

    %{
      configs: [
        %{
          checks: %{
            enabled: [
              {Rbtz.CredoChecks.Design.BareScriptInHeex, []},
              {Rbtz.CredoChecks.Design.CnInClassList, []},
              {Rbtz.CredoChecks.Design.CustomAliasInRouterScope, []},
              {Rbtz.CredoChecks.Design.PreferLogsterInLib, []},
              {Rbtz.CredoChecks.Design.RawHtmlElementsInHeex, []},
              {Rbtz.CredoChecks.Design.RawSvgInHeex, []},
              {Rbtz.CredoChecks.Readability.AtomHttpStatusCodes, []},
              {Rbtz.CredoChecks.Readability.AwkwardPipe, []},
              {Rbtz.CredoChecks.Readability.ClassAttrFormatting, []},
              {Rbtz.CredoChecks.Readability.LiveViewCallbackOrder, []},
              {Rbtz.CredoChecks.Readability.PreferBooleanDataAttrShorthand, []},
              {Rbtz.CredoChecks.Readability.PreferCapture, []},
              {Rbtz.CredoChecks.Readability.PreferSigilSForEscapedQuotes, []},
              {Rbtz.CredoChecks.Readability.PreferToTimeout, []},
              {Rbtz.CredoChecks.Readability.RedundantClassAttrWrapping, []},
              {Rbtz.CredoChecks.Readability.ShorthandDefMustBeCompact, []},
              {Rbtz.CredoChecks.Readability.SnakeCaseVariableNumbering, []},
              {Rbtz.CredoChecks.Readability.TopLevelAliasImportRequire, []},
              {Rbtz.CredoChecks.Refactor.PreferEctoMigrationHelper, []},
              {Rbtz.CredoChecks.Refactor.PreferForAttrOverForBlock, []},
              {Rbtz.CredoChecks.Refactor.PreferTextColumns, []},
              {Rbtz.CredoChecks.Refactor.PreferToFormInTemplates, []},
              {Rbtz.CredoChecks.Refactor.RawHtmlMatchInLiveViewTests, []},
              {Rbtz.CredoChecks.Refactor.RedundantThen, []},
              {Rbtz.CredoChecks.Warning.AssertNonEmptyBeforeIterate, []},
              {Rbtz.CredoChecks.Warning.BooleanDataAttrCoalescesNil, []},
              {Rbtz.CredoChecks.Warning.DisableMigrationLock, []},
              {Rbtz.CredoChecks.Warning.EnumEachInHeex, []},
              {Rbtz.CredoChecks.Warning.LiveViewFormCanBeRehydrated, []},
              {Rbtz.CredoChecks.Warning.PhxClickAwayWithoutId, []},
              {Rbtz.CredoChecks.Warning.PhxHookComponentWithoutStableId, []},
              {Rbtz.CredoChecks.Warning.PhxHookWithoutId, []},
              {Rbtz.CredoChecks.Warning.PhxUpdateStreamWithoutId, []},
              {Rbtz.CredoChecks.Warning.PreferGetFieldOnChangeset, []},
              {Rbtz.CredoChecks.Warning.PushEventSocketBinding, []},
              {Rbtz.CredoChecks.Warning.ReqTestWithoutVerifyOnExit, []},
              {Rbtz.CredoChecks.Warning.SetMimicGlobal, []},
              {Rbtz.CredoChecks.Warning.SortKeywordValidateResult, []},
              {Rbtz.CredoChecks.Warning.StringInterpolationInClassAttr, []},
              {Rbtz.CredoChecks.Warning.UnnamedOtpProcess, []}
            ]
          }
        }
      ]
    }

License

MIT. See LICENSE.