From b59c9d2fc78d652c4fa5a2adf47db7502f6fcdcd Mon Sep 17 00:00:00 2001 From: Guillaume Cauchon Date: Thu, 9 Feb 2023 23:51:54 -0500 Subject: [PATCH] Format & Linting --- .credo.exs | 8 +++++--- assets/js/app.js | 13 ++++++++----- assets/tailwind.config.js | 2 ++ lib/elixir_boilerplate_web/components/core.ex | 18 ++++++++++-------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.credo.exs b/.credo.exs index 86bd65db..7f9992be 100644 --- a/.credo.exs +++ b/.credo.exs @@ -16,6 +16,7 @@ common_checks = [ {Credo.Check.Readability.ModuleNames}, {Credo.Check.Readability.MultiAlias}, {Credo.Check.Readability.ParenthesesInCondition}, + {Credo.Check.Readability.ParenthesesOnZeroArityDefs, false}, {Credo.Check.Readability.PredicateFunctionNames}, {Credo.Check.Readability.SinglePipe}, {Credo.Check.Readability.StrictModuleLayout}, @@ -47,9 +48,10 @@ common_checks = [ {Credo.Check.Warning.UnusedTupleOperation}, {Credo.Check.Warning.OperationWithConstantResult}, {CredoEnvvar.Check.Warning.EnvironmentVariablesAtCompileTime}, - {CredoNaming.Check.Warning.AvoidSpecificTermsInModuleNames, terms: ["Manager", "Fetcher", "Builder", "Persister", "Serializer", ~r/^Helpers?$/i, ~r/^Utils?$/i]}, - {CredoNaming.Check.Consistency.ModuleFilename, - excluded_paths: ["config", "mix.exs", "priv", "test/support"], acronyms: [{"ElixirBoilerplateGraphQL", "elixir_boilerplate_graphql"}, {"GraphQL", "graphql"}]} + # , + {CredoNaming.Check.Warning.AvoidSpecificTermsInModuleNames, terms: ["Manager", "Fetcher", "Builder", "Persister", "Serializer", ~r/^Helpers?$/i, ~r/^Utils?$/i]} + # {CredoNaming.Check.Consistency.ModuleFilename, + # excluded_paths: ["config", "mix.exs", "priv", "test/support"], acronyms: [{"ElixirBoilerplateGraphQL", "elixir_boilerplate_graphql"}, {"GraphQL", "graphql"}]} ] %{ diff --git a/assets/js/app.js b/assets/js/app.js index 9667999d..50b37350 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -4,20 +4,23 @@ import 'phoenix_html'; // Show progress bar on live navigation and form submits import topbar from 'topbar'; +const DELAY_IN_MILISECONDS = 200; + topbar.config({barColors: {0: '#29d'}, shadowColor: 'rgba(0, 0, 0, .3)'}); -window.addEventListener('phx:page-loading-start', (info) => - topbar.delayedShow(200) +window.addEventListener('phx:page-loading-start', (_info) => + topbar.delayedShow(DELAY_IN_MILISECONDS) ); -window.addEventListener('phx:page-loading-stop', (info) => topbar.hide()); +window.addEventListener('phx:page-loading-stop', (_info) => topbar.hide()); // Establish Phoenix Socket and LiveView configuration. import {Socket} from 'phoenix'; import {LiveSocket} from 'phoenix_live_view'; -let csrfToken = document +const csrfToken = document .querySelector("meta[name='csrf-token']") .getAttribute('content'); -let liveSocket = new LiveSocket('/live', Socket, { +const liveSocket = new LiveSocket('/live', Socket, { + // eslint-disable-next-line camelcase params: {_csrf_token: csrfToken} }); diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index e9a25e2f..4218d815 100644 --- a/assets/tailwind.config.js +++ b/assets/tailwind.config.js @@ -1,3 +1,5 @@ +/* eslint-env node */ + // See the Tailwind configuration guide for advanced usage // https://tailwindcss.com/docs/configuration diff --git a/lib/elixir_boilerplate_web/components/core.ex b/lib/elixir_boilerplate_web/components/core.ex index a33e4c24..00cf4149 100644 --- a/lib/elixir_boilerplate_web/components/core.ex +++ b/lib/elixir_boilerplate_web/components/core.ex @@ -11,9 +11,11 @@ defmodule ElixirBoilerplateWeb.Components.Core do """ use Phoenix.Component - alias Phoenix.LiveView.JS import ElixirBoilerplate.Gettext + alias Phoenix.HTML.Form + alias Phoenix.LiveView.JS + @doc """ Renders a modal. @@ -207,7 +209,7 @@ defmodule ElixirBoilerplateWeb.Components.Core do @doc """ Renders an input with label and error messages. - A `%Phoenix.HTML.Form{}` and field name may be passed to the input + A `%Form{}` and field name may be passed to the input to build input names and error messages, or all the attributes and errors may be passed explicitly. @@ -226,11 +228,11 @@ defmodule ElixirBoilerplateWeb.Components.Core do range radio search select tel text textarea time url week) attr :value, :any - attr :field, :any, doc: "a %Phoenix.HTML.Form{}/field name tuple, for example: {f, :email}" + attr :field, :any, doc: "a %Form{}/field name tuple, for example: {f, :email}" attr :errors, :list attr :checked, :boolean, doc: "the checked flag for checkbox inputs" attr :prompt, :string, default: nil, doc: "the prompt for select inputs" - attr :options, :list, doc: "the options to pass to Phoenix.HTML.Form.options_for_select/2" + attr :options, :list, doc: "the options to pass to Form.options_for_select/2" attr :multiple, :boolean, default: false, doc: "the multiple flag for select inputs" attr :rest, :global, include: ~w(autocomplete cols disabled form max maxlength min minlength pattern placeholder readonly required rows size step) @@ -240,11 +242,11 @@ defmodule ElixirBoilerplateWeb.Components.Core do assigns |> assign(field: nil) |> assign_new(:name, fn -> - name = Phoenix.HTML.Form.input_name(f, field) + name = Form.input_name(f, field) if assigns.multiple, do: name <> "[]", else: name end) - |> assign_new(:id, fn -> Phoenix.HTML.Form.input_id(f, field) end) - |> assign_new(:value, fn -> Phoenix.HTML.Form.input_value(f, field) end) + |> assign_new(:id, fn -> Form.input_id(f, field) end) + |> assign_new(:value, fn -> Form.input_value(f, field) end) |> assign_new(:errors, fn -> translate_errors(f.errors || [], field) end) |> input() end @@ -273,7 +275,7 @@ defmodule ElixirBoilerplateWeb.Components.Core do {@rest} > - <%= Phoenix.HTML.Form.options_for_select(@options, @value) %> + <%= Form.options_for_select(@options, @value) %> <.error :for={msg <- @errors}><%= msg %>