Skip to content
Merged
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
3 changes: 1 addition & 2 deletions .claude/rules/edge-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ document.addEventListener('DOMContentLoaded', async () => {
- Avoid using `!important` as it breaks the natural cascading behavior of CSS. Instead, use more specific selectors or leverage CSS custom properties (variables) for values that need to be overridden.
- Use CSS custom properties (variables) for theme values, colors, and other design tokens that need to be overridden.
- Do not add code comments to CSS code unless it's not obvious what the code does.
- This project uses [Super Linter](mdc:https://github.com/github/super-linter) for linting.
- Stylelint is used for linting CSS files.
- Stylelint is used for linting CSS files.
- Use Stylelint's rules ([https://stylelint.io/user-guide/rules](https://stylelint.io/user-guide/rules)) as a guide when generating code.

## SCSS
Expand Down
13 changes: 0 additions & 13 deletions .github/linters/.jscpd.json

This file was deleted.

4 changes: 0 additions & 4 deletions .github/linters/.prettierrc.json

This file was deleted.

10 changes: 0 additions & 10 deletions .github/linters/.textlintrc

This file was deleted.

9 changes: 0 additions & 9 deletions .github/linters/.yamllint.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/linters/stylelint.config.cjs

This file was deleted.

100 changes: 90 additions & 10 deletions .github/workflows/edge-app-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
outputs:
changed-apps: ${{ steps.extract-changes.outputs.changed-apps }}
apps-with-build-system: ${{ steps.build-system-check.outputs.apps-with-build-system }}
apps-without-build-system: ${{ steps.no-build-system-check.outputs.apps-without-build-system }}
steps:
- name: Checkout code
uses: actions/checkout@v6
Expand Down Expand Up @@ -46,12 +47,12 @@ jobs:
# Read CHANGED_FILES into an array
read -ra FILES_ARRAY <<< "$CHANGED_FILES"

# Function to add app to list if it has build system and isn't already included
# Function to add app to list if not already included
add_app_if_valid() {
local app="$1"
if [[ -n "$app" && "$app" != "helpers" && "$app" != ".bun-create" ]]; then
if [[ -f "edge-apps/$app/package.json" ]]; then
if [[ ! " $CHANGED_APPS " =~ $app ]]; then
if [[ -d "edge-apps/$app" ]]; then
if [[ " $CHANGED_APPS " != *" $app "* ]]; then
CHANGED_APPS="$CHANGED_APPS $app"
fi
fi
Expand Down Expand Up @@ -99,8 +100,30 @@ jobs:
fi
echo "Apps with build system: $APPS_WITH_BUILD_SYSTEM"

run-checks:
name: Run Checks for ${{ matrix.app }}
- name: Check which apps don't have build systems
id: no-build-system-check
run: |
CHANGED_APPS="${{ steps.extract-changes.outputs.changed-apps }}"
APPS_WITHOUT_BUILD_SYSTEM=""

read -ra APPS_ARRAY <<< "$CHANGED_APPS"
for app in "${APPS_ARRAY[@]}"; do
if [[ ! -f "edge-apps/$app/package.json" ]]; then
APPS_WITHOUT_BUILD_SYSTEM="$APPS_WITHOUT_BUILD_SYSTEM $app"
fi
done

APPS_WITHOUT_BUILD_SYSTEM="${APPS_WITHOUT_BUILD_SYSTEM# }"
if [[ -n "$APPS_WITHOUT_BUILD_SYSTEM" ]]; then
JSON_ARRAY=$(echo "$APPS_WITHOUT_BUILD_SYSTEM" | tr ' ' '\n' | jq -R . | jq -s -c .)
echo "apps-without-build-system=$JSON_ARRAY" >> "$GITHUB_OUTPUT"
else
echo "apps-without-build-system=[]" >> "$GITHUB_OUTPUT"
fi
echo "Apps without build system: $APPS_WITHOUT_BUILD_SYSTEM"

run-full-checks:
name: Run Full Checks for ${{ matrix.app }}
runs-on: ubuntu-latest
needs: detect-changes
strategy:
Expand Down Expand Up @@ -162,24 +185,81 @@ jobs:
retry_on: error
command: cd edge-apps/${{ matrix.app }} && bun run test:e2e

run-simple-checks:
name: Run Simple Checks for ${{ matrix.app }}
runs-on: ubuntu-latest
needs: detect-changes
strategy:
matrix:
app: ${{ fromJSON(needs.detect-changes.outputs.apps-without-build-system) }}
fail-fast: false
if: needs.detect-changes.outputs.apps-without-build-system != '[]'

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.2.2

- name: Run formatting check
run: |
bunx prettier --check \
--config edge-apps/.prettierrc.json \
"edge-apps/${{ matrix.app }}/**/*.{html,css,js,json,yml,yaml,md}"

- name: Run Markdown lint
run: |
bunx markdownlint-cli2 "edge-apps/${{ matrix.app }}/**/*.md"

- name: Run HTML lint
run: |
find "edge-apps/${{ matrix.app }}" \
-name "*.html" \
-not -path "*/static/*" \
-not -path "*/dist/*" \
-not -path "*/node_modules/*" \
-print0 | xargs -0 -r bunx htmlhint

- name: Run CSS lint
run: |
find "edge-apps/${{ matrix.app }}" \
-name "*.css" \
-not -path "*/dist/*" \
-not -path "*/node_modules/*" \
-print0 | xargs -0 -r bunx stylelint \
--config edge-apps/.stylelintrc.json

- name: Run JavaScript lint
run: |
find "edge-apps/${{ matrix.app }}" \
-name "*.js" \
-not -name "*.min.js" \
-not -name "eslint.config.js" \
-not -path "*/dist/*" \
-not -path "*/node_modules/*" \
-print0 | xargs -0 -r bunx eslint \
--config edge-apps/eslint.config.cjs

summary:
name: Summary
runs-on: ubuntu-latest
needs: [detect-changes, run-checks]
needs: [detect-changes, run-full-checks, run-simple-checks]
if: always()
steps:
- name: Check if any apps were processed
run: |
if [[ "${{ needs.detect-changes.outputs.changed-apps }}" == "" ]]; then
echo "No Edge Apps were changed."
elif [[ "${{ needs.detect-changes.outputs.apps-with-build-system }}" == "[]" ]]; then
echo "Changed Edge Apps don't have build systems: ${{ needs.detect-changes.outputs.changed-apps }}"
else
echo "Processed Edge Apps with build systems: ${{ needs.detect-changes.outputs.apps-with-build-system }}"
echo "Apps with build system: ${{ needs.detect-changes.outputs.apps-with-build-system }}"
echo "Apps without build system: ${{ needs.detect-changes.outputs.apps-without-build-system }}"
fi

- name: Check for failures
if: needs.run-checks.result == 'failure'
if: needs.run-full-checks.result == 'failure' || needs.run-simple-checks.result == 'failure'
run: |
echo "Some Edge App checks failed. Please review the logs above."
exit 1
79 changes: 0 additions & 79 deletions .github/workflows/linter.yml

This file was deleted.

10 changes: 10 additions & 0 deletions edge-apps/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/stylelintrc",
"rules": {
"color-no-invalid-hex": true,
"declaration-block-no-duplicate-properties": true,
"no-duplicate-selectors": true,
"no-empty-source": true,
"unit-no-unknown": true
}
}
35 changes: 35 additions & 0 deletions edge-apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,41 @@ After scaffolding:
bun run dev
```

## Linting and Formatting

### Apps with a build system

From the app directory, run:

```bash
bun run lint
bun run format:check
```

### Apps without a build system

From the repository root, run the following tools via `bunx`:

```bash
# Formatting (HTML, CSS, JS, JSON, YAML, Markdown)
Comment thread
nicomiguelino marked this conversation as resolved.
bunx prettier --check --config edge-apps/.prettierrc.json "edge-apps/<app-name>/**/*.{html,css,js,json,yml,yaml,md}"

# Markdown
bunx markdownlint-cli2 "edge-apps/<app-name>/**/*.md"

# HTML
bunx htmlhint "edge-apps/<app-name>/index.html"

# CSS (excludes dist/)
find edge-apps/<app-name> -name "*.css" -not -path "*/dist/*" -not -path "*/node_modules/*" \
-print0 | xargs -0 -r bunx stylelint --config edge-apps/.stylelintrc.json

# JavaScript (excludes dist/ and minified files)
find edge-apps/<app-name> -name "*.js" -not -name "*.min.js" -not -name "eslint.config.js" \
-not -path "*/dist/*" -not -path "*/node_modules/*" \
-print0 | xargs -0 -r bunx eslint --config edge-apps/eslint.config.cjs
```

## TypeScript Library

The [`@screenly/edge-apps`](https://www.npmjs.com/package/@screenly/edge-apps) NPM package contains shared utilities, components, and styles used by the apps in this directory.
26 changes: 26 additions & 0 deletions edge-apps/eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @type {import('eslint').Linter.Config[]} */
module.exports = [
{
languageOptions: {
ecmaVersion: 2020,
sourceType: 'script',
globals: {
window: 'readonly',
document: 'readonly',
console: 'readonly',
fetch: 'readonly',
screenly: 'readonly',
setTimeout: 'readonly',
setInterval: 'readonly',
clearTimeout: 'readonly',
clearInterval: 'readonly',
alert: 'readonly',
location: 'readonly',
},
},
rules: {
'no-undef': 'error',
'no-unused-vars': 'warn',
},
},
]