Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: add frontend tooling #184

Draft
wants to merge 5 commits into
base: 3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .ddev/commands/web/eslint-js
Original file line number Diff line number Diff line change
@@ -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 $*
7 changes: 7 additions & 0 deletions .ddev/commands/web/eslint-yaml
Original file line number Diff line number Diff line change
@@ -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 $*
7 changes: 7 additions & 0 deletions .ddev/commands/web/stylelint
Original file line number Diff line number Diff line change
@@ -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 $*
12 changes: 12 additions & 0 deletions .lando.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 && 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
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
87 changes: 87 additions & 0 deletions README_FRONTEND_TOOLING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# LocalGov Drupal Frontend Tooling

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 only needs to be done once.

```bash
lando install-frontend
ddev install-frontend
```

## ESLint (Javascript) Usage

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, 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

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, 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

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, add the `--fix` flag:

```bash
lando stylelint --fix web/modules/contrib/[project_name]/**/*.css
ddev stylelint --fix web/modules/contrib/[project_name]/**/*.css
```