From 7d6ac656fe2fed08500f74bc9b6ac0f393c8f9ca Mon Sep 17 00:00:00 2001 From: Lee Mills Date: Tue, 31 Dec 2024 15:32:31 +0000 Subject: [PATCH 1/5] feat: add frontend tooling to lando --- .lando.dist.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.lando.dist.yml b/.lando.dist.yml index 9c46dad..0eb4a94 100644 --- a/.lando.dist.yml +++ b/.lando.dist.yml @@ -115,3 +115,15 @@ tooling: update-solr-config: service: appserver cmd: /app/.lando/update-solr-config.sh + install-frontend: + service: node + cmd: cd /app/web/core && cp -f /app/web/core/.prettierrc.json /app/web/.prettierrc.json && npm i + eslint-js: + service: node + cmd: /app/web/core/node_modules/eslint/bin/eslint.js --ext .js --resolve-plugins-relative-to=./web/core + eslint-yml: + service: node + cmd: /app/web/core/node_modules/eslint/bin/eslint.js --ext .yml --resolve-plugins-relative-to=./web/core + stylelint: + service: node + cmd: /app/web/core/node_modules/.bin/stylelint --ignore-path /app/web/core/.stylelintignore --config /app/web/core/.stylelintrc.json From f7584c0a4db70276a7f1561771d21d2ef0a26ebe Mon Sep 17 00:00:00 2001 From: Lee Mills Date: Tue, 31 Dec 2024 15:45:26 +0000 Subject: [PATCH 2/5] feat: add frontend tooling readme --- README_FRONTEND_TOOLING.md | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 README_FRONTEND_TOOLING.md diff --git a/README_FRONTEND_TOOLING.md b/README_FRONTEND_TOOLING.md new file mode 100644 index 0000000..fb2db87 --- /dev/null +++ b/README_FRONTEND_TOOLING.md @@ -0,0 +1,73 @@ +# LocalGov Drupal Frontend Tooling + +Below details the steps required to run the frontend tooling such as ESLint and Stylelint via Lando or DDEV. + +## Prerequisites + +Run the following command to install the frontend dependencies. + +This installs Drupal Core's frontend packages and copies the Prettier config to the correct directory for tooling. + +```bash +lando install-frontend +``` + +## ESLint (Javascript) Usage + +Run: + +```bash +lando eslint-js web/modules/contrib/[project_name] +``` + +E.g. + +```bash +lando eslint-js web/modules/contrib/localgov_core +``` + +If you wish to fix some of the issues automatically, this can be run with the following: + +```bash +lando eslint-js --fix web/modules/contrib/[project_name] +``` + +## ESLint (Yaml) Usage + +Run: + +```bash +lando eslint-yml web/modules/contrib/[project_name] +``` + +E.g. + +```bash +lando eslint-yml web/modules/contrib/localgov_core +``` + +If you wish to fix some of the issues automatically, this can be run with the following: + +```bash +lando eslint-yml --fix web/modules/contrib/[project_name] +``` + +## Stylelint (CSS) Usage + +Run: + +```bash +lando stylelint web/modules/contrib/[project_name]/**/*.css +``` + +E.g. + +```bash +lando stylelint web/modules/contrib/localgov_base/**/*.css +``` + +If you wish to fix some of the issues automatically, this can be run with the following: + +```bash +lando stylelint --fix web/modules/contrib/[project_name]/**/*.css +``` From beddbd1618eba844adbca954185fb7807b09cc39 Mon Sep 17 00:00:00 2001 From: Lee Mills Date: Tue, 31 Dec 2024 16:01:45 +0000 Subject: [PATCH 3/5] feat: add frontend tooling to lando --- .lando.dist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lando.dist.yml b/.lando.dist.yml index 0eb4a94..83e1125 100644 --- a/.lando.dist.yml +++ b/.lando.dist.yml @@ -117,7 +117,7 @@ tooling: cmd: /app/.lando/update-solr-config.sh install-frontend: service: node - cmd: cd /app/web/core && cp -f /app/web/core/.prettierrc.json /app/web/.prettierrc.json && npm i + cmd: cd /app/web/core && cp -f /app/web/core/.prettierrc.json /app/web/.prettierrc.json && cp -f /app/web/core/.prettierignore /app/.prettierignore && npm i eslint-js: service: node cmd: /app/web/core/node_modules/eslint/bin/eslint.js --ext .js --resolve-plugins-relative-to=./web/core From c6b0da2ec60aaed5c6d09b894a638c42dc4dc6a6 Mon Sep 17 00:00:00 2001 From: Finn Date: Wed, 5 Feb 2025 18:17:00 +0800 Subject: [PATCH 4/5] Add ddev commands for eslint and stylelint, aiming to replicate the functionality added to the Lando config. --- .ddev/commands/web/eslint-js | 7 +++++++ .ddev/commands/web/eslint-yaml | 7 +++++++ .ddev/commands/web/stylelint | 7 +++++++ 3 files changed, 21 insertions(+) create mode 100755 .ddev/commands/web/eslint-js create mode 100755 .ddev/commands/web/eslint-yaml create mode 100755 .ddev/commands/web/stylelint diff --git a/.ddev/commands/web/eslint-js b/.ddev/commands/web/eslint-js new file mode 100755 index 0000000..50d1866 --- /dev/null +++ b/.ddev/commands/web/eslint-js @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +## Description: Run the eslint on js files. +## Usage: eslint-js +## Example: "ddev eslint-js" + +/var/www/html/web/core/node_modules/eslint/bin/eslint.js --ext .js --resolve-plugins-relative-to=./web/core $* \ No newline at end of file diff --git a/.ddev/commands/web/eslint-yaml b/.ddev/commands/web/eslint-yaml new file mode 100755 index 0000000..1ab889c --- /dev/null +++ b/.ddev/commands/web/eslint-yaml @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +## Description: Run the eslint on yaml files. +## Usage: eslint-yaml +## Example: "ddev eslint-yaml" + +/var/www/html/web/core/node_modules/eslint/bin/eslint.js --ext .yml --resolve-plugins-relative-to=./web/core $* \ No newline at end of file diff --git a/.ddev/commands/web/stylelint b/.ddev/commands/web/stylelint new file mode 100755 index 0000000..c3eab35 --- /dev/null +++ b/.ddev/commands/web/stylelint @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +## Description: Run the stylelint. +## Usage: stylelint +## Example: "ddev stylelint" + +/var/www/html/web/core/node_modules/.bin/stylelint --ignore-path /var/www/html/web/core/.stylelintignore --config /var/www/html/web/core/.stylelintrc.json $* \ No newline at end of file From ae0e0956c96ce59872425a8faccf0468a906c4ed Mon Sep 17 00:00:00 2001 From: Finn Date: Wed, 5 Feb 2025 19:01:18 +0800 Subject: [PATCH 5/5] Update README_FRONTEND_TOOLING.md with corresponding ddev commands. --- README_FRONTEND_TOOLING.md | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/README_FRONTEND_TOOLING.md b/README_FRONTEND_TOOLING.md index fb2db87..5e0468e 100644 --- a/README_FRONTEND_TOOLING.md +++ b/README_FRONTEND_TOOLING.md @@ -1,73 +1,87 @@ # LocalGov Drupal Frontend Tooling -Below details the steps required to run the frontend tooling such as ESLint and Stylelint via Lando or DDEV. +Below details the steps required to run the frontend tooling such as ESLint and +Stylelint with Lando or DDEV. ## Prerequisites Run the following command to install the frontend dependencies. -This installs Drupal Core's frontend packages and copies the Prettier config to the correct directory for tooling. +This installs Drupal Core's frontend packages and copies the Prettier config +to the correct directory for tooling. + +This only needs to be done once. ```bash lando install-frontend +ddev install-frontend ``` ## ESLint (Javascript) Usage -Run: +To run eslint on just .js files, run: ```bash lando eslint-js web/modules/contrib/[project_name] +ddev eslint-js web/modules/contrib/[project_name] ``` E.g. ```bash lando eslint-js web/modules/contrib/localgov_core +ddev eslint-js web/modules/contrib/localgov_core ``` -If you wish to fix some of the issues automatically, this can be run with the following: +If you wish to fix some of the issues automatically, add the `--fix` flag: ```bash lando eslint-js --fix web/modules/contrib/[project_name] +ddev eslint-js --fix web/modules/contrib/[project_name] ``` ## ESLint (Yaml) Usage -Run: +To run eslint on just .yml files, run: ```bash lando eslint-yml web/modules/contrib/[project_name] +ddev eslint-yml web/modules/contrib/[project_name] ``` E.g. ```bash lando eslint-yml web/modules/contrib/localgov_core +ddev eslint-yml web/modules/contrib/localgov_core ``` -If you wish to fix some of the issues automatically, this can be run with the following: +If you wish to fix some of the issues automatically, add the `--fix` flag: ```bash lando eslint-yml --fix web/modules/contrib/[project_name] +ddev eslint-yml --fix web/modules/contrib/[project_name] ``` ## Stylelint (CSS) Usage -Run: +To run stylelint on all css files, run: ```bash lando stylelint web/modules/contrib/[project_name]/**/*.css +ddev stylelint web/modules/contrib/[project_name]/**/*.css ``` E.g. ```bash lando stylelint web/modules/contrib/localgov_base/**/*.css +ddev stylelint web/modules/contrib/localgov_base/**/*.css ``` -If you wish to fix some of the issues automatically, this can be run with the following: +If you wish to fix some of the issues automatically, add the `--fix` flag: ```bash lando stylelint --fix web/modules/contrib/[project_name]/**/*.css +ddev stylelint --fix web/modules/contrib/[project_name]/**/*.css ```