Skip to content

Commit

Permalink
3534: Cleaned up and applied coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Jan 9, 2025
1 parent 7ee6a64 commit c764a7d
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 321 deletions.
13 changes: 13 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"default": true,
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
"line-length": {
"line_length": 80,
"code_blocks": false,
"tables": false
},
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
"no-duplicate-heading": {
"siblings_only": true
}
}
12 changes: 0 additions & 12 deletions .markdownlintrc

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).
* [PR-371](https://github.com/itk-dev/hoeringsportal/pull/371)
Cleaned up archiving of citizen proposals

## [3.5.1] - 2023-09-01

## [3.5.0] - 2023-08-30

* [PR-363](https://github.com/itk-dev/hoeringsportal/pull/363)
Expand Down
67 changes: 67 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ tasks:
composer:
cmds:
- task compose -- exec phpfpm composer {{.CLI_ARGS}}
silent: true

composer-install:
cmds:
Expand Down Expand Up @@ -129,3 +130,69 @@ tasks:
sh: task compose -- exec --no-TTY --env PGPASSWORD=pretix pretix_database psql --user=pretix pretix --tuples-only --csv <<< "SELECT token FROM pretixbase_teamapitoken WHERE name = 'hoeringsportal'"
cmds:
- "task compose -- exec phpfpm curl --header 'Authorization: Token {{.API_TOKEN}}' {{.PRETIX_URL}}/api/v1/organizers/"

coding-standards:apply:
desc: "Apply coding standards"
cmds:
- task: coding-standards:markdown:apply
- task: coding-standards:assets:apply
- task: coding-standards:php:apply
- task: coding-standards:twig:apply
silent: true

coding-standards:check:
desc: "Apply coding standards"
cmds:
- task: coding-standards:markdown:check
- task: coding-standards:assets:check
- task: coding-standards:php:check
- task: coding-standards:twig:check
silent: true

coding-standards:assets:apply:
desc: "Apply coding standards for assets"
cmds:
# Prettier does not (yet, fcf.
# https://github.com/prettier/prettier/issues/15206) have an official
# docker image.
# https://hub.docker.com/r/jauderho/prettier is good candidate (cf. https://hub.docker.com/search?q=prettier&sort=updated_at&order=desc)
- docker pull jauderho/prettier
- docker run --rm --volume "$PWD:/work" jauderho/prettier --write playwright

coding-standards:assets:check:
desc: "Apply and check coding standards for assets"
cmds:
- task: coding-standards:assets:apply
- docker pull jauderho/prettier
- docker run --rm --volume "$PWD:/work" jauderho/prettier --check playwright

coding-standards:markdown:apply:
desc: "Apply coding standards for Markdown"
cmds:
- docker pull peterdavehello/markdownlint
- docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint --ignore '**/node_modules/**' --ignore '**/vendor/**' '*.md' 'web/*/custom/**/*.md' 'documentation/*.md' --fix
silent: true

coding-standards:markdown:check:
desc: "Apply and check coding standards for Markdown"
cmds:
- task: coding-standards:markdown:apply
- docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint --ignore '**/node_modules/**' --ignore '**/vendor/**' '*.md' 'web/*/custom/**/*.md' 'documentation/*.md'
silent: true

coding-standards:php:apply:
desc: "Apply coding standards for PHP"
cmds:
- task composer -- coding-standards-apply
silent: true

coding-standards:php:check:
desc: "Apply and check coding standards for PHP"
cmds:
- task: coding-standards:php:apply
- task composer -- coding-standards-check
silent: true

code-analysis:
cmds:
- task composer -- code-analysis
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
"@coding-standards-apply/twig-cs-fixer"
],
"coding-standards-apply/phpcs": [
"scripts/phpcbf --standard=phpcs.xml.dist"
"phpcbf --standard=phpcs.xml.dist"
],
"coding-standards-apply/twig-cs-fixer": [
"twig-cs-fixer lint web/themes/custom/hoeringsportal/templates --fix"
Expand All @@ -279,7 +279,7 @@
"@coding-standards-check/twig-cs-fixer"
],
"coding-standards-check/phpcs": [
"vendor/bin/phpcs --standard=phpcs.xml.dist"
"phpcs --standard=phpcs.xml.dist"
],
"coding-standards-check/twig-cs-fixer": [
"twig-cs-fixer lint web/themes/custom/hoeringsportal/templates"
Expand Down
22 changes: 5 additions & 17 deletions documentation/localDevelopment.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,36 +90,24 @@ All code must follow the [Drupal coding standards](https://www.drupal.org/docs/d

#### Coding standards

```sh
docker compose exec phpfpm composer coding-standards-check
```

Apply automatic coding standard fixes by running
Apply and check coding standard by running

```sh
docker compose exec phpfpm composer coding-standards-apply
task coding-standards:check
```

#### Code analysis

```sh
docker compose exec phpfpm composer code-analysis
task code-analysis
```

#### Markdown

```sh
docker compose run --rm node yarn install
```

```sh
docker compose run --rm node yarn coding-standards-check
```

Apply automatic coding standard fixes by running
Apply and check Markdown coding standards:

```sh
docker compose run --rm node yarn coding-standards-apply
task coding-standards:markdown:check
```

## About translations
Expand Down
18 changes: 0 additions & 18 deletions package.json

This file was deleted.

6 changes: 3 additions & 3 deletions playwright/citizen-proposal-support.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ test("Support proposal", async ({ page }) => {
await page.getByRole("button", { name: "Login" }).click();

await expect(
page.getByText("You're currently authenticated as Anders And")
page.getByText("You're currently authenticated as Anders And"),
).toBeVisible();

await expect(page.getByRole("link", { name: "Sign out" })).toBeVisible();

await expect(page.getByLabel("Name", { exact: true })).toHaveValue(
"Anders And"
"Anders And",
);

await page.getByRole("button", { name: "Support proposal" }).click();
Expand All @@ -48,7 +48,7 @@ test("Support proposal", async ({ page }) => {

// Test that citizen cannot support proposal more than once
await expect(
page.getByText("You already supported this proposal")
page.getByText("You already supported this proposal"),
).toBeVisible();

// Test that citizen must re-authenticate to support another proposal
Expand Down
12 changes: 6 additions & 6 deletions playwright/citizen-proposal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test("Can authenticate", async ({ page }) => {
await page.getByRole("link", { name: "Sign out" }).click();

await expect(
page.getByRole("link", { name: "Authenticate with MitID" })
page.getByRole("link", { name: "Authenticate with MitID" }),
).toBeVisible();
});

Expand All @@ -31,7 +31,7 @@ test("Create proposal", async ({ page }) => {
await page.getByRole("button", { name: "Login" }).click();

await expect(
page.getByText("You're currently authenticated as Anders And")
page.getByText("You're currently authenticated as Anders And"),
).toBeVisible();

await expect(page.getByRole("link", { name: "Sign out" })).toBeVisible();
Expand Down Expand Up @@ -61,21 +61,21 @@ test("Create proposal", async ({ page }) => {
expect(page).toHaveURL("/citizen_proposal/approve");

await expect(
page.getByRole("button", { name: "Approve proposal" })
page.getByRole("button", { name: "Approve proposal" }),
).toBeVisible();

await expect(page.getByRole("link", { name: "Edit proposal" })).toBeVisible();

await expect(
page.getByRole("button", { name: "Cancel proposal" })
page.getByRole("button", { name: "Cancel proposal" }),
).toBeVisible();

await expect(page.getByText("[email protected]")).toBeVisible();

await page.getByRole("link", { name: "Edit proposal" }).click();

await expect(page.getByLabel("Email", { exact: true })).toHaveValue(
"[email protected]"
"[email protected]",
);

await page.getByLabel("Email", { exact: true }).fill("[email protected]");
Expand Down Expand Up @@ -128,6 +128,6 @@ test("Cancel proposal", async ({ page }) => {
await page.getByRole("button", { name: "Cancel proposal" }).click();

await expect(
page.getByText("Your submission has been cancelled.")
page.getByText("Your submission has been cancelled."),
).toBeVisible();
});
19 changes: 0 additions & 19 deletions scripts/phpcbf

This file was deleted.

5 changes: 1 addition & 4 deletions web/themes/custom/hoeringsportal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
We use [Webpack
Encore](http://symfony.com/doc/current/frontend.html#webpack-encore)
to handle frontend assets, see
http://symfony.com/doc/current/frontend.html#webpack-encore for
<http://symfony.com/doc/current/frontend.html#webpack-encore> for
details.


JavaScript and CSS (actually SCSS) assets are put in `assets/js/` and
`assets/css/`, respectively, and built assets are put in `build/`.


## Building assets

First, install tools and requirements:
Expand Down Expand Up @@ -79,7 +77,6 @@ yarn run apply-coding-standards-js

to apply any possible automatic fixes.


### Twig

Check twig standards
Expand Down
Loading

0 comments on commit c764a7d

Please sign in to comment.