slopthreshold 2.1.0.dev22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. slopthreshold/__init__.py +1 -0
  2. slopthreshold/guide/STYLE_GUIDE.md +495 -0
  3. slopthreshold/packs/editorconfig-pack/.editorconfig +899 -0
  4. slopthreshold/packs/editorconfig-pack/Directory.Build.props +47 -0
  5. slopthreshold/packs/editorconfig-pack/Directory.Build.targets +16 -0
  6. slopthreshold/packs/editorconfig-pack/Directory.Packages.props +29 -0
  7. slopthreshold/packs/editorconfig-pack/README.md +141 -0
  8. slopthreshold/packs/editorconfig-pack/global.json +7 -0
  9. slopthreshold/packs/editorconfig-pack/nuget.config +19 -0
  10. slopthreshold/packs/editorconfig-pack/ruff.toml +29 -0
  11. slopthreshold/packs/editorconfig-pack/sonar-drift-allowlist.json +10 -0
  12. slopthreshold/packs/frontend-lint-pack/.prettierrc.json +7 -0
  13. slopthreshold/packs/frontend-lint-pack/.stylelintrc.json +64 -0
  14. slopthreshold/packs/frontend-lint-pack/README.md +64 -0
  15. slopthreshold/packs/frontend-lint-pack/eslint.config.mjs +108 -0
  16. slopthreshold/packs/frontend-lint-pack/package.json +23 -0
  17. slopthreshold/packs/frontend-lint-pack/tsconfig.app.json +17 -0
  18. slopthreshold/packs/frontend-lint-pack/tsconfig.base.json +20 -0
  19. slopthreshold/packs/frontend-lint-pack/tsconfig.json +4 -0
  20. slopthreshold/packs/frontend-lint-pack/tsconfig.spec.json +8 -0
  21. slopthreshold/packs/project-guide-starters/app-STYLE_GUIDE.md +35 -0
  22. slopthreshold/packs/project-guide-starters/frontend-STYLE_GUIDE.md +33 -0
  23. slopthreshold/packs/project-guide-starters/library-STYLE_GUIDE.md +36 -0
  24. slopthreshold/packs/three-layer-wiring/.githooks/commit-msg +13 -0
  25. slopthreshold/packs/three-layer-wiring/.githooks/post-merge +8 -0
  26. slopthreshold/packs/three-layer-wiring/.githooks/pre-commit +10 -0
  27. slopthreshold/packs/three-layer-wiring/.githooks/pre-push +14 -0
  28. slopthreshold/packs/three-layer-wiring/.github/actionlint.yaml +3 -0
  29. slopthreshold/packs/three-layer-wiring/.github/workflows/quality.yml +164 -0
  30. slopthreshold/packs/three-layer-wiring/.gitleaks.toml +16 -0
  31. slopthreshold/packs/three-layer-wiring/.hadolint.yaml +6 -0
  32. slopthreshold/packs/three-layer-wiring/README.md +62 -0
  33. slopthreshold/packs/three-layer-wiring/budget.json +14 -0
  34. slopthreshold/tools/check_characters.py +104 -0
  35. slopthreshold/tools/check_ci_config.py +405 -0
  36. slopthreshold/tools/check_package_health.py +554 -0
  37. slopthreshold/tools/check_sonar_drift.py +1123 -0
  38. slopthreshold/tools/mine_sonar_metrics.py +1259 -0
  39. slopthreshold/tools/validate_guide_tags.py +795 -0
  40. slopthreshold/zh.py +973 -0
  41. slopthreshold-2.1.0.dev22.dist-info/METADATA +49 -0
  42. slopthreshold-2.1.0.dev22.dist-info/RECORD +44 -0
  43. slopthreshold-2.1.0.dev22.dist-info/WHEEL +4 -0
  44. slopthreshold-2.1.0.dev22.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,35 @@
1
+ # <Project> — Style Guide
2
+
3
+ This project adopts the Generalized Style Guide v2.1. Project rules below
4
+ add to it. Overrides and bypasses of generalized rules are listed under
5
+ "Generalized guide overrides" and nowhere else.
6
+
7
+ ## Project facts
8
+
9
+ - **Purpose:** <one or two sentences>
10
+ - **Stack:** .NET <version>, <database>, <frontend if any>
11
+ - **Deployment:** <where it runs; data residency decision (ST-PRIV-03)>
12
+ - **Auth:** <identity approach; passkeys offered? (ST-SEC-13)>
13
+ - **Tenancy:** <single-tenant / multi-tenant; tenant isolation rule>
14
+
15
+ ## Project rules
16
+
17
+ - **Transport (ST-MSG-04):** <Redis Pub/Sub / Streams / broker choice and why>
18
+ - **API versioning (ST-API-05):** <contract versioning approach>
19
+ - **Caching (ST-PAT-07):** <what is cached, TTLs, invalidation triggers>
20
+ - **Money (ST-MONEY-02):** <rounding mode at each boundary, or "no money handling">
21
+ - **Time (ST-TIME-03):** <calendar library decision for recurrence, or "instants only">
22
+ - **Domain rules:** <invariants reviewers must enforce, one per bullet>
23
+
24
+ ## Generalized guide overrides
25
+
26
+ <!-- No tags yet. Add OVERRIDE (DEFAULT rules), BYPASS (REQUIRED rules,
27
+ with approver and review date) or BYPASS-LIB (one package) lines
28
+ here. Examples live in the generalized guide's overrides template.
29
+ Validate with the bypass-tag validator before merging changes. -->
30
+
31
+ ## Open decisions
32
+
33
+ | # | Question | Default until decided |
34
+ |---|---|---|
35
+ | 1 | <question> | <default> |
@@ -0,0 +1,33 @@
1
+ # <Project> Frontend — Style Guide
2
+
3
+ This project adopts the Generalized Style Guide v2.1 (Part 2, plus the
4
+ Angular addendum where Angular is used). Project rules below add to it.
5
+ Overrides and bypasses of generalized rules are listed under
6
+ "Generalized guide overrides" and nowhere else.
7
+
8
+ ## Project facts
9
+
10
+ - **Framework:** <Angular version / React / other>
11
+ - **Locales:** <for example ar (RTL) and en (LTR); default locale>
12
+ - **API:** <base URL shape; envelope type; generated-types source (ST-FE-API-01)>
13
+ - **Theme:** <token set (UiKit --zh-* or project tokens); dark mode stance>
14
+
15
+ ## Project rules
16
+
17
+ - **Selector prefix (ST-FE-NG-02):** <app prefix set in angular.json, or n/a>
18
+ - **i18n (ST-FE-NG-10):** <per-locale builds / runtime switching decision>
19
+ - **Forms (ST-FE-NG-12):** <Signal Forms for new forms; reactive exceptions>
20
+ - **Performance budgets (ST-FE-PERF-01):** <per-route budgets and CI check>
21
+ - **Libraries consumed:** <page-model / page-builder / UiKit versions>
22
+
23
+ ## Generalized guide overrides
24
+
25
+ <!-- No tags yet. Add OVERRIDE (DEFAULT rules), BYPASS (REQUIRED rules,
26
+ with approver and review date) or BYPASS-LIB (one package) lines
27
+ here. Validate with the bypass-tag validator before merging. -->
28
+
29
+ ## Open decisions
30
+
31
+ | # | Question | Default until decided |
32
+ |---|---|---|
33
+ | 1 | <question> | <default> |
@@ -0,0 +1,36 @@
1
+ # <Library> — Style Guide
2
+
3
+ This project adopts the Generalized Style Guide v2.1. Project rules below
4
+ add to it. Overrides and bypasses of generalized rules are listed under
5
+ "Generalized guide overrides" and nowhere else.
6
+
7
+ ## Project facts
8
+
9
+ - **Packages:** <package IDs this repo publishes>
10
+ - **Targets:** <for example net8.0;net10.0>
11
+ - **Feed:** <GitHub Packages / nuget.org; publishing flow>
12
+ - **AOT stance (ST-PERF-04):** <trim/AOT compatible: yes/no, IsAotCompatible>
13
+
14
+ ## Project rules
15
+
16
+ - **Public API:** SemVer per package (ST-BUILD-05). Breaking changes only
17
+ in a major version; deprecate first with `[Obsolete]` naming the
18
+ replacement and removal version.
19
+ - **Dependencies:** <which house packages this library consumes; anything
20
+ deliberately not consumed goes in the overrides section as BYPASS-LIB>
21
+ - **Compatibility:** <supported framework versions and how long old majors
22
+ receive fixes>
23
+ - **Docs:** every public member carries XML docs (ST-FMT-10, error in
24
+ this repo); README and CHANGELOG ship with every package.
25
+
26
+ ## Generalized guide overrides
27
+
28
+ <!-- No tags yet. Add OVERRIDE (DEFAULT rules), BYPASS (REQUIRED rules,
29
+ with approver and review date) or BYPASS-LIB (one package) lines
30
+ here. Validate with the bypass-tag validator before merging. -->
31
+
32
+ ## Open decisions
33
+
34
+ | # | Question | Default until decided |
35
+ |---|---|---|
36
+ | 1 | <question> | <default> |
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env bash
2
+ # Layer 2, message moment: ST-GIT-02 Conventional Commits via zh msg.
3
+ # ZH_MSG=warn prints problems without blocking; ZH_MSG=off skips.
4
+ set -u
5
+ [ "${ZH_HOOKS:-on}" = "off" ] && exit 0
6
+ [ "${ZH_MSG:-block}" = "off" ] && exit 0
7
+ if [ -f tools/zh.py ]; then
8
+ if [ "${ZH_MSG:-block}" = "warn" ]; then
9
+ python3 tools/zh.py msg "$1" || true
10
+ else
11
+ python3 tools/zh.py msg "$1"
12
+ fi
13
+ fi
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ # Advisory only: after a merge, warn when dependency files changed so the
3
+ # restore/install step is not forgotten. Never blocks.
4
+ set -u
5
+ changed=$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD 2>/dev/null || true)
6
+ echo "$changed" | grep -qE 'package(-lock)?\.json$' && echo "post-merge: package.json changed — run npm ci"
7
+ echo "$changed" | grep -qE '\.csproj$|Directory\.Packages\.props$|packages\.lock\.json$' && echo "post-merge: .NET pins changed — run dotnet restore"
8
+ exit 0
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ # Layer 2, commit moment: fast staged checks via zh (single source of logic).
3
+ # CI is the hard gate; this is the fast local mirror. ZH_HOOKS=off skips.
4
+ set -u
5
+ [ "${ZH_HOOKS:-on}" = "off" ] && exit 0
6
+ if [ -f tools/zh.py ]; then
7
+ python3 tools/zh.py check --staged --skip drift,metrics
8
+ else
9
+ echo "pre-commit: tools/zh.py not found; run zh adopt. Skipping local checks (CI enforces)."
10
+ fi
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bash
2
+ # Layer 2, push moment: full check + build via zh (tests stay in CI by
3
+ # default; ZH_PREPUSH_TESTS=1 adds them). ZH_HOOKS=off skips.
4
+ set -u
5
+ [ "${ZH_HOOKS:-on}" = "off" ] && exit 0
6
+ if [ -f tools/zh.py ]; then
7
+ if [ "${ZH_PREPUSH_TESTS:-0}" = "1" ]; then
8
+ python3 tools/zh.py pr
9
+ else
10
+ python3 tools/zh.py pr --skip test
11
+ fi
12
+ else
13
+ echo "pre-push: tools/zh.py not found; run zh adopt. Skipping local checks (CI enforces)."
14
+ fi
@@ -0,0 +1,3 @@
1
+ # actionlint configuration. Self-hosted runner labels used by this repo:
2
+ self-hosted-runner:
3
+ labels: []
@@ -0,0 +1,164 @@
1
+ name: quality
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [Dev, UAT, Prod]
7
+
8
+ permissions: {}
9
+
10
+ jobs:
11
+ backend:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ steps:
16
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
17
+ - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
18
+ with:
19
+ global-json-file: global.json
20
+ - name: Restore (locked)
21
+ env:
22
+ NUGET_TOKEN: ${{ secrets.NUGET_PRIVATE_FEED_API_KEY }}
23
+ run: dotnet restore --locked-mode
24
+ - name: Build
25
+ run: dotnet build --no-restore
26
+ - name: Test
27
+ run: dotnet test --no-build
28
+ - name: Format verify
29
+ run: dotnet format --verify-no-changes
30
+ - name: Validate style-guide tags
31
+ run: python3 tools/validate_guide_tags.py docs/STYLE_GUIDE.md --strict
32
+ - name: Health gate
33
+ env:
34
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35
+ run: python3 tools/check_package_health.py --props Directory.Packages.props
36
+ # SonarQube (ST-GATE-01/02): enable when the project is registered.
37
+ # - name: Sonar scan
38
+ # env:
39
+ # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
40
+ # run: |
41
+ # dotnet tool install --global dotnet-sonarscanner
42
+ # dotnet sonarscanner begin /k:"<project-key>" /d:sonar.host.url="https://sonar.hassanragai.dev" /d:sonar.token="$SONAR_TOKEN"
43
+ # dotnet build
44
+ # dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
45
+
46
+ frontend:
47
+ runs-on: ubuntu-latest
48
+ permissions:
49
+ contents: read
50
+ steps:
51
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
52
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
53
+ with:
54
+ node-version: 24
55
+ cache: npm
56
+ - name: Install (locked)
57
+ run: npm ci
58
+ - name: Lint
59
+ run: npm run lint
60
+ - name: Stylelint
61
+ run: npm run lint:styles
62
+ - name: Typecheck
63
+ run: npm run typecheck
64
+ - name: Audit (ST-FE-SEC-05)
65
+ run: npm audit --audit-level=high
66
+ - name: Health gate (npm)
67
+ env:
68
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69
+ run: python3 tools/check_package_health.py --npm package.json
70
+
71
+ security:
72
+ runs-on: ubuntu-latest
73
+ permissions:
74
+ contents: read
75
+ steps:
76
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
77
+ with:
78
+ fetch-depth: 0
79
+ - name: gitleaks
80
+ run: |
81
+ curl -sSL https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz | tar -xz gitleaks
82
+ ./gitleaks detect --redact --config .gitleaks.toml
83
+ - name: actionlint
84
+ run: |
85
+ curl -sSL https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz | tar -xz actionlint
86
+ ./actionlint
87
+ - name: No secrets expanded in run blocks (S7636)
88
+ run: |
89
+ if grep -rnE 'run:.*secrets\.' .github/workflows/; then
90
+ echo "Secrets must reach steps through env:, never expanded in run:"; exit 1
91
+ fi
92
+ - name: hadolint
93
+ run: |
94
+ curl -sSL -o hadolint https://github.com/hadolint/hadolint/releases/download/v2.15.1/hadolint-Linux-x86_64
95
+ chmod +x hadolint
96
+ find . -name 'Dockerfile*' -not -path './node_modules/*' -print0 | xargs -0 -r ./hadolint --config .hadolint.yaml
97
+
98
+ codeql:
99
+ name: CodeQL security scan (ST-SEC-16)
100
+ # Promotion gate: PRs to UAT/Prod and manual dispatch only.
101
+ if: >-
102
+ github.event_name == 'workflow_dispatch' ||
103
+ (github.event_name == 'pull_request' &&
104
+ (github.base_ref == 'UAT' || github.base_ref == 'Prod'))
105
+ runs-on: ubuntu-latest
106
+ timeout-minutes: 30
107
+ permissions:
108
+ contents: read
109
+ actions: read
110
+ security-events: write
111
+ steps:
112
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
113
+ with:
114
+ persist-credentials: false
115
+ - uses: github/codeql-action/init@915412ff23e8b7659517e607487dbeae018f2934 # v4
116
+ with:
117
+ languages: csharp
118
+ build-mode: none
119
+ - uses: github/codeql-action/analyze@915412ff23e8b7659517e607487dbeae018f2934 # v4
120
+ with:
121
+ category: "/language:csharp"
122
+ # SARIF uploads to the GitHub Security tab and to the artifact
123
+ # below (which feeds the BuildReports security page).
124
+ upload: always
125
+ output: artifacts/codeql
126
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
127
+ if: always()
128
+ with:
129
+ name: codeql-sarif
130
+ path: artifacts/codeql/*.sarif
131
+ if-no-files-found: ignore
132
+
133
+ # The agreed PR feedback loop: one gate summary comment per PR, updated
134
+ # in place on every push. Same-repo PRs only (fork tokens are read-only).
135
+ pr-comment:
136
+ name: PR gate comment
137
+ needs: [backend, frontend, security]
138
+ if: >-
139
+ always() && github.event_name == 'pull_request' &&
140
+ github.event.pull_request.head.repo.full_name == github.repository
141
+ runs-on: ubuntu-latest
142
+ timeout-minutes: 10
143
+ permissions:
144
+ contents: read
145
+ pull-requests: write
146
+ env:
147
+ GH_TOKEN: ${{ github.token }}
148
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
149
+ SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
150
+ SONAR_PROJECT_KEY: ${{ vars.SONAR_PROJECT_KEY }}
151
+ SONAR_BRANCH: ${{ github.base_ref }}
152
+ SONAR_PR: ${{ github.event.pull_request.number }}
153
+ steps:
154
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
155
+ with:
156
+ persist-credentials: false
157
+
158
+ - name: Build the reports manifest and post the gate comment
159
+ shell: bash
160
+ run: |
161
+ python3 tools/build_reports_site.py
162
+ python3 tools/pr_comment.py \
163
+ --repo "${{ github.repository }}" \
164
+ --pr "${{ github.event.pull_request.number }}"
@@ -0,0 +1,16 @@
1
+ # Extends the default gitleaks ruleset. Add allowlists sparingly, each
2
+ # with a comment naming why the match is not a secret.
3
+ title = "house gitleaks config"
4
+
5
+ [extend]
6
+ useDefault = true
7
+
8
+ [allowlist]
9
+ description = "test fixtures and documentation placeholders"
10
+ paths = [
11
+ '''tests/.*fixtures/''',
12
+ '''.*\.md$''',
13
+ ]
14
+ regexes = [
15
+ '''(?i)(example|placeholder|changeme|your[-_ ]?(api[-_ ]?key|token|secret))''',
16
+ ]
@@ -0,0 +1,6 @@
1
+ # ST-BUILD-06: containers run as non-root (DL3002). Threshold: warnings fail.
2
+ failure-threshold: warning
3
+ trustedRegistries:
4
+ - mcr.microsoft.com
5
+ - docker.io
6
+ ignored: []
@@ -0,0 +1,62 @@
1
+ # Three-layer wiring
2
+
3
+ Layer 1 (while coding): the editorconfig pack and the frontend lint pack.
4
+ Layer 2 (commit + CI): this folder — deterministic, zero-token checks.
5
+ Layer 3 (PR review): SonarQube gate plus the stack_code_review skill,
6
+ scoped by its Layer discipline section to judgment findings only.
7
+
8
+ ## Hooks by moment
9
+
10
+ Hooks are thin dispatchers — one small script per git moment, all logic in
11
+ `tools/zh.py` (the same granular/composite split as the commands):
12
+
13
+ | Hook | Runs | Purpose |
14
+ |---|---|---|
15
+ | `pre-commit` | `zh check --staged` | Fast staged checks: secrets, guide tags, format/lint on staged files, health when pins change |
16
+ | `commit-msg` | `zh msg` | ST-GIT-02 Conventional Commits (`ZH_MSG=warn` to only warn, `off` to skip) |
17
+ | `pre-push` | `zh pr --skip test` | Full check + build before anything leaves the machine (`ZH_PREPUSH_TESTS=1` adds tests) |
18
+ | `post-merge` | advisory | Warns when dependency files changed so restore/`npm ci` is not forgotten |
19
+
20
+ `ZH_HOOKS=off` skips the blocking hooks for one command. Hooks are a local
21
+ mirror, never the authority: `--no-verify` exists, so CI remains the hard
22
+ gate. Install with `git config core.hooksPath .githooks` (zh adopt does
23
+ the copying).
24
+
25
+ ## Adopt
26
+
27
+ 1. Copy `.githooks/pre-commit`, `.gitleaks.toml`, `.hadolint.yaml`,
28
+ `.github/actionlint.yaml`, `.github/workflows/quality.yml` into the repo.
29
+ 2. Copy `validate_guide_tags.py` and `check_package_health.py` into
30
+ `tools/`, plus the generalized guide as `tools/GENERALIZED_STYLE_GUIDE.md`
31
+ (the validator's default search path) or pass `--generalized`.
32
+ 3. Enable the hook: `git config core.hooksPath .githooks`.
33
+ 4. Install local tools: gitleaks, actionlint, hadolint (versions pinned in
34
+ the workflow: gitleaks 8.30.1, actionlint 1.7.12, hadolint 2.15.1 —
35
+ checked 2026-12-02). Missing tools are skipped locally with a hint;
36
+ CI always enforces.
37
+ 5. Set repo secrets: `NUGET_PRIVATE_FEED_API_KEY`, and `SONAR_TOKEN` when
38
+ the Sonar step is enabled. Actions are pinned by commit SHA
39
+ (checkout v7.0.1, setup-dotnet v6.1.0, setup-node v7.1.0).
40
+ 6. Performance budgets (ST-FE-PERF-01): `budget.json` holds starter
41
+ Lighthouse budgets (LCP 2.5s, CLS 0.1, TBT 200ms, script 300KB);
42
+ wire with Lighthouse CI per route and treat breaches as findings.
43
+
44
+ ## What runs where
45
+
46
+ | Check | Commit hook | CI |
47
+ |---|---|---|
48
+ | gitleaks (staged / full history) | staged | full |
49
+ | Style-guide tag validator | when guide staged | always |
50
+ | Health gate | when pins change | always |
51
+ | dotnet format verify | staged .cs | whole solution |
52
+ | ESLint / Stylelint | staged files | whole app |
53
+ | actionlint + S7636 grep | when workflows staged | always |
54
+ | hadolint (ST-BUILD-06) | when Dockerfile staged | always |
55
+ | Build + tests + locked restore | — | always |
56
+ | npm audit high/critical | — | always |
57
+
58
+ Verified 2026-12-02: actionlint clean on quality.yml; hadolint flags
59
+ root/unpinned Dockerfiles and passes the non-root sample; gitleaks
60
+ catches a staged secret; the hook blocks an expired bypass and a staged
61
+ secret, and passes a clean commit. (The sandbox git wrapper disables
62
+ repo hooks, so the hook script was exercised directly — same code path.)
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "path": "/*",
4
+ "timings": [
5
+ { "metric": "largest-contentful-paint", "budget": 2500 },
6
+ { "metric": "cumulative-layout-shift", "budget": 0.1 },
7
+ { "metric": "total-blocking-time", "budget": 200 }
8
+ ],
9
+ "resourceSizes": [
10
+ { "resourceType": "script", "budget": 300 },
11
+ { "resourceType": "total", "budget": 1200 }
12
+ ]
13
+ }
14
+ ]
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env python3
2
+ """Enforce ST-FMT-13/14/15: human characters only.
3
+
4
+ Code files: printable ASCII plus tab/newline/carriage-return. Any other
5
+ codepoint is reported with its Unicode name (smart quotes, dashes, emoji,
6
+ homoglyphs, zero-width and bidi controls all fail).
7
+
8
+ Every text file (documentation included): invisible and control characters
9
+ fail - zero-width, BOM, bidi controls, non-breaking space, soft hyphen,
10
+ C0/C1 controls other than tab/newline/carriage-return.
11
+
12
+ Usage: check_characters.py [--allow GLOB ...] [PATH ...]
13
+ With no PATH, scans the current directory tree (skipping .git, node_modules,
14
+ bin, obj, dist). Exit 1 when anything is flagged.
15
+ """
16
+ import argparse
17
+ import fnmatch
18
+ import pathlib
19
+ import sys
20
+ import unicodedata
21
+
22
+ CODE_EXTS = {
23
+ ".cs", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py", ".json",
24
+ ".yml", ".yaml", ".csproj", ".props", ".targets", ".sln", ".css",
25
+ ".scss", ".html", ".xml", ".sh", ".ps1", ".editorconfig", ".toml",
26
+ }
27
+ TEXT_EXTS = CODE_EXTS | {".md", ".txt", ".rst"}
28
+ SKIP_DIRS = {".git", "node_modules", "bin", "obj", "dist", "__pycache__", ".venv", "artifacts", "htmlcov"}
29
+
30
+ INVISIBLE = (
31
+ set(range(0x200B, 0x2010)) # zero-width + directional marks
32
+ | set(range(0x202A, 0x202F)) # bidi embeddings/overrides
33
+ | set(range(0x2060, 0x2065)) # word joiner + invisible operators
34
+ | set(range(0x2066, 0x206A)) # bidi isolates
35
+ | set(range(0xFE00, 0xFE10)) # variation selectors
36
+ | {0xFEFF, 0x00A0, 0x00AD, 0x180E, 0xFFFE, 0xFFFF}
37
+ )
38
+
39
+
40
+ def char_problem(ch, strict_ascii):
41
+ cp = ord(ch)
42
+ if cp in (0x09, 0x0A, 0x0D):
43
+ return None
44
+ if cp < 0x20 or cp == 0x7F or 0x80 <= cp <= 0x9F:
45
+ return "control character"
46
+ if cp in INVISIBLE:
47
+ return "invisible or bidi character"
48
+ if strict_ascii and cp > 0x7E:
49
+ return "non-ASCII in code"
50
+ return None
51
+
52
+
53
+ def check_file(path, strict_ascii):
54
+ findings = []
55
+ try:
56
+ text = path.read_text(encoding="utf-8")
57
+ except (UnicodeDecodeError, OSError) as exc:
58
+ return [(str(path), 0, 0, f"unreadable as UTF-8: {exc}")]
59
+ for lineno, line in enumerate(text.split("\n"), 1):
60
+ for col, ch in enumerate(line, 1):
61
+ problem = char_problem(ch, strict_ascii)
62
+ if problem:
63
+ name = unicodedata.name(ch, "UNNAMED")
64
+ findings.append((str(path), lineno, col,
65
+ f"U+{ord(ch):04X} {name} ({problem})"))
66
+ return findings
67
+
68
+
69
+ def iter_files(roots):
70
+ for root in roots:
71
+ p = pathlib.Path(root)
72
+ if p.is_file():
73
+ yield p
74
+ continue
75
+ for f in sorted(p.rglob("*")):
76
+ if f.is_file() and not (set(f.parts) & SKIP_DIRS):
77
+ yield f
78
+
79
+
80
+ def main(argv=None):
81
+ ap = argparse.ArgumentParser(description="ST-FMT-13/14/15 character check")
82
+ ap.add_argument("paths", nargs="*", default=["."])
83
+ ap.add_argument("--allow", action="append", default=[],
84
+ help="glob of code files exempt from strict ASCII (ST-FMT-15)")
85
+ args = ap.parse_args(argv)
86
+ findings = []
87
+ checked = 0
88
+ for f in iter_files(args.paths):
89
+ ext = f.suffix.lower()
90
+ if ext not in TEXT_EXTS and f.name != ".editorconfig":
91
+ continue
92
+ checked += 1
93
+ strict = ext in CODE_EXTS and not any(
94
+ fnmatch.fnmatch(str(f), pat) or fnmatch.fnmatch(f.name, pat)
95
+ for pat in args.allow)
96
+ findings.extend(check_file(f, strict))
97
+ for path, line, col, msg in findings:
98
+ print(f"{path}:{line}:{col}: {msg}")
99
+ print(f"checked {checked} file(s), {len(findings)} finding(s)")
100
+ return 1 if findings else 0
101
+
102
+
103
+ if __name__ == "__main__":
104
+ sys.exit(main())