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,47 @@
1
+ <Project>
2
+
3
+ <!-- Generalized Style Guide v1.1 - shared build settings (SG-BUILD, ST-DEP).
4
+ Copy to the repository root. Project files override single values
5
+ where the project guide records an OVERRIDE/BYPASS tag. -->
6
+
7
+ <PropertyGroup>
8
+ <!-- Libraries that multi-target override this in their csproj
9
+ (for example net8.0;net10.0). -->
10
+ <TargetFramework>net10.0</TargetFramework>
11
+ <LangVersion>latest</LangVersion>
12
+ <Nullable>enable</Nullable>
13
+ <ImplicitUsings>enable</ImplicitUsings>
14
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
15
+ <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
16
+ <AnalysisLevel>latest-recommended</AnalysisLevel>
17
+ <AnalysisLevelSecurity>latest-all</AnalysisLevelSecurity>
18
+ <GenerateDocumentationFile>true</GenerateDocumentationFile>
19
+ <Deterministic>true</Deterministic>
20
+ <ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
21
+
22
+ <!-- ST-DEP-07: lock files. Applications keep this on and CI restores
23
+ in locked mode. Libraries may set it false in their csproj. -->
24
+ <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
25
+
26
+ <!-- ST-DEP-08: NuGet audit, transitive included; high/critical fail. -->
27
+ <NuGetAuditMode>all</NuGetAuditMode>
28
+ <NuGetAuditLevel>moderate</NuGetAuditLevel>
29
+ <WarningsAsErrors>$(WarningsAsErrors);NU1903;NU1904</WarningsAsErrors>
30
+
31
+ <!-- ST-ASYNC-03 / ST-FMT-10: libraries treat ConfigureAwait and
32
+ missing XML docs as errors; applications keep them as warnings
33
+ (CS1591 is silenced for non-packable projects below). -->
34
+ <WarningsAsErrors Condition="'$(IsPackable)' == 'true'">$(WarningsAsErrors);CA2007;CS1591</WarningsAsErrors>
35
+ <NoWarn Condition="'$(IsPackable)' != 'true'">$(NoWarn);CS1591</NoWarn>
36
+ </PropertyGroup>
37
+
38
+ <!-- Analyzers run the Sonar rule set in the build, so repeats fail
39
+ locally instead of on the PR quality gate. Versions live in
40
+ Directory.Packages.props with their health-gate evidence. -->
41
+ <ItemGroup>
42
+ <PackageReference Include="SonarAnalyzer.CSharp" PrivateAssets="all" />
43
+ <PackageReference Include="Meziantou.Analyzer" PrivateAssets="all" />
44
+ <PackageReference Include="Roslynator.Analyzers" PrivateAssets="all" />
45
+ </ItemGroup>
46
+
47
+ </Project>
@@ -0,0 +1,16 @@
1
+ <Project>
2
+
3
+ <!-- Test-project relaxations (ST-TEST-10): no Async-suffix or XML-doc
4
+ requirements in tests, no ConfigureAwait rule. CA1861 and IDE0028
5
+ stay on in tests - they are mined Sonar repeats there.
6
+ IsTestProject is set by Microsoft.NET.Test.Sdk; test projects that
7
+ do not reference it set <IsTestProject>true</IsTestProject> in
8
+ their csproj. The tests/.editorconfig carries the same relaxations
9
+ for editor-time diagnostics. -->
10
+
11
+ <PropertyGroup Condition="'$(IsTestProject)' == 'true'">
12
+ <GenerateDocumentationFile>false</GenerateDocumentationFile>
13
+ <NoWarn>$(NoWarn);CA1707;CS1591;CA2007;S2325;CA1822</NoWarn>
14
+ </PropertyGroup>
15
+
16
+ </Project>
@@ -0,0 +1,29 @@
1
+ <Project>
2
+
3
+ <!-- Central Package Management (ST-BUILD-01). One version per package.
4
+ Every third-party pin carries its health-gate evidence (ST-DEP-04):
5
+ checked date, last release, last commit, licence. A warn verdict
6
+ adds one decision line with a review date (ST-DEP-03). -->
7
+
8
+ <PropertyGroup>
9
+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
10
+ <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
11
+ </PropertyGroup>
12
+
13
+ <ItemGroup Label="Analyzers">
14
+ <!-- checked 2026-12-02 | last release 2026 | active | LGPL-3.0 (build-time only, does not ship) -->
15
+ <PackageVersion Include="SonarAnalyzer.CSharp" Version="10.37.0.15768" />
16
+ <!-- checked 2026-12-02 | last release 2026 | active | MIT -->
17
+ <PackageVersion Include="Meziantou.Analyzer" Version="3.0.344" />
18
+ <!-- checked 2026-12-02 | last release 2026 | active | Apache-2.0 -->
19
+ <PackageVersion Include="Roslynator.Analyzers" Version="5.0.1" />
20
+ </ItemGroup>
21
+
22
+ <ItemGroup Label="House libraries (ST-LIB)">
23
+ <!-- checked 2026-12-02 | house package | MIT -->
24
+ <PackageVersion Include="ZhEaIsNsAaBn.LayerResponse" Version="0.9.0" />
25
+ <!-- Add the rest of the package map as the project adopts them, one
26
+ evidence comment per pin. -->
27
+ </ItemGroup>
28
+
29
+ </Project>
@@ -0,0 +1,141 @@
1
+ # EditorConfig pack — Generalized Style Guide v1.2
2
+
3
+ Build-time enforcement for the Generalized Style Guide, built from the
4
+ SonarQube history of the house projects (mined 2026-12-02: Essentials,
5
+ Libraries.V1, MarketPulse, Sql — open plus resolved issues). The point:
6
+ every repeated Sonar finding fails the local build or the editor, before
7
+ the PR quality gate ever sees it.
8
+
9
+ ## Size thresholds (ST-PAT-09 to ST-PAT-13, guide v1.2)
10
+
11
+ Hard caps, enforced at build: method 50 lines (`MA0051` with
12
+ `maximum_lines_per_method = 50`, plus `S138`), file 1000 lines (`S104`), cognitive
13
+ complexity 15 (`S3776`), cyclomatic complexity 10 (`CA1502`), parameters 7
14
+ (`S107`), nesting depth 3 (`S134`). Class 500 lines has no direct analyzer
15
+ rule; it is enforced by the review skill's responsibility check
16
+ (ST-PAT-09/ST-PAT-10) and the file cap. Tests keep the caps as suggestions
17
+ (long arrange blocks move into builders, ST-TEST-08).
18
+
19
+ ## Adopt
20
+
21
+ Copy to the repository root: `.editorconfig`, `Directory.Build.props`,
22
+ `Directory.Packages.props`, `Directory.Build.targets`, `nuget.config`,
23
+ `global.json`. Copy `tests/.editorconfig` into the tests folder. Then:
24
+
25
+ 1. Restore once and commit the generated `packages.lock.json` files.
26
+ 2. In CI, restore with `dotnet restore --locked-mode`.
27
+ 3. Record any deviation as an `OVERRIDE`/`BYPASS` tag in the project
28
+ guide (validate with the bypass-tag validator), never as a silent
29
+ local edit to these files.
30
+
31
+ Library vs application switches are automatic: packable projects treat
32
+ CA2007 and CS1591 as errors; applications silence CS1591. Test projects
33
+ relax CA1707/CS1591/CA2007 through `Directory.Build.targets` and
34
+ `tests/.editorconfig` — CA1861 and IDE0028 stay on in tests on purpose.
35
+
36
+ ## Repeated Sonar findings and where they now fire
37
+
38
+ Counts are open + resolved across the four mined projects. PR-only rounds
39
+ (CA1861, IDE0028, S7636 on Essentials PR #8) are marked PR.
40
+
41
+ | Sonar rule | Count | Pre-PR enforcement |
42
+ |---|---|---|
43
+ | S2306 async/await as identifiers | 82 | SonarAnalyzer in build, error |
44
+ | S6966 awaitable method should be used | 51 | SonarAnalyzer + CA1849, warning |
45
+ | IDE0022 expression body | 20 | editorconfig style, warning |
46
+ | S3776 cognitive complexity | 16 | SonarAnalyzer (threshold 15 = ST-TEST-08) |
47
+ | S3358 nested ternary | 16 | SonarAnalyzer, warning |
48
+ | CA1031 catch general exception | 16 | Roslyn, warning (ST-ERR-03) |
49
+ | S107 too many parameters | 14 | SonarAnalyzer (threshold 7 = ST-TEST-08) |
50
+ | S4136 overloads grouped | 12 | SonarAnalyzer, suggestion |
51
+ | IDE0028 collection initialization | 8 + PR | editorconfig style, warning |
52
+ | S2326 unused type parameters | 8 | SonarAnalyzer, warning |
53
+ | IDE0007 use var | 7 | editorconfig style, warning |
54
+ | S101 PascalCase types | 6 | naming rules + S101, warning |
55
+ | S1192 duplicated string literals | 6 | SonarAnalyzer, suggestion |
56
+ | S1135 TODO tags | 5 | suggestion; TODOs need issues (ST-FMT-12) |
57
+ | S3267 loops to LINQ | 4 | SonarAnalyzer, suggestion |
58
+ | S2743 static fields in generic types | 4 | SonarAnalyzer, warning |
59
+ | S8969 redundant null-forgiving | 4 | SonarAnalyzer, warning |
60
+ | S2365 properties copying collections | 4 | SonarAnalyzer, warning |
61
+ | S3871 exception types public | 3 | SonarAnalyzer, warning |
62
+ | SYSLIB1045 GeneratedRegex | 3 | Roslyn, warning |
63
+ | docker:S6471 containers run as root | 3 | Dockerfile snippet below (ST-BUILD-06) |
64
+ | S3011 reflection accessibility | 2 | SonarAnalyzer, warning |
65
+ | S2436 too many generic parameters | 2 | SonarAnalyzer, suggestion |
66
+ | CA1716 keyword-conflicting identifiers | 2 | Roslyn, warning |
67
+ | S6562 DateTimeKind on new DateTime | 2 | SonarAnalyzer, warning (ST-TIME-03) |
68
+ | S6444 regex timeout | 2 | SonarAnalyzer, warning |
69
+ | S3220 params overload ambiguity | 2 | SonarAnalyzer, suggestion |
70
+ | S127 loop stop condition | 2 | SonarAnalyzer, warning |
71
+ | S3604 redundant member initializer | 2 | SonarAnalyzer, suggestion |
72
+ | CA1304 specify CultureInfo | 2 | Roslyn, warning |
73
+ | githubactions:S7636 secrets in run | 2 + PR | CI snippet below |
74
+ | githubactions:S8233/S8264 job permissions | 3 | CI snippet below |
75
+ | CA1861 constant array arguments | PR | Roslyn, warning (also in tests) |
76
+ | S125 commented-out code | 1 | SonarAnalyzer, warning (ST-FMT-11) |
77
+ | S2245 insecure Random | 1 | SonarAnalyzer + CA5394, warning |
78
+ | S2178 short-circuit logic | 1 | SonarAnalyzer, warning |
79
+ | S3218 inner class shadowing | 1 | SonarAnalyzer, warning |
80
+ | S3875 operator== on reference types | 1 | SonarAnalyzer, warning |
81
+ | S2583/S2589 gratuitous conditions | 2 | SonarAnalyzer, warning |
82
+ | S1751 single-iteration loops | 1 | SonarAnalyzer, warning |
83
+ | S1481 unused local | 1 | SonarAnalyzer, warning |
84
+ | S3398 private method placement | 1 | SonarAnalyzer, suggestion |
85
+ | S4035 IEquatable classes sealed | 1 | SonarAnalyzer, suggestion |
86
+ | S3878 arrays for params | 1 | SonarAnalyzer, suggestion |
87
+ | S6672 logger type mismatch | 1 | SonarAnalyzer, warning |
88
+ | IDE0021 expression-body constructor | 1 | editorconfig style, warning |
89
+ | CS9236 lambda binding | 1 | compiler warning (already build-visible) |
90
+
91
+ Not build-enforceable, handled elsewhere: new-code coverage (ST-GATE-01)
92
+ is a test-writing discipline — run the local scanner before push
93
+ (ST-GATE-02):
94
+
95
+ ```text
96
+ dotnet sonarscanner begin /k:"<project-key>" /d:sonar.host.url="https://sonar.hassanragai.dev" /d:sonar.token="$SONAR_TOKEN"
97
+ dotnet build
98
+ dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
99
+ ```
100
+
101
+ ## CI and Docker snippets (S7636, S8233, S8264, S6471)
102
+
103
+ Secrets reach steps through `env:`, never expanded inside `run:`.
104
+ Permissions are declared per job, least-privilege. Third-party actions
105
+ are pinned by commit SHA.
106
+
107
+ ```yaml
108
+ jobs:
109
+ build:
110
+ runs-on: ubuntu-latest
111
+ permissions:
112
+ contents: read
113
+ packages: write
114
+ steps:
115
+ - uses: actions/checkout@<sha>
116
+ - name: Restore
117
+ env:
118
+ NUGET_TOKEN: ${{ secrets.NUGET_PRIVATE_FEED_API_KEY }}
119
+ run: dotnet restore --locked-mode
120
+ ```
121
+
122
+ Containers run as a non-root user (ST-BUILD-06):
123
+
124
+ ```dockerfile
125
+ FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
126
+ USER $APP_UID
127
+ ```
128
+
129
+ ## ReSharper/Rider profile items
130
+
131
+ Spaced parentheses (`if ( x )`), spaced attribute brackets and
132
+ column-aligned `=` (ST-FMT-01/02) have no Visual Studio/Roslyn
133
+ editorconfig keys. The pack carries best-effort `resharper_*` keys;
134
+ the exact profile lives in Rider settings. Reviews flag deviations at
135
+ LOW/nitpick only where tooling does not catch them.
136
+
137
+ ## Versioning
138
+
139
+ Pack version tracks the guide: v1.1 (2026-12-02). Analyzer pins carry
140
+ health-gate evidence in `Directory.Packages.props`; re-check quarterly
141
+ (ST-DEP-05).
@@ -0,0 +1,7 @@
1
+ {
2
+ "sdk": {
3
+ "version": "10.0.100",
4
+ "rollForward": "latestFeature",
5
+ "allowPrerelease": false
6
+ }
7
+ }
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- ST-LIB-05 / ST-DEP-09: feeds are pinned and source-mapped.
3
+ Credentials come from environment variables in CI and from the
4
+ user-level config locally — never literal secrets in this file. -->
5
+ <configuration>
6
+ <packageSources>
7
+ <clear />
8
+ <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
9
+ <add key="github" value="https://nuget.pkg.github.com/ZHEAISNSAABN/index.json" />
10
+ </packageSources>
11
+ <packageSourceMapping>
12
+ <packageSource key="github">
13
+ <package pattern="ZhEaIsNsAaBn.*" />
14
+ </packageSource>
15
+ <packageSource key="nuget.org">
16
+ <package pattern="*" />
17
+ </packageSource>
18
+ </packageSourceMapping>
19
+ </configuration>
@@ -0,0 +1,29 @@
1
+ # SlopThreshold Python lint (layer 1): mirrors the guide caps so smells
2
+ # are caught while coding, not in Sonar. ST-PAT-11: complexity <= 15,
3
+ # parameters <= 7. Security subset mirrors ST-SEC.
4
+ line-length = 120
5
+ target-version = "py310"
6
+
7
+ [lint]
8
+ select = [
9
+ "C901", # cyclomatic complexity (proxy for the cognitive cap)
10
+ "PLR0913", # too many arguments
11
+ "PLR0912", # too many branches
12
+ "PLR0915", # too many statements
13
+ "B", # bugbear: likely bugs
14
+ "SIM", # simplifications
15
+ "S105", "S106", "S107", "S108", "S110", "S112", "S301", "S307",
16
+ "S310", "S324", "S501", "S602", "S603", "S605", "S607", "S701",
17
+ ]
18
+ ignore = ["S603"] # subprocess with list args is the house pattern; S602/S605 still banned
19
+
20
+ [lint.mccabe]
21
+ max-complexity = 15
22
+
23
+ [lint.pylint]
24
+ max-args = 7
25
+ max-branches = 15
26
+ max-statements = 60
27
+
28
+ [lint.per-file-ignores]
29
+ "tools/test_*.py" = ["S101", "PLR0913", "PLR0915", "S105", "S106", "S108"]
@@ -0,0 +1,10 @@
1
+ {
2
+ "S101": "House stricter: PascalCase types enforced as warning (ST naming rules); Sonar profile MINOR/suggestion.",
3
+ "S1481": "House stricter: unused locals are warnings locally (TreatWarningsAsErrors makes them build errors); Sonar MINOR.",
4
+ "S6444": "House stricter: regex timeouts required (ReDoS defence, ST-SEC); Sonar MINOR.",
5
+ "S6672": "House stricter: logger generic type must match enclosing type; Sonar MINOR.",
6
+ "S8969": "House stricter: redundant null-forgiving operators flagged as warning; Sonar MINOR.",
7
+ "S104": "House cap (ST-PAT-11): file <= 1000 lines enforced locally; rule inactive in Sonar profile.",
8
+ "S134": "House cap (ST-PAT-12): nesting <= 3 enforced locally; rule inactive in Sonar profile.",
9
+ "S138": "House cap (ST-PAT-11): method <= 50 lines enforced locally; rule inactive in Sonar profile."
10
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "printWidth": 120,
3
+ "singleQuote": true,
4
+ "trailingComma": "all",
5
+ "tabWidth": 2,
6
+ "semi": true
7
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "extends": [
3
+ "stylelint-config-standard-scss"
4
+ ],
5
+ "rules": {
6
+ "property-disallowed-list": [
7
+ "margin-left",
8
+ "margin-right",
9
+ "padding-left",
10
+ "padding-right",
11
+ "left",
12
+ "right",
13
+ "border-left",
14
+ "border-right",
15
+ "border-left-width",
16
+ "border-right-width",
17
+ "border-left-color",
18
+ "border-right-color",
19
+ "border-left-style",
20
+ "border-right-style",
21
+ "border-top-left-radius",
22
+ "border-top-right-radius",
23
+ "border-bottom-left-radius",
24
+ "border-bottom-right-radius"
25
+ ],
26
+ "declaration-property-value-disallowed-list": {
27
+ "text-align": [
28
+ "left",
29
+ "right"
30
+ ],
31
+ "float": [
32
+ "left",
33
+ "right"
34
+ ],
35
+ "clear": [
36
+ "left",
37
+ "right"
38
+ ]
39
+ },
40
+ "declaration-no-important": true,
41
+ "color-no-hex": true,
42
+ "selector-class-pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$",
43
+ "custom-property-pattern": "^zh-[a-z0-9-]+$",
44
+ "declaration-property-unit-disallowed-list": {
45
+ "/^font-size$/": [
46
+ "px"
47
+ ]
48
+ }
49
+ },
50
+ "overrides": [
51
+ {
52
+ "files": [
53
+ "**/tokens/**/*.scss",
54
+ "**/styles/_tokens*.scss",
55
+ "**/theme/**/*.scss"
56
+ ],
57
+ "rules": {
58
+ "color-no-hex": null,
59
+ "declaration-property-unit-disallowed-list": null,
60
+ "color-hex-length": null
61
+ }
62
+ }
63
+ ]
64
+ }
@@ -0,0 +1,64 @@
1
+ # Frontend lint pack — Generalized Style Guide v1.1, Part 2
2
+
3
+ Build-time enforcement for the 62 frontend rules, mirroring the .NET pack:
4
+ REQUIRED rules are errors, DEFAULT rules are warnings, and CI runs with
5
+ `--max-warnings=0` so both fail the build.
6
+
7
+ ## Adopt
8
+
9
+ Copy `eslint.config.mjs`, `tsconfig.json`, `tsconfig.base.json`,
10
+ `tsconfig.app.json`, `tsconfig.spec.json`, `.stylelintrc.json`,
11
+ `.prettierrc.json` to the workspace root and merge the `devDependencies`
12
+ and scripts from `package.json`. Set the selector prefix in
13
+ `eslint.config.mjs` to the app prefix (libraries keep `zh`, ST-FE-NG-02).
14
+ Enable `@angular-eslint/template/i18n` once the app's i18n is wired
15
+ (ST-FE-I18N-03).
16
+
17
+ ## Rule mapping (selection)
18
+
19
+ | Guide rule | Enforcement |
20
+ |---|---|
21
+ | ST-FE-TS-01 strict TS | tsconfig.base.json flags |
22
+ | ST-FE-TS-02 no any | no-explicit-any, no-non-null-assertion |
23
+ | ST-FE-TS-03 naming | naming-convention (no I-prefix types) |
24
+ | ST-FE-TS-04 no Dto suffix | no-restricted-syntax selectors |
25
+ | ST-FE-TS-05 observables end in $ | rxjs-x/finnish |
26
+ | ST-FE-TS-06 no enum | no-restricted-syntax TSEnumDeclaration |
27
+ | ST-FE-TS-08 no default exports | no-restricted-syntax |
28
+ | ST-FE-API-05 no web-storage tokens | no-restricted-syntax MemberExpression |
29
+ | ST-FE-API-07 never swallow stream errors | rxjs-x/no-ignored-error |
30
+ | ST-FE-SEC-03 no eval | no-eval, no-new-func, no-implied-eval |
31
+ | ST-FE-SEC-05 npm audit gate | `npm run audit` in CI |
32
+ | ST-FE-FMT-01 Prettier 120/single | .prettierrc.json |
33
+ | ST-FE-FMT-02 ESLint correctness | no-floating-promises, eqeqeq, no-console, import-x/order |
34
+ | ST-FE-NG-03 OnPush | prefer-on-push (explicit pre-v22; v22 defaults) |
35
+ | ST-FE-NG-04 signal inputs/outputs | prefer-signals + decorator ban |
36
+ | ST-FE-NG-05 built-in control flow | template/prefer-control-flow |
37
+ | ST-FE-NG-07 subscribe discipline | rxjs-x/no-unsafe-takeuntil, no-floating-observables |
38
+ | ST-FE-NG-08 inject() | prefer-inject |
39
+ | ST-FE-A11Y-01..03 | templateAccessibility config |
40
+ | ST-FE-I18N-02 logical properties | Stylelint property/value disallowed lists |
41
+ | ST-FE-STYLE-01 tokens, no raw hex | color-no-hex (tokens folder exempt) |
42
+ | ST-FE-STYLE-03 no !important | declaration-no-important |
43
+ | ST-FE-STYLE-02 kebab classes, --zh-* | selector/custom-property patterns |
44
+
45
+ Review-only (no lint rule exists): envelope unwrapping (ST-FE-API-02),
46
+ generated API types (ST-FE-API-01 — enforce by generating into
47
+ `*.generated.ts`, which the config ignores), sanitizer bypass comments
48
+ (ST-FE-NG-13), CWV budgets (ST-FE-PERF-01 — Lighthouse CI in the wiring
49
+ pack).
50
+
51
+ ## Pins and the health gate (checked 2026-12-02)
52
+
53
+ eslint 10.16.0, typescript-eslint 8.74.0, angular-eslint 22.8.0,
54
+ eslint-plugin-import-x 4.18.1, eslint-plugin-rxjs-x 1.0.7,
55
+ stylelint 18.1.0, stylelint-config-standard-scss 18.0.0,
56
+ prettier 3.10.1, typescript 5.9.3 (typescript-eslint supports <6.1;
57
+ revisit when it allows TS 7). Two originals failed the gate and were
58
+ replaced: eslint-plugin-import (no ESLint 10 peer) and
59
+ eslint-plugin-rxjs (unmaintained since 2023) — import-x and rxjs-x are
60
+ the maintained forks. All MIT/Apache-2.0.
61
+
62
+ Verified 2026-12-02 on scratch samples: violating TS/component/template/
63
+ SCSS failed with the mapped rules; clean samples passed ESLint, Stylelint
64
+ and `tsc --noEmit`.
@@ -0,0 +1,108 @@
1
+ // Generalized Style Guide v1.2, Part 2 - ESLint flat config.
2
+ // Each rule names the guide rule it enforces. Severity: REQUIRED -> error,
3
+ // DEFAULT -> warn (CI treats warnings as failures via --max-warnings=0).
4
+ import tseslint from 'typescript-eslint';
5
+ import angular from 'angular-eslint';
6
+ import importPlugin from 'eslint-plugin-import-x';
7
+ import rxjs from 'eslint-plugin-rxjs-x';
8
+
9
+ export default tseslint.config(
10
+ {
11
+ ignores: ['dist/**', 'coverage/**', '**/*.generated.ts', 'src/environments/**'],
12
+ },
13
+ {
14
+ files: ['**/*.ts'],
15
+ extends: [
16
+ ...tseslint.configs.strictTypeChecked,
17
+ ...tseslint.configs.stylisticTypeChecked,
18
+ ...angular.configs.tsRecommended,
19
+ ],
20
+ plugins: { 'import-x': importPlugin, 'rxjs-x': rxjs },
21
+ languageOptions: {
22
+ parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname },
23
+ },
24
+ rules: {
25
+ // ST-FE-TS-10 / ST-PAT-11 size thresholds (function 50, file 1000,
26
+ // complexity 10, nesting 3, parameters 7)
27
+ // ST-FMT-13/14 human characters (full check: zh chars)
28
+ 'no-irregular-whitespace': 'error',
29
+ 'max-lines-per-function': ['error', { max: 50, skipBlankLines: true, skipComments: true }],
30
+ 'max-lines': ['error', { max: 1000, skipBlankLines: true, skipComments: true }],
31
+ complexity: ['error', 10],
32
+ 'max-depth': ['error', 3],
33
+ 'max-params': ['error', 7],
34
+ // ST-FE-TS-02 / ST-FE-FMT-02
35
+ '@typescript-eslint/no-explicit-any': 'error',
36
+ '@typescript-eslint/no-non-null-assertion': 'warn',
37
+ '@typescript-eslint/no-floating-promises': 'error',
38
+ '@typescript-eslint/no-misused-promises': 'error',
39
+ '@typescript-eslint/await-thenable': 'error',
40
+ '@typescript-eslint/explicit-module-boundary-types': 'warn',
41
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
42
+ 'no-console': ['warn', { allow: ['warn', 'error'] }],
43
+ // ST-FE-TS-03 naming
44
+ '@typescript-eslint/naming-convention': [
45
+ 'warn',
46
+ { selector: 'typeLike', format: ['PascalCase'], custom: { regex: '^I[A-Z]', match: false } },
47
+ { selector: 'variable', format: ['camelCase', 'UPPER_CASE'] },
48
+ { selector: 'parameter', format: ['camelCase'] },
49
+ { selector: 'enumMember', format: ['PascalCase'] },
50
+ ],
51
+ // ST-FE-TS-07
52
+ '@typescript-eslint/prefer-readonly': 'warn',
53
+ // ST-FE-TS-04 (no Dto suffix), ST-FE-TS-06 (no enum), ST-FE-TS-08 (no default exports),
54
+ // ST-FE-API-05 (no web storage for tokens), ST-FE-NG-04 (no @Input/@Output decorators)
55
+ 'no-restricted-syntax': [
56
+ 'error',
57
+ { selector: 'TSEnumDeclaration', message: 'ST-FE-TS-06: prefer union string literals or as const objects over enum.' },
58
+ { selector: 'ExportDefaultDeclaration', message: 'ST-FE-TS-08: no default exports.' },
59
+ { selector: 'TSTypeAliasDeclaration[id.name=/Dto$/]', message: 'ST-FE-TS-04: name transport models *Request/*Response/*Settings, never *Dto.' },
60
+ { selector: 'TSInterfaceDeclaration[id.name=/Dto$/]', message: 'ST-FE-TS-04: name transport models *Request/*Response/*Settings, never *Dto.' },
61
+ { selector: 'MemberExpression[object.name=/^(localStorage|sessionStorage)$/]', message: 'ST-FE-API-05: auth tokens never live in web storage; use an HttpOnly cookie or BFF.' },
62
+ { selector: 'Decorator[expression.callee.name=/^(Input|Output)$/]', message: 'ST-FE-NG-04: use signal inputs/outputs (input(), output(), model()), not decorators.' },
63
+ ],
64
+ // ST-FE-SEC-03
65
+ 'no-eval': 'error',
66
+ 'no-new-func': 'error',
67
+ 'no-implied-eval': 'error',
68
+ // ST-FE-FMT-02 import ordering
69
+ 'import-x/order': ['warn', { groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], 'newlines-between': 'always' }],
70
+ // ST-FE-NG-07
71
+ 'rxjs-x/no-unsafe-takeuntil': 'warn',
72
+ 'rxjs-x/no-floating-observables': 'warn',
73
+ // ST-FE-API-07 stream errors are never swallowed
74
+ 'rxjs-x/no-ignored-error': 'warn',
75
+ // ST-FE-TS-05 observables end in $
76
+ 'rxjs-x/finnish': ['warn', { functions: false, parameters: true, properties: true, variables: true }],
77
+ // ST-FE-NG-01/02/03
78
+ '@angular-eslint/prefer-standalone': 'error',
79
+ '@angular-eslint/prefer-on-push-component-change-detection': 'error',
80
+ '@angular-eslint/component-selector': ['warn', { type: 'element', prefix: 'zh', style: 'kebab-case' }],
81
+ '@angular-eslint/directive-selector': ['warn', { type: 'attribute', prefix: 'zh', style: 'camelCase' }],
82
+ // ST-FE-NG-04/07 signal APIs; ST-FE-NG-08 inject(); ST-FE-NG-06 host metadata
83
+ '@angular-eslint/prefer-signals': 'error',
84
+ '@angular-eslint/no-uncalled-signals': 'error',
85
+ '@angular-eslint/prefer-inject': 'warn',
86
+ '@angular-eslint/prefer-host-metadata-property': 'warn',
87
+ '@angular-eslint/component-class-suffix': 'warn',
88
+ '@angular-eslint/directive-class-suffix': 'warn',
89
+ '@angular-eslint/no-input-rename': 'warn',
90
+ '@angular-eslint/no-output-rename': 'warn',
91
+ '@angular-eslint/use-lifecycle-interface': 'warn',
92
+ },
93
+ },
94
+ {
95
+ files: ['**/*.html'],
96
+ extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility],
97
+ rules: {
98
+ // ST-FE-NG-05 built-in control flow
99
+ '@angular-eslint/template/prefer-control-flow': 'error',
100
+ '@angular-eslint/template/use-track-by-function': 'warn',
101
+ '@angular-eslint/template/eqeqeq': 'error',
102
+ '@angular-eslint/template/no-negated-async': 'warn',
103
+ '@angular-eslint/template/banana-in-box': 'error',
104
+ // ST-FE-I18N-03 hard-coded text (enable per app once i18n is wired)
105
+ '@angular-eslint/template/i18n': 'off',
106
+ },
107
+ },
108
+ );
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "frontend-lint-pack",
3
+ "private": true,
4
+ "scripts": {
5
+ "lint": "eslint . --max-warnings=0",
6
+ "lint:styles": "stylelint \"src/**/*.{scss,css}\"",
7
+ "format:check": "prettier --check \"src/**/*.{ts,html,scss,json}\"",
8
+ "typecheck": "tsc --noEmit -p tsconfig.app.json",
9
+ "audit": "npm audit --audit-level=high"
10
+ },
11
+ "devDependencies": {
12
+ "angular-eslint": "22.8.0",
13
+ "eslint": "10.16.0",
14
+ "prettier": "3.10.1",
15
+ "stylelint": "18.1.0",
16
+ "stylelint-config-standard-scss": "18.0.0",
17
+ "typescript": "5.9.3",
18
+ "typescript-eslint": "8.74.0",
19
+ "eslint-plugin-import-x": "4.18.1",
20
+ "eslint-plugin-rxjs-x": "1.0.7",
21
+ "rxjs": "7.8.2"
22
+ }
23
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "./tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/out-tsc/app",
5
+ "types": []
6
+ },
7
+ "files": ["src/main.ts"],
8
+ "include": ["src/**/*.d.ts", "src/**/*.ts"],
9
+ "exclude": ["src/**/*.spec.ts"],
10
+ "angularCompilerOptions": {
11
+ "strictTemplates": true,
12
+ "strictInjectionParameters": true,
13
+ "strictInputAccessModifiers": true,
14
+ "strictDomEventTypes": true,
15
+ "strictLiteralTypes": true
16
+ }
17
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "strict": true,
8
+ "noUncheckedIndexedAccess": true,
9
+ "noImplicitOverride": true,
10
+ "exactOptionalPropertyTypes": true,
11
+ "noFallthroughCasesInSwitch": true,
12
+ "noImplicitReturns": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "isolatedModules": true,
15
+ "verbatimModuleSyntax": true,
16
+ "skipLibCheck": true,
17
+ "declaration": true,
18
+ "sourceMap": true
19
+ }
20
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "files": [],
3
+ "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.spec.json" }]
4
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/out-tsc/spec",
5
+ "types": ["vitest/globals", "node"]
6
+ },
7
+ "include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
8
+ }