diff --git a/.prettierignore b/.prettierignore index 63a774714a..2456f95334 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,3 +7,4 @@ modules result target component-spec +/app diff --git a/Makefile b/Makefile index d022e203e5..cd282740a7 100644 --- a/Makefile +++ b/Makefile @@ -312,6 +312,7 @@ lint: export TARGET := clojure lint: export CLJ_LINTER_PRINT_WARNINGS ?= false lint: ##@test Run code style checks @sh scripts/lint-re-frame-in-quo-components.sh && \ + sh scripts/lint-direct-require-component-outside-quo.sh && \ clj-kondo --config .clj-kondo/config.edn --cache false --fail-level error --lint src $(if $(filter $(CLJ_LINTER_PRINT_WARNINGS),true),,| grep -v ': warning: ') && \ ALL_CLOJURE_FILES=$(call find_all_clojure_files) && \ zprint '{:search-config? true}' -sfc $$ALL_CLOJURE_FILES && \ diff --git a/doc/component-tests-overview.md b/doc/component-tests-overview.md index 016d508778..9635dd6a90 100644 --- a/doc/component-tests-overview.md +++ b/doc/component-tests-overview.md @@ -23,7 +23,7 @@ setups and runs the test suite once. setups and runs the test suite and watches for code changes will then retrigger the test suite. ## Writing Tests -New test files will need their namespace added to either the file "src/quo2/core_spec.cljs" or "src/status_im2/core_spec.cljs. These locations may update overtime but it is dependent on the entrypoint in shadow-cljs config discussed below. +New test files will need their namespace added to either the file "src/quo/core_spec.cljs" or "src/status_im2/core_spec.cljs. These locations may update overtime but it is dependent on the entrypoint in shadow-cljs config discussed below. ### Best practices diff --git a/doc/new-guidelines.md b/doc/new-guidelines.md index c90de39a7c..b61f38eba3 100644 --- a/doc/new-guidelines.md +++ b/doc/new-guidelines.md @@ -76,7 +76,7 @@ It's important to name functional components with `f-` prefix. ### Component props and API scheme to match Figma as closely as possible -Ideally, the prop names for components (particularly in quo2 Design System) +Ideally, the prop names for components (particularly in quo Design System) should match the Figma properties as best as possible. This makes it easier for the developer using that component to configure it correctly for the screen it is being used on and avoids unnecessary overwrites and adjustments being made. @@ -134,7 +134,7 @@ For example if Figma has sizes `:small`, `:medium` and `:large` Prefer to define styles in a separate file named `style.cljs`, colocated with the source file. For a real example, see -[src/quo2/components/record_audio/record_audio/style.cljs](../src/quo2/components/record_audio/record_audio/style.cljs). +[src/quo/components/record_audio/record_audio/style.cljs](../src/quo/components/record_audio/record_audio/style.cljs). ```clojure ;; bad @@ -528,27 +528,27 @@ due to performance constraints. (:preferred-name multiaccount))) ``` -### Requiring quo2 components +### Requiring quo components -Consume `quo2` components from `quo2.core`, unless the namespace is also inside -the `quo2/` directory. +Consume `quo` components from `quo.core`, unless the namespace is also inside +the `quo/` directory. ```clojure ;; bad (ns my-namespace - (:require [quo2.components.icon :as icon])) + (:require [quo.components.icon :as icon])) (icon/icon :i/verified) ;; good (ns my-namespace - (:require [quo2.core :as quo])) + (:require [quo.core :as quo])) (quo/icon :i/verified) -;; also good because both namespaces are inside quo2/ -(ns quo2.components.tabs.account-selector - (:require [quo2.components.markdown.text :as text])) +;; also good because both namespaces are inside quo/ +(ns quo.components.tabs.account-selector + (:require [quo.components.markdown.text :as text])) ``` ### Require/import @@ -615,12 +615,12 @@ Use the appropriate keyword qualification/namespace. ```clojure ;; bad -(require '[quo2.components.icon :as icons]) +(require '[quo.components.icon :as icons]) (icons/icon :main-icons2/verified) ;; good -(require '[quo2.core :as quo2]) -(quo2/icon :i/verified) +(require '[quo.core :as quo]) +(quo/icon :i/verified) ``` ### Translations @@ -695,7 +695,7 @@ First, the bird's-eye view with some example ClojureScript files: src ├── js/ ├── mocks/ -├── quo2 +├── quo │ ├── components/ │ ├── foundations/ │ └── theme.cljs @@ -716,7 +716,7 @@ src - `src/js`: Raw Javascript files, e.g. React Native Reanimated worklets. - `src/mocks`: Plumbing configuration to be able to run tests. -- `src/quo2/`: The component library for Status Mobile. +- `src/quo/`: The component library for Status Mobile. - `src/react_native/`: Contains only low-level constructs to help React Native work in tandem with Clojure(Script). - `src/status_im2/`: Directory where we try to be as strict as possible about @@ -728,7 +728,7 @@ src of the directory tree. Just like directories named `utils`, their directory nesting level communicates their applicable limits. - `src/status_im2/common/components/`: Contains reusable components that are not - part of the design system (quo2). + part of the design system (quo). - `src/status_im2/contexts/`: Contains [bounded contexts](#glossary), like `browser/`, `messaging/`, etc. As much as possible, _bounded contexts_ should not directly require each other's namespaces. @@ -743,9 +743,9 @@ directory nesting level precisely indicates its boundaries. For example, a `contexts/user_settings/utils/datetime.cljs` file communicates that it should only be used in the `user_settings` context. -### src/quo2 +### src/quo -The `src/quo2/` directory holds all components for the new design system. As +The `src/quo/` directory holds all components for the new design system. As much as possible, its sub-directories and component names should reflect the same language used by designers. @@ -753,14 +753,14 @@ Even though the directory lives alongside the rest of the codebase, we should think of it as an external entity that abstracts away particular Status domain knowledge. -Components inside `src/quo2/` should not rely on re-frame, i.e. they should not +Components inside `src/quo/` should not rely on re-frame, i.e. they should not dispatch events or use subscriptions. Example structure: ``` src -└── quo2 +└── quo ├── components │ └── dropdown │ ├── style.cljs diff --git a/nix/shells.nix b/nix/shells.nix index a30ec7d013..8f9cd776a6 100644 --- a/nix/shells.nix +++ b/nix/shells.nix @@ -21,7 +21,7 @@ let buildInputs = with pkgs; [ clojure flock maven openjdk # lint specific utilities - clj-kondo zprint clojure-lsp + clj-kondo zprint clojure-lsp ripgrep ]; # CLASSPATH from clojure deps with 'src' appended to find local sources. shellHook = with pkgs; '' diff --git a/scripts/lint-direct-require-component-outside-quo.sh b/scripts/lint-direct-require-component-outside-quo.sh new file mode 100755 index 0000000000..19c52bee71 --- /dev/null +++ b/scripts/lint-direct-require-component-outside-quo.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +# quo components namespace ends with style|utils|types|reaction-resource +# are not the component view, they are usually utils fns or styles + +if rg --pcre2 --glob '!src/quo/**/*' 'quo\.components(\.[\w-]+)*\.[\w-]*(?