@cerios/sparta-lint-rules 0.0.1 → 0.0.2
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/LICENSE +7 -7
- package/README.md +46 -30
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/oxlint.cjs +1 -1
- package/dist/oxlint.d.cts +1 -1
- package/dist/oxlint.d.mts +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/{plugin-types-CgeW0cQl.d.cts → plugin-types-CXFDQLJF.d.cts} +2 -1
- package/dist/{plugin-types-CgeW0cQl.d.mts → plugin-types-CXFDQLJF.d.mts} +2 -1
- package/dist/{rules-BSRYNh4F.mjs → rules-D94N3gGx.mjs} +850 -171
- package/dist/rules-D94N3gGx.mjs.map +1 -0
- package/dist/{rules-COk7kmEU.cjs → rules-T_C5segG.cjs} +850 -171
- package/dist/rules-T_C5segG.cjs.map +1 -0
- package/dist/settings.d.cts +5 -1
- package/dist/settings.d.mts +5 -1
- package/package.json +1 -1
- package/dist/rules-BSRYNh4F.mjs.map +0 -1
- package/dist/rules-COk7kmEU.cjs.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
Copyright © 2026 Cerios
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
-
|
|
6
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
-
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright © 2026 Cerios
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
8
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -50,15 +50,16 @@ Register the plugin with `jsPlugins` and enable the rules you want:
|
|
|
50
50
|
"rules": {
|
|
51
51
|
"sparta/architecture-boundaries": "error",
|
|
52
52
|
"sparta/class-matches-filename": "warn",
|
|
53
|
+
"sparta/director-composes-builders": "warn",
|
|
53
54
|
"sparta/expect-from-support": "error",
|
|
54
55
|
"sparta/file-naming": "warn",
|
|
55
56
|
"sparta/lines-between-class-members": "warn",
|
|
57
|
+
"sparta/member-ordering": "warn",
|
|
56
58
|
"sparta/no-direct-construction-in-tests": "error",
|
|
57
59
|
"sparta/no-expect-in-tests": "error",
|
|
58
60
|
"sparta/no-hard-waits": "error",
|
|
59
61
|
"sparta/no-nested-polling": "error",
|
|
60
62
|
"sparta/padding-lines": "warn",
|
|
61
|
-
"sparta/private-members-last": "warn",
|
|
62
63
|
"sparta/step-placeholders": "error",
|
|
63
64
|
"sparta/step-required": "warn"
|
|
64
65
|
}
|
|
@@ -84,8 +85,10 @@ The rules recognise files by their path, so they rely on the SPARTA folder conve
|
|
|
84
85
|
```text
|
|
85
86
|
<project>/
|
|
86
87
|
├── sparta/
|
|
87
|
-
│ ├── api/ # area: api, database, ui or
|
|
88
|
+
│ ├── api/ # area: api, database, ui, mobile or desktop
|
|
88
89
|
│ │ ├── common/ # shared within the area
|
|
90
|
+
│ │ ├── builders/ # *-builder.ts, test data builders shared by the area's groups
|
|
91
|
+
│ │ ├── directors/ # *-director.ts, compose several builders
|
|
89
92
|
│ │ └── <group>/ # e.g. orders
|
|
90
93
|
│ │ ├── clients/ # *-client.ts
|
|
91
94
|
│ │ ├── services/ # *-service.ts
|
|
@@ -93,8 +96,9 @@ The rules recognise files by their path, so they rely on the SPARTA folder conve
|
|
|
93
96
|
│ │ ├── asserters/ # *-asserter.ts
|
|
94
97
|
│ │ └── scenarios/ # *-scenario.ts
|
|
95
98
|
│ ├── database/<group>/ # repositories/, services/, steppers/, asserters/, scenarios/, ...
|
|
96
|
-
│ ├── ui/<group>/ # pages/, components/,
|
|
99
|
+
│ ├── ui/<group>/ # pages/, components/, steppers/, asserters/, scenarios/
|
|
97
100
|
│ ├── mobile/<group>/ # like ui, with screens/ (*-screen.ts) in place of pages/
|
|
101
|
+
│ ├── desktop/<group>/ # like ui, with windows/ (*-window.ts) in place of pages/, for Windows apps
|
|
98
102
|
│ ├── scenarios/ # cross-area scenarios
|
|
99
103
|
│ ├── fixtures/ # Playwright fixtures that wire everything up
|
|
100
104
|
│ ├── common/ # shared, area-independent code
|
|
@@ -103,7 +107,7 @@ The rules recognise files by their path, so they rely on the SPARTA folder conve
|
|
|
103
107
|
└── framework/ # framework tests; never checked
|
|
104
108
|
```
|
|
105
109
|
|
|
106
|
-
Imports through the `@sparta/*` and `@tests/*` path aliases are resolved to `<project>/sparta/` and `<project>/tests
|
|
110
|
+
Imports through the `@sparta/*` and `@tests/*` path aliases are resolved to `<project>/sparta/` and `<project>/tests/`, and the `paths` and `baseUrl` of your `tsconfig.json` are followed as well (see [import resolution](#import-resolution)). Files elsewhere are not affected by the path-based rules.
|
|
107
111
|
|
|
108
112
|
---
|
|
109
113
|
|
|
@@ -118,17 +122,17 @@ Without configuration, the rules use the SPARTA names shown above. If your proje
|
|
|
118
122
|
|
|
119
123
|
The standard names keep working next to yours. The layer rules, isolation and re-export checks themselves are not configurable. To switch a check off, use the linter itself (rule severity, `ignores`, overrides), where it stays visible.
|
|
120
124
|
|
|
121
|
-
| Setting | Default | What it does | Used by
|
|
122
|
-
| ---------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
123
|
-
| `root` | nearest folder with a `package.json` | Project root: aliases resolve against it, and only paths below it are matched. A relative path resolves against the folder the linter runs in. | all path-based rules
|
|
124
|
-
| `folders` | `{ sparta: "sparta", tests: "tests" }` | Names of the two top-level folders. Replaces the defaults. | all path-based rules
|
|
125
|
-
| `areas` | `api`, `database`, `mobile`, `ui`
|
|
126
|
-
| `layers` | `pages`, `steppers`, `services`, ... | Extra layer folders, each following a standard layer folder (its layer rules and file suffix): `{ "page-objects": "pages" }`. | `architecture-boundaries`, `file-naming`, `class-matches-filename`, `step-required` |
|
|
127
|
-
| `aliases` | `@sparta/*` → `sparta`, `@tests/*` → `tests` | Extra path aliases
|
|
128
|
-
| `supportModule` | `@sparta/support` | The module `expect` must come from. Replaces the default. | `expect-from-support`
|
|
129
|
-
| `pollingMethods` | `toPass`, `toPassAndReturn`, `poll`, `pollAndReturn` | Extra retrying methods, called as `x.method(callback)` or `x(callback).method()`. | `no-nested-polling`
|
|
130
|
-
| `stepDecorators` | `step` | Extra decorators that count as `@step`. | `step-required`, `step-placeholders`
|
|
131
|
-
| `expectNames` | `expect`, `expectly…` | Extra assertion functions that tests must not call. | `no-expect-in-tests`
|
|
125
|
+
| Setting | Default | What it does | Used by |
|
|
126
|
+
| ---------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
127
|
+
| `root` | nearest folder with a `package.json` | Project root: aliases resolve against it, and only paths below it are matched. A relative path resolves against the folder the linter runs in. | all path-based rules |
|
|
128
|
+
| `folders` | `{ sparta: "sparta", tests: "tests" }` | Names of the two top-level folders. Replaces the defaults. | all path-based rules |
|
|
129
|
+
| `areas` | `api`, `database`, `desktop`, `mobile`, `ui` | Extra area folders, each following a standard area: `{ web: "ui" }`. Each area folder is still isolated from the others. | all path-based rules |
|
|
130
|
+
| `layers` | `pages`, `steppers`, `services`, ... | Extra layer folders, each following a standard layer folder (its layer rules and file suffix): `{ "page-objects": "pages" }`. | `architecture-boundaries`, `file-naming`, `class-matches-filename`, `step-required`, `no-direct-construction-in-tests`, `director-composes-builders` |
|
|
131
|
+
| `aliases` | `@sparta/*` → `sparta`, `@tests/*` → `tests` | Extra path aliases pointing to `sparta` or `tests`: `{ "@app/*": "sparta" }`. Only needed when they are not in your tsconfig `paths`. | `architecture-boundaries`, `no-nested-polling`, `no-direct-construction-in-tests`, `director-composes-builders` |
|
|
132
|
+
| `supportModule` | `@sparta/support` | The module `expect` must come from. Replaces the default. | `expect-from-support` |
|
|
133
|
+
| `pollingMethods` | `toPass`, `toPassAndReturn`, `poll`, `pollAndReturn` | Extra retrying methods, called as `x.method(callback)` or `x(callback).method()`. | `no-nested-polling` |
|
|
134
|
+
| `stepDecorators` | `step` | Extra decorators that count as `@step`. | `step-required`, `step-placeholders` |
|
|
135
|
+
| `expectNames` | `expect`, `expectly…` | Extra assertion functions that tests must not call. | `no-expect-in-tests` |
|
|
132
136
|
|
|
133
137
|
A mistake in the settings stops the lint run with a clear message, so a typo can't silently weaken the checks:
|
|
134
138
|
|
|
@@ -185,25 +189,37 @@ The project root is the nearest folder, from the linted file upwards, that conta
|
|
|
185
189
|
|
|
186
190
|
Only the part of a file's path below the root is matched against the SPARTA folder names. A checkout inside a folder named `tests` or `sparta` therefore doesn't change how files are classified, and files outside the root aren't checked by the path-based rules.
|
|
187
191
|
|
|
192
|
+
### Import resolution
|
|
193
|
+
|
|
194
|
+
The rules that follow imports (`architecture-boundaries`, `no-direct-construction-in-tests`, `no-nested-polling`) resolve them as TypeScript does, in this order:
|
|
195
|
+
|
|
196
|
+
1. relative imports (`./`, `../`);
|
|
197
|
+
2. `compilerOptions.paths` of the nearest `tsconfig.json` above the linted file, including what it `extends` (local files and packages). Of several targets, the first that exists is used, so `"@pages/*": ["sparta/ui/shop/pages/*"]` is checked like the folder it points to;
|
|
198
|
+
3. the `@sparta/*` and `@tests/*` aliases and `settings.sparta.aliases`, against the [project root](#project-root);
|
|
199
|
+
4. `compilerOptions.baseUrl`, for imports such as `sparta/ui/shop/pages/cart-page`, only when that file exists, so packages are never mistaken for project files.
|
|
200
|
+
|
|
201
|
+
Package imports are not checked. A `tsconfig.json` that can't be read, or whose `extends` can't be found, stops the lint run with a message naming the file. Only `tsconfig.json` is looked up; project references are not followed.
|
|
202
|
+
|
|
188
203
|
---
|
|
189
204
|
|
|
190
205
|
## Rules
|
|
191
206
|
|
|
192
|
-
| Rule | Description
|
|
193
|
-
| -------------------------------------------------------------------------------- |
|
|
194
|
-
| [architecture-boundaries](docs/rules/architecture-boundaries.md) | Enforce the SPARTA layer and isolation boundaries between imports
|
|
195
|
-
| [class-matches-filename](docs/rules/class-matches-filename.md) | One class per layer file, named after the file
|
|
196
|
-
| [
|
|
197
|
-
| [
|
|
198
|
-
| [
|
|
199
|
-
| [
|
|
200
|
-
| [
|
|
201
|
-
| [no-
|
|
202
|
-
| [no-
|
|
203
|
-
| [
|
|
204
|
-
| [
|
|
205
|
-
| [
|
|
206
|
-
| [step-
|
|
207
|
+
| Rule | Description | Recommended | Fix |
|
|
208
|
+
| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ----------- | --- |
|
|
209
|
+
| [architecture-boundaries](docs/rules/architecture-boundaries.md) | Enforce the SPARTA layer and isolation boundaries between imports | error | |
|
|
210
|
+
| [class-matches-filename](docs/rules/class-matches-filename.md) | One class per layer file, named after the file | warn | |
|
|
211
|
+
| [director-composes-builders](docs/rules/director-composes-builders.md) | A director composes several builders; a single-builder director belongs on the builder | warn | |
|
|
212
|
+
| [expect-from-support](docs/rules/expect-from-support.md) | Import `expect` from the support module inside `sparta/` | error | 🔧 |
|
|
213
|
+
| [file-naming](docs/rules/file-naming.md) | Files in a layer folder are kebab-case and end with the layer suffix | warn | |
|
|
214
|
+
| [lines-between-class-members](docs/rules/lines-between-class-members.md) | Blank line after multi-line methods; none between overloads | warn | 🔧 |
|
|
215
|
+
| [member-ordering](docs/rules/member-ordering.md) | Properties, constructor, methods; static first; public before private | warn | |
|
|
216
|
+
| [no-direct-construction-in-tests](docs/rules/no-direct-construction-in-tests.md) | No constructing layer classes (`new OrdersStepper()`) in tests; use fixtures | error | |
|
|
217
|
+
| [no-expect-in-tests](docs/rules/no-expect-in-tests.md) | No `expect` in tests; checks belong in steppers and asserters | error | |
|
|
218
|
+
| [no-hard-waits](docs/rules/no-hard-waits.md) | No `waitForTimeout` or `setTimeout` sleeps | error | |
|
|
219
|
+
| [no-nested-polling](docs/rules/no-nested-polling.md) | No poll inside a poll callback, also through calls into other files | error | |
|
|
220
|
+
| [padding-lines](docs/rules/padding-lines.md) | Blank lines after imports, around functions and object methods; none between overloads | warn | 🔧 |
|
|
221
|
+
| [step-placeholders](docs/rules/step-placeholders.md) | Validate `@step` description placeholders against the method parameters | error | 🔧 |
|
|
222
|
+
| [step-required](docs/rules/step-required.md) | Public methods of steppers, asserters and scenarios need `@step` | warn | |
|
|
207
223
|
|
|
208
224
|
`@step` refers to [`@cerios/playwright-step-decorator`](https://github.com/CeriosTesting/playwright-step-decorator).
|
|
209
225
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const require_rules = require("./rules-
|
|
1
|
+
const require_rules = require("./rules-T_C5segG.cjs");
|
|
2
2
|
// src/index.ts
|
|
3
3
|
const plugin = {
|
|
4
4
|
meta: {
|
|
5
5
|
name: require_rules.PLUGIN_NAME,
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.2"
|
|
7
7
|
},
|
|
8
8
|
rules: require_rules.rules,
|
|
9
9
|
configs: {}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as recommendedRules, r as rules, t as PLUGIN_NAME } from "./rules-
|
|
1
|
+
import { n as recommendedRules, r as rules, t as PLUGIN_NAME } from "./rules-D94N3gGx.mjs";
|
|
2
2
|
// src/index.ts
|
|
3
3
|
const plugin = {
|
|
4
4
|
meta: {
|
|
5
5
|
name: PLUGIN_NAME,
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.2"
|
|
7
7
|
},
|
|
8
8
|
rules,
|
|
9
9
|
configs: {}
|
package/dist/oxlint.cjs
CHANGED
package/dist/oxlint.d.cts
CHANGED
package/dist/oxlint.d.mts
CHANGED
package/dist/oxlint.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
declare const rules: {
|
|
2
2
|
"architecture-boundaries": import("@oxlint/plugins").CreateRule;
|
|
3
3
|
"class-matches-filename": import("@oxlint/plugins").CreateRule;
|
|
4
|
+
"director-composes-builders": import("@oxlint/plugins").CreateRule;
|
|
4
5
|
"expect-from-support": import("@oxlint/plugins").CreateRule;
|
|
5
6
|
"file-naming": import("@oxlint/plugins").CreateRule;
|
|
6
7
|
"lines-between-class-members": import("@oxlint/plugins").CreateRule;
|
|
8
|
+
"member-ordering": import("@oxlint/plugins").CreateRule;
|
|
7
9
|
"no-direct-construction-in-tests": import("@oxlint/plugins").CreateRule;
|
|
8
10
|
"no-expect-in-tests": import("@oxlint/plugins").CreateRule;
|
|
9
11
|
"no-hard-waits": import("@oxlint/plugins").CreateRule;
|
|
10
12
|
"no-nested-polling": import("@oxlint/plugins").CreateRule;
|
|
11
13
|
"padding-lines": import("@oxlint/plugins").CreateRule;
|
|
12
|
-
"private-members-last": import("@oxlint/plugins").CreateRule;
|
|
13
14
|
"step-placeholders": import("@oxlint/plugins").CreateRule;
|
|
14
15
|
"step-required": import("@oxlint/plugins").CreateRule;
|
|
15
16
|
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
declare const rules: {
|
|
2
2
|
"architecture-boundaries": import("@oxlint/plugins").CreateRule;
|
|
3
3
|
"class-matches-filename": import("@oxlint/plugins").CreateRule;
|
|
4
|
+
"director-composes-builders": import("@oxlint/plugins").CreateRule;
|
|
4
5
|
"expect-from-support": import("@oxlint/plugins").CreateRule;
|
|
5
6
|
"file-naming": import("@oxlint/plugins").CreateRule;
|
|
6
7
|
"lines-between-class-members": import("@oxlint/plugins").CreateRule;
|
|
8
|
+
"member-ordering": import("@oxlint/plugins").CreateRule;
|
|
7
9
|
"no-direct-construction-in-tests": import("@oxlint/plugins").CreateRule;
|
|
8
10
|
"no-expect-in-tests": import("@oxlint/plugins").CreateRule;
|
|
9
11
|
"no-hard-waits": import("@oxlint/plugins").CreateRule;
|
|
10
12
|
"no-nested-polling": import("@oxlint/plugins").CreateRule;
|
|
11
13
|
"padding-lines": import("@oxlint/plugins").CreateRule;
|
|
12
|
-
"private-members-last": import("@oxlint/plugins").CreateRule;
|
|
13
14
|
"step-placeholders": import("@oxlint/plugins").CreateRule;
|
|
14
15
|
"step-required": import("@oxlint/plugins").CreateRule;
|
|
15
16
|
};
|