Skip to content

Fix color linting script for cross platform development#7776

Open
Steve-Mcl wants to merge 4 commits into
mainfrom
7775-color-linting
Open

Fix color linting script for cross platform development#7776
Steve-Mcl wants to merge 4 commits into
mainfrom
7775-color-linting

Conversation

@Steve-Mcl

@Steve-Mcl Steve-Mcl commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

This pull request refactors the scripts/lint-colors.js script to remove its dependency on the grep command, making it cross-platform. Additionally, the exit method was changed from a noisy throw to a process.exit(1) (see note below)

Linting infrastructure improvements:

  • Replaces all uses of the grep shell command in scripts/lint-colors.js with a new cross-platform grepLines function that recursively searches files for patterns, improving compatibility and reliability. (F18d4070L4R4, [1] [2]
  • Changes the script's failure handling to use process.exit(1) instead of throwing an error, ensuring proper exit codes in all environments.

Temp Testing (will be deleted after being ran on CI:

* Adds two probe files, frontend/src/__lint_probe__.scss and frontend/src/__lint_probe__.vue, containing intentional lint violations to test the color linting script. [1] [2]
* Adds a probe-only theme token to frontend/src/ui-components/stylesheets/ff-theme-light.scss to test theme parity checks.

THESE WILL BE DELETED BEFORE MERGE

UPDATE: test probes removed - results can be seen here: https://github.com/FlowFuse/flowfuse/actions/runs/28938870171/job/85856315043?pr=7776


NOTE:

The script originally threw a new Error(...) when a lint fail was detected. While it does give a non-zero exit code (an uncaught exception makes node exit with 1) it also dumps a stack trace pointing at lint-colors.js:159, which reads as if the script itself crashed rather than the lint found violations. The output becomes pure noise for someone who just wants to see what they need to fix.

The usual pattern for a CLI/lint tool is a clean exit with exit code e.g. process.exit(1)

BEFORE

.\packages\flowfuse\scripts\lint-colors.js:159
        throw new Error('FlowFuse color-token lint failed.')
        ^

Error: FlowFuse color-token lint failed.
    at run (.\packages\flowfuse\scripts\lint-colors.js:159:15)
    at Object.<anonymous> (.\packages\flowfuse\scripts\lint-colors.js:167:1)
    at Module._compile (node:internal/modules/cjs/loader:1706:14)
    at Object..js (node:internal/modules/cjs/loader:1839:10)
    at Module.load (node:internal/modules/cjs/loader:1441:32)
    at Function._load (node:internal/modules/cjs/loader:1263:12)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
    at Function.executeUserEntryPoint [as runMai

AFTER

FlowFuse color-token lint failed.

# no stack trace ↑ and the exit code is non zero ↓

~/flowfuse (main)
$ echo "exit code: $?"
exit code: 1

Related Issue(s)

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production
  • Link to Changelog Entry PR, or note why one is not needed.

Labels

  • Includes a DB migration? -> add the area:migration label

@Steve-Mcl

Steve-Mcl commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

probe files confirm the corss-platform changes finds color lint errors.


> @flowfuse/flowfuse@2.32.0 lint
> npm-run-all --sequential lint:eslint lint:colors


> @flowfuse/flowfuse@2.32.0 lint:eslint
(node:2440) ESLintEnvWarning: /* eslint-env */ comments are no longer recognized when linting with flat config and will be reported as errors as of v10.0.0. Replace them with /* global */ comments or define globals in your config file. See https://eslint.org/docs/latest/use/configure/migration-guide#eslint-env-configuration-comments for details. Found in /home/runner/work/flowfuse/flowfuse/test/unit/frontend/stores/context.spec.js at line 1.
(Use `node --trace-warnings ...` to show where the warning was created)
> eslint forge frontend test

(node:2440) ESLintEnvWarning: /* eslint-env */ comments are no longer recognized when linting with flat config and will be reported as errors as of v10.0.0. Replace them with /* global */ comments or define globals in your config file. See https://eslint.org/docs/latest/use/configure/migration-guide#eslint-env-configuration-comments for details. Found in /home/runner/work/flowfuse/flowfuse/test/unit/frontend/subscribers/team-channel.subscriber.spec.js at line 1.

> @flowfuse/flowfuse@2.32.0 lint:colors
> node scripts/lint-colors.js


— Banned color references —
<snip for brevity >


— Banned Tailwind utility classes in templates —

<snip for brevity >

— Theme-file parity —

<snip for brevity >

FlowFuse color-token lint failed.
ERROR: "lint:colors" exited with 1.
Error: Process completed with exit code 1.

The follow commits will now remove the probes

The remaining eslint-env CLI warnings will be resolved when #7774 is merged.

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.38%. Comparing base (3a61885) to head (ad4db66).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7776   +/-   ##
=======================================
  Coverage   75.38%   75.38%           
=======================================
  Files         428      428           
  Lines       22539    22539           
  Branches     5944     5944           
=======================================
  Hits        16992    16992           
  Misses       5547     5547           
Flag Coverage Δ
backend 75.38% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Steve-Mcl Steve-Mcl linked an issue Jul 8, 2026 that may be closed by this pull request
@Steve-Mcl Steve-Mcl requested a review from n-lark July 8, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Full linting of code not possible on windows

1 participant