@style-contract/binary-win32-x64 0.8.0 → 0.9.1
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.
- package/README.md +16 -10
- package/package.json +1 -1
- package/style-contract.exe +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# StyleContract
|
|
2
2
|
|
|
3
|
-
StyleContract is a fast, standalone Rust CLI that verifies the contract between TypeScript CSS Module references and CSS/SCSS declarations. It detects missing symbols, unused classes and `:export` keys, empty style rules,
|
|
3
|
+
StyleContract is a fast, standalone Rust CLI that verifies the contract between TypeScript CSS Module references and CSS/SCSS declarations. It detects missing symbols, unused classes and `:export` keys, empty style rules, class leaks from Sass imports, optional naming mismatches, and dynamic accesses that cannot be checked safely.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -48,6 +48,7 @@ Available options:
|
|
|
48
48
|
Naming convention (default: none)
|
|
49
49
|
--source <PATH> Source folder (default: ./src)
|
|
50
50
|
--output <minimal|rich> Output style (default: rich)
|
|
51
|
+
--print-only-errors[=BOOL] Print errors without printing warnings
|
|
51
52
|
--config <PATH> JSON5 configuration file (auto: ./style-contract.json)
|
|
52
53
|
--exclude <PATH> Excluded folder; repeat as needed
|
|
53
54
|
--include <PATH> Re-include a folder below an exclusion
|
|
@@ -56,7 +57,7 @@ Available options:
|
|
|
56
57
|
--tsconfig <PATH> tsconfig used for paths aliases (default: ./tsconfig.json)
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
CLI paths are resolved from the working directory. Paths in a config file are resolved from that file's directory. Include and exclude folders must exist beneath the source folder. A tsconfig is optional when no aliases are needed.
|
|
60
|
+
CLI paths are resolved from the working directory. Paths in a config file are resolved from that file's directory. Include and exclude folders must exist beneath the source folder. A tsconfig is optional when no aliases are needed. Each tsconfig `paths` replacement is resolved relative to the config that declares it, including mappings inherited through `extends`. StyleContract does not use `baseUrl`; migrate stylesheet aliases that rely on it to explicit `paths` mappings.
|
|
60
61
|
|
|
61
62
|
With no explicit `--config`, StyleContract automatically loads `./style-contract.json` when it exists. Use `--config` to select another file. JSON5 comments and trailing commas are supported regardless of the filename extension:
|
|
62
63
|
|
|
@@ -64,6 +65,7 @@ With no explicit `--config`, StyleContract automatically loads `./style-contract
|
|
|
64
65
|
{
|
|
65
66
|
convention: "camel-to-kebab",
|
|
66
67
|
output: "rich",
|
|
68
|
+
printOnlyErrors: false,
|
|
67
69
|
source: "./src",
|
|
68
70
|
exclude: ["./src/generated"],
|
|
69
71
|
include: [],
|
|
@@ -74,12 +76,13 @@ With no explicit `--config`, StyleContract automatically loads `./style-contract
|
|
|
74
76
|
"unused-dependent-class": "warning",
|
|
75
77
|
"naming-convention-global": "off",
|
|
76
78
|
"empty-rule": "warning",
|
|
77
|
-
"
|
|
79
|
+
"class-leak": "warning",
|
|
80
|
+
"leaked-class-usage": "warning",
|
|
78
81
|
},
|
|
79
82
|
}
|
|
80
83
|
```
|
|
81
84
|
|
|
82
|
-
Explicit CLI values replace matching config values. Supplying any CLI entries for `--exclude`, `--include`, or `--rule` replaces that configured collection. `--ignore-exports=false` can disable
|
|
85
|
+
Explicit CLI values replace matching config values. Supplying any CLI entries for `--exclude`, `--include`, or `--rule` replaces that configured collection. `--ignore-exports=false` and `--print-only-errors=false` can disable values enabled by the config.
|
|
83
86
|
|
|
84
87
|
Supported rules:
|
|
85
88
|
|
|
@@ -91,9 +94,12 @@ Supported rules:
|
|
|
91
94
|
- `naming-convention-global`
|
|
92
95
|
- `dynamic-reference`
|
|
93
96
|
- `empty-rule`
|
|
94
|
-
- `
|
|
97
|
+
- `class-leak`
|
|
98
|
+
- `leaked-class-usage`
|
|
95
99
|
|
|
96
|
-
All enabled rules are errors except `naming-convention-local`, `naming-convention-global`, `dynamic-reference`, `empty-rule`, and `
|
|
100
|
+
All enabled rules are errors except `naming-convention-local`, `naming-convention-global`, `dynamic-reference`, `empty-rule`, `class-leak`, and `leaked-class-usage`, which are warnings. Naming-convention rules do not emit findings in `none` mode. `unused-dependent-class` is disabled by default; when enabled, it verifies that classes declared in same-element compound selectors are used together with a complete prerequisite class path in one JSX `className` expression or `clsx(...)` call. `empty-rule` reports selector blocks that contain only whitespace or comments; empty `:export` and structural at-rule blocks are not reported.
|
|
101
|
+
|
|
102
|
+
`class-leak` reports a CSS Module's direct `@use`, `@forward`, and `@import` dependencies when the imported file declares classes. This includes ordinary stylesheets as well as other CSS Modules, because those classes are emitted into the importing module. `leaked-class-usage` reports TS/TSX references that rely on one of those leaked classes. Such references work at runtime, so they are not also reported as `missing-symbol`, and the source declaration counts as used. Keep shared Sass dependencies class-free; move shared classes into an explicit CSS Module and import that module independently from the TS or TSX file.
|
|
97
103
|
|
|
98
104
|
### Targeted suppressions
|
|
99
105
|
|
|
@@ -131,15 +137,15 @@ style-contract --convention camel-to-kebab \
|
|
|
131
137
|
|
|
132
138
|
Diagnostics follow `path:line:column severity rule message`. Exit code `0` means no errors, `1` means rule errors were found, and `2` means configuration or analysis failed.
|
|
133
139
|
|
|
134
|
-
Rich output uses compiler-style diagnostics, terminal colors, linked-looking source locations, compact per-source error/warning totals, and a final total across all affected files. Use `--output minimal` for the original single-line format. Colors are disabled when output is redirected or the `NO_COLOR` environment variable is set.
|
|
140
|
+
Rich output uses compiler-style diagnostics, terminal colors, linked-looking source locations, compact per-source error/warning totals, and a final total across all affected files. Use `--output minimal` for the original single-line format. Use `--print-only-errors` to hide warnings from either report without disabling their analysis. Colors are disabled when output is redirected or the `NO_COLOR` environment variable is set.
|
|
135
141
|
|
|
136
142
|
## Static-analysis boundary
|
|
137
143
|
|
|
138
|
-
The MVP supports `.ts`, `.tsx`, `.css`, and `.scss`, default or namespace CSS Module imports, relative imports, tsconfig `
|
|
144
|
+
The MVP supports `.ts`, `.tsx`, `.css`, and `.scss`, default or namespace CSS Module imports, relative imports, tsconfig `paths`, dot and literal bracket access, and static destructuring. `baseUrl` resolution is not supported; define non-relative stylesheet aliases with `compilerOptions.paths`. It recognizes literal class selectors, nested literal SCSS selectors, empty selector blocks, `:export` blocks, CSS Modules `:global`/`:local` functions and blocks, Sass `@use`/`@forward`/`@import` dependencies, Sass `@extend`, and same-file or relative-file CSS Modules `composes` references.
|
|
139
145
|
|
|
140
146
|
Classes in `.module.css` and `.module.scss` are local by default. Classes in other stylesheets are global by default. With an explicit convention, global classes are checked against the warning-level global convention rule, but are not CSS Module exports and therefore do not participate in missing or unused checks.
|
|
141
147
|
|
|
142
|
-
Dynamic Sass-generated selectors and computed accesses such as `styles[name]` produce warnings. Because their complete usage cannot be proven, unused-symbol findings are suppressed for that stylesheet. StyleContract detects
|
|
148
|
+
Dynamic Sass-generated selectors and computed accesses such as `styles[name]` produce warnings. Because their complete usage cannot be proven, unused-symbol findings are suppressed for that stylesheet. StyleContract detects direct class leaks from resolvable Sass dependencies and recognizes their statically referenced classes, but it does not evaluate Sass or follow transitive Sass imports. Sass evaluation and `composes` evaluation remain outside the MVP.
|
|
143
149
|
|
|
144
150
|
## Development
|
|
145
151
|
|
|
@@ -154,5 +160,5 @@ cargo build --release
|
|
|
154
160
|
|
|
155
161
|
Releases are published from version tags. Before the first release, create or claim the `@style-contract` organization on npm, grant the publisher access to it, and add an npm automation token to the GitHub repository as the `NPM_TOKEN` Actions secret.
|
|
156
162
|
|
|
157
|
-
Keep the version in `package.json`, `Cargo.toml`, `Cargo.lock`, and every platform package dependency identical. The release verifier enforces this. Push a tag matching that version, such as `v0.
|
|
163
|
+
Keep the version in `package.json`, `Cargo.toml`, `Cargo.lock`, and every platform package dependency identical. The release verifier enforces this. Push a tag matching that version, such as `v0.9.1`; the release workflow builds and publishes all eight platform packages before publishing `style-contract`.
|
|
158
164
|
|
package/package.json
CHANGED
package/style-contract.exe
CHANGED
|
Binary file
|