@cerios/sparta-lint-rules 0.0.1 → 0.0.3

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 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
@@ -46,19 +46,21 @@ Register the plugin with `jsPlugins` and enable the rules you want:
46
46
 
47
47
  ```json
48
48
  {
49
+ "$schema": "./node_modules/@cerios/sparta-lint-rules/oxlintrc.schema.json",
49
50
  "jsPlugins": ["@cerios/sparta-lint-rules"],
50
51
  "rules": {
51
52
  "sparta/architecture-boundaries": "error",
52
53
  "sparta/class-matches-filename": "warn",
54
+ "sparta/director-composes-builders": "warn",
53
55
  "sparta/expect-from-support": "error",
54
56
  "sparta/file-naming": "warn",
55
57
  "sparta/lines-between-class-members": "warn",
58
+ "sparta/member-ordering": "warn",
56
59
  "sparta/no-direct-construction-in-tests": "error",
57
60
  "sparta/no-expect-in-tests": "error",
58
61
  "sparta/no-hard-waits": "error",
59
62
  "sparta/no-nested-polling": "error",
60
63
  "sparta/padding-lines": "warn",
61
- "sparta/private-members-last": "warn",
62
64
  "sparta/step-placeholders": "error",
63
65
  "sparta/step-required": "warn"
64
66
  }
@@ -68,13 +70,42 @@ Register the plugin with `jsPlugins` and enable the rules you want:
68
70
  ### ESLint (flat config)
69
71
 
70
72
  ```js
71
- import sparta from "@cerios/sparta-lint-rules";
72
73
  // eslint.config.mjs
74
+ import sparta from "@cerios/sparta-lint-rules";
73
75
  import tsParser from "@typescript-eslint/parser";
76
+ import { defineConfig } from "eslint/config";
77
+
78
+ export default defineConfig({ files: ["**/*.ts"], languageOptions: { parser: tsParser } }, sparta.configs.recommended);
79
+ ```
80
+
81
+ ### Editor autocompletion
82
+
83
+ Your editor suggests the sparta rules and the [`settings.sparta`](#configuration) keys and values, and flags wrong values, while you write the config:
84
+
85
+ | Config file | Rule names | `settings.sparta` | How |
86
+ | --------------------------- | ---------- | ----------------- | ----------------------------------------------------------------------------------------- |
87
+ | `oxlint.config.ts` | ✅ | ✅ | Works once you import `@cerios/sparta-lint-rules/oxlint` and use oxlint's `defineConfig`. |
88
+ | `.oxlintrc.json` | ✅ | ✅ | Point `$schema` at `./node_modules/@cerios/sparta-lint-rules/oxlintrc.schema.json`. |
89
+ | `eslint.config.(m)js / .ts` | | ✅ (ESLint 10+) | Works once you import the plugin and use `defineConfig` from `eslint/config`. |
90
+
91
+ `oxlintrc.schema.json` extends oxlint's own `configuration_schema.json`, so oxlint's options keep their completion too. It expects `oxlint` in the same `node_modules` folder. Without `defineConfig`, annotate the ESLint config with `/** @type {import("eslint").Linter.Config[]} */`. ESLint 9 types `settings` as a plain record that a plugin can't extend; there, add `satisfies SpartaSettings` (from `@cerios/sparta-lint-rules/settings`) to `settings.sparta` in a TypeScript config. ESLint has no way for a plugin to add rule names to its types without making every rules object in your project list them, so those aren't completed there.
92
+
93
+ #### Combining with other schemas
74
94
 
75
- export default [{ files: ["**/*.ts"], languageOptions: { parser: tsParser } }, sparta.configs.recommended];
95
+ `$schema` takes a single schema. To also use another plugin's schema, or your own, add a schema to your project that combines them with `allOf`, and point `$schema` at it:
96
+
97
+ ```json
98
+ {
99
+ "$schema": "http://json-schema.org/draft-07/schema#",
100
+ "allOf": [
101
+ { "$ref": "../node_modules/@cerios/sparta-lint-rules/oxlintrc.schema.json" },
102
+ { "$ref": "../node_modules/other-oxlint-plugin/oxlintrc.schema.json" }
103
+ ]
104
+ }
76
105
  ```
77
106
 
107
+ Each `$ref` is relative to the file it's written in. This example is `schemas/oxlintrc.json`, so `.oxlintrc.json` uses `"$schema": "./schemas/oxlintrc.json"`. A value must match every schema in `allOf`. This schema only describes the `sparta/*` rules and `settings.sparta`, so it accepts the rules and settings of other plugins.
108
+
78
109
  ---
79
110
 
80
111
  ## Project layout
@@ -84,26 +115,30 @@ The rules recognise files by their path, so they rely on the SPARTA folder conve
84
115
  ```text
85
116
  <project>/
86
117
  ├── sparta/
87
- │ ├── api/ # area: api, database, ui or mobile
88
- │ │ ├── common/ # shared within the area
118
+ │ ├── api/ # area: api, database, ui, mobile or desktop
119
+ │ │ ├── common/ # shared within the area; may hold builders/ and directors/
120
+ │ │ ├── builders/ # *-builder.ts, test data builders shared by the area's groups
121
+ │ │ ├── directors/ # *-director.ts, compose several builders
89
122
  │ │ └── <group>/ # e.g. orders
90
123
  │ │ ├── clients/ # *-client.ts
91
124
  │ │ ├── services/ # *-service.ts
92
125
  │ │ ├── steppers/ # *-stepper.ts
93
126
  │ │ ├── asserters/ # *-asserter.ts
94
- │ │ └── scenarios/ # *-scenario.ts
127
+ │ │ ├── scenarios/ # *-scenario.ts
128
+ │ │ └── builders/ # *-builder.ts (and directors/), private to the group
95
129
  │ ├── database/<group>/ # repositories/, services/, steppers/, asserters/, scenarios/, ...
96
- │ ├── ui/<group>/ # pages/, components/, builders/, directors/, steppers/, ...
130
+ │ ├── ui/<group>/ # pages/, components/, steppers/, asserters/, scenarios/
97
131
  │ ├── mobile/<group>/ # like ui, with screens/ (*-screen.ts) in place of pages/
132
+ │ ├── desktop/<group>/ # like ui, with windows/ (*-window.ts) in place of pages/, for Windows apps
98
133
  │ ├── scenarios/ # cross-area scenarios
99
134
  │ ├── fixtures/ # Playwright fixtures that wire everything up
100
- │ ├── common/ # shared, area-independent code
135
+ │ ├── common/ # shared, area-independent code; may hold builders/ and directors/
101
136
  │ └── support/ # expect with custom matchers, helpers
102
137
  └── tests/ # the tests themselves
103
138
  └── framework/ # framework tests; never checked
104
139
  ```
105
140
 
106
- Imports through the `@sparta/*` and `@tests/*` path aliases are resolved to `<project>/sparta/` and `<project>/tests/`. Files elsewhere are not affected by the path-based rules.
141
+ 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
142
 
108
143
  ---
109
144
 
@@ -118,17 +153,17 @@ Without configuration, the rules use the SPARTA names shown above. If your proje
118
153
 
119
154
  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
155
 
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` | Extra area folders, each following a standard area: `{ web: "ui" }`. Each area folder is still isolated from the others. | all path-based rules |
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, in tsconfig syntax, pointing to `sparta` or `tests`: `{ "@app/*": "sparta" }`. | `architecture-boundaries`, `no-nested-polling` |
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` |
156
+ | Setting | Default | What it does | Used by |
157
+ | ---------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
158
+ | `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 |
159
+ | `folders` | `{ sparta: "sparta", tests: "tests" }` | Names of the two top-level folders. Replaces the defaults. | all path-based rules |
160
+ | `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 |
161
+ | `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` |
162
+ | `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` |
163
+ | `supportModule` | `@sparta/support` | The module `expect` must come from. Replaces the default. | `expect-from-support` |
164
+ | `pollingMethods` | `toPass`, `toPassAndReturn`, `poll`, `pollAndReturn` | Extra retrying methods, called as `x.method(callback)` or `x(callback).method()`. | `no-nested-polling` |
165
+ | `stepDecorators` | `step` | Extra decorators that count as `@step`. | `step-required`, `step-placeholders` |
166
+ | `expectNames` | `expect`, `expectly…` | Extra assertion functions that tests must not call. | `no-expect-in-tests` |
132
167
 
133
168
  A mistake in the settings stops the lint run with a clear message, so a typo can't silently weaken the checks:
134
169
 
@@ -142,7 +177,6 @@ A name can't turn one SPARTA concept into another, so `areas: { ui: "api" }`, `a
142
177
 
143
178
  ```ts
144
179
  import sparta from "@cerios/sparta-lint-rules/oxlint";
145
- import type { SpartaSettings } from "@cerios/sparta-lint-rules/settings";
146
180
  import { defineConfig } from "oxlint";
147
181
 
148
182
  export default defineConfig({
@@ -153,7 +187,7 @@ export default defineConfig({
153
187
  layers: { "page-objects": "pages" },
154
188
  aliases: { "@app/*": "sparta" },
155
189
  supportModule: "@app/support",
156
- } satisfies SpartaSettings,
190
+ },
157
191
  },
158
192
  });
159
193
  ```
@@ -162,6 +196,7 @@ export default defineConfig({
162
196
 
163
197
  ```json
164
198
  {
199
+ "$schema": "./node_modules/@cerios/sparta-lint-rules/oxlintrc.schema.json",
165
200
  "jsPlugins": ["@cerios/sparta-lint-rules"],
166
201
  "settings": {
167
202
  "sparta": { "areas": { "web": "ui" } }
@@ -172,11 +207,11 @@ export default defineConfig({
172
207
  ### ESLint (flat config)
173
208
 
174
209
  ```js
175
- export default [
210
+ export default defineConfig(
176
211
  // ...
177
212
  sparta.configs.recommended,
178
- { settings: { sparta: { areas: { web: "ui" } } } },
179
- ];
213
+ { settings: { sparta: { areas: { web: "ui" } } } }
214
+ );
180
215
  ```
181
216
 
182
217
  ### Project root
@@ -185,25 +220,37 @@ The project root is the nearest folder, from the linted file upwards, that conta
185
220
 
186
221
  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
222
 
223
+ ### Import resolution
224
+
225
+ The rules that follow imports (`architecture-boundaries`, `no-direct-construction-in-tests`, `no-nested-polling`) resolve them as TypeScript does, in this order:
226
+
227
+ 1. relative imports (`./`, `../`);
228
+ 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;
229
+ 3. the `@sparta/*` and `@tests/*` aliases and `settings.sparta.aliases`, against the [project root](#project-root);
230
+ 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.
231
+
232
+ 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.
233
+
188
234
  ---
189
235
 
190
236
  ## Rules
191
237
 
192
- | Rule | Description | Recommended | Fix |
193
- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------- | --- |
194
- | [architecture-boundaries](docs/rules/architecture-boundaries.md) | Enforce the SPARTA layer and isolation boundaries between imports | error | |
195
- | [class-matches-filename](docs/rules/class-matches-filename.md) | One class per layer file, named after the file | warn | |
196
- | [expect-from-support](docs/rules/expect-from-support.md) | Import `expect` from the support module inside `sparta/` | error | 🔧 |
197
- | [file-naming](docs/rules/file-naming.md) | Files in a layer folder end with the layer suffix | warn | |
198
- | [lines-between-class-members](docs/rules/lines-between-class-members.md) | Blank line after every multi-line class member | warn | 🔧 |
199
- | [no-direct-construction-in-tests](docs/rules/no-direct-construction-in-tests.md) | No `new XStepper()` and friends in tests; use fixtures | error | |
200
- | [no-expect-in-tests](docs/rules/no-expect-in-tests.md) | No `expect` in tests; checks belong in steppers and asserters | error | |
201
- | [no-hard-waits](docs/rules/no-hard-waits.md) | No `waitForTimeout` or `setTimeout` sleeps | error | |
202
- | [no-nested-polling](docs/rules/no-nested-polling.md) | No poll inside a poll callback, also through calls into other files | error | |
203
- | [padding-lines](docs/rules/padding-lines.md) | Blank lines after imports, around functions and around object methods | warn | 🔧 |
204
- | [private-members-last](docs/rules/private-members-last.md) | Public methods above private methods | warn | |
205
- | [step-placeholders](docs/rules/step-placeholders.md) | Validate `@step` description placeholders against the method parameters | error | 🔧 |
206
- | [step-required](docs/rules/step-required.md) | Public methods of steppers, asserters and scenarios need `@step` | warn | |
238
+ | Rule | Description | Recommended | Fix |
239
+ | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ----------- | --- |
240
+ | [architecture-boundaries](docs/rules/architecture-boundaries.md) | Enforce the SPARTA layer and isolation boundaries between imports | error | |
241
+ | [class-matches-filename](docs/rules/class-matches-filename.md) | One class per layer file, named after the file | warn | |
242
+ | [director-composes-builders](docs/rules/director-composes-builders.md) | A director composes several builders; a single-builder director belongs on the builder | warn | |
243
+ | [expect-from-support](docs/rules/expect-from-support.md) | Import `expect` from the support module inside `sparta/` | error | 🔧 |
244
+ | [file-naming](docs/rules/file-naming.md) | Files in a layer folder are kebab-case and end with the layer suffix | warn | |
245
+ | [lines-between-class-members](docs/rules/lines-between-class-members.md) | Blank line after multi-line methods; none between overloads | warn | 🔧 |
246
+ | [member-ordering](docs/rules/member-ordering.md) | Properties, constructor, methods; static first; public before private | warn | |
247
+ | [no-direct-construction-in-tests](docs/rules/no-direct-construction-in-tests.md) | No constructing layer classes (`new OrdersStepper()`) in tests; use fixtures | error | |
248
+ | [no-expect-in-tests](docs/rules/no-expect-in-tests.md) | No `expect` in tests; checks belong in steppers and asserters | error | |
249
+ | [no-hard-waits](docs/rules/no-hard-waits.md) | No `waitForTimeout` or `setTimeout` sleeps | error | |
250
+ | [no-nested-polling](docs/rules/no-nested-polling.md) | No poll inside a poll callback, also through calls into other files | error | |
251
+ | [padding-lines](docs/rules/padding-lines.md) | Blank lines after imports, around functions and object methods; none between overloads | warn | 🔧 |
252
+ | [step-placeholders](docs/rules/step-placeholders.md) | Validate `@step` description placeholders against the method parameters | error | 🔧 |
253
+ | [step-required](docs/rules/step-required.md) | Public methods of steppers, asserters and scenarios need `@step` | warn | |
207
254
 
208
255
  `@step` refers to [`@cerios/playwright-step-decorator`](https://github.com/CeriosTesting/playwright-step-decorator).
209
256
 
@@ -0,0 +1,97 @@
1
+
2
+ /**
3
+ * The names a SPARTA project uses, and how `settings.sparta` extends them.
4
+ *
5
+ * Settings describe a project; they never relax the rules. A setting either maps a project's own name onto an
6
+ * existing SPARTA concept (so it gets all of that concept's checks) or adds names to detect (which only makes the
7
+ * rules stricter). Switching checks off is left to the linter config, where it stays visible.
8
+ */
9
+ type Area = "api" | "database" | "desktop" | "mobile" | "ui";
10
+ /** A top-level SPARTA folder that aliases can point to. */
11
+ type TopFolder = "sparta" | "tests";
12
+ /** The standard layer folders, with the layer the architecture rules know them as and their file name suffix. */
13
+ declare const LAYER_FOLDERS: {
14
+ readonly asserters: {
15
+ readonly layer: "asserter";
16
+ readonly suffix: "asserter";
17
+ };
18
+ readonly builders: {
19
+ readonly layer: "builder";
20
+ readonly suffix: "builder";
21
+ };
22
+ readonly clients: {
23
+ readonly layer: "client";
24
+ readonly suffix: "client";
25
+ };
26
+ readonly components: {
27
+ readonly layer: "component";
28
+ readonly suffix: "component";
29
+ };
30
+ readonly containers: {
31
+ readonly layer: "container";
32
+ };
33
+ readonly databases: {
34
+ readonly layer: "database";
35
+ };
36
+ readonly directors: {
37
+ readonly layer: "director";
38
+ readonly suffix: "director";
39
+ };
40
+ readonly factories: {
41
+ readonly suffix: "factory";
42
+ };
43
+ readonly pages: {
44
+ readonly layer: "page";
45
+ readonly suffix: "page";
46
+ };
47
+ readonly repositories: {
48
+ readonly layer: "repository";
49
+ readonly suffix: "repository";
50
+ };
51
+ readonly scenarios: {
52
+ readonly layer: "scenario";
53
+ readonly suffix: "scenario";
54
+ };
55
+ readonly screens: {
56
+ readonly layer: "screen";
57
+ readonly suffix: "screen";
58
+ };
59
+ readonly services: {
60
+ readonly layer: "service";
61
+ readonly suffix: "service";
62
+ };
63
+ readonly steppers: {
64
+ readonly layer: "stepper";
65
+ readonly suffix: "stepper";
66
+ };
67
+ readonly windows: {
68
+ readonly layer: "window";
69
+ readonly suffix: "window";
70
+ };
71
+ };
72
+ type LayerFolder = keyof typeof LAYER_FOLDERS;
73
+ /** Settings accepted under `settings.sparta`. Every key is optional; the defaults are the SPARTA standard. */
74
+ type SpartaSettings = {
75
+ /** Project root that the aliases resolve against. Default: the nearest folder with a `package.json`. */
76
+ root?: string;
77
+ /** Names of the top-level folders. Default: `{ sparta: "sparta", tests: "tests" }`. */
78
+ folders?: {
79
+ sparta?: string;
80
+ tests?: string;
81
+ };
82
+ /** Extra area folders, mapped to the standard area they follow, e.g. `{ web: "ui" }`. */
83
+ areas?: Record<string, Area>;
84
+ /** Extra layer folders, mapped to the standard layer folder they follow, e.g. `{ "page-objects": "pages" }`. */
85
+ layers?: Record<string, LayerFolder>;
86
+ /** Extra path aliases, mapped to the top-level folder they point to, e.g. `{ "@app/*": "sparta" }`. */
87
+ aliases?: Record<string, TopFolder>;
88
+ /** The module `expect` must be imported from inside the sparta folder. Default: `@sparta/support`. */
89
+ supportModule?: string;
90
+ /** Extra retrying methods, added to `toPass`, `toPassAndReturn`, `poll` and `pollAndReturn`. */
91
+ pollingMethods?: string[];
92
+ /** Extra step decorators, added to `step`. */
93
+ stepDecorators?: string[];
94
+ /** Extra assertion functions that tests must not call, added to `expect` and `expectly…`. */
95
+ expectNames?: string[];
96
+ };
97
+ export { TopFolder as i, LayerFolder as n, SpartaSettings as r, Area as t };
@@ -0,0 +1,97 @@
1
+
2
+ /**
3
+ * The names a SPARTA project uses, and how `settings.sparta` extends them.
4
+ *
5
+ * Settings describe a project; they never relax the rules. A setting either maps a project's own name onto an
6
+ * existing SPARTA concept (so it gets all of that concept's checks) or adds names to detect (which only makes the
7
+ * rules stricter). Switching checks off is left to the linter config, where it stays visible.
8
+ */
9
+ type Area = "api" | "database" | "desktop" | "mobile" | "ui";
10
+ /** A top-level SPARTA folder that aliases can point to. */
11
+ type TopFolder = "sparta" | "tests";
12
+ /** The standard layer folders, with the layer the architecture rules know them as and their file name suffix. */
13
+ declare const LAYER_FOLDERS: {
14
+ readonly asserters: {
15
+ readonly layer: "asserter";
16
+ readonly suffix: "asserter";
17
+ };
18
+ readonly builders: {
19
+ readonly layer: "builder";
20
+ readonly suffix: "builder";
21
+ };
22
+ readonly clients: {
23
+ readonly layer: "client";
24
+ readonly suffix: "client";
25
+ };
26
+ readonly components: {
27
+ readonly layer: "component";
28
+ readonly suffix: "component";
29
+ };
30
+ readonly containers: {
31
+ readonly layer: "container";
32
+ };
33
+ readonly databases: {
34
+ readonly layer: "database";
35
+ };
36
+ readonly directors: {
37
+ readonly layer: "director";
38
+ readonly suffix: "director";
39
+ };
40
+ readonly factories: {
41
+ readonly suffix: "factory";
42
+ };
43
+ readonly pages: {
44
+ readonly layer: "page";
45
+ readonly suffix: "page";
46
+ };
47
+ readonly repositories: {
48
+ readonly layer: "repository";
49
+ readonly suffix: "repository";
50
+ };
51
+ readonly scenarios: {
52
+ readonly layer: "scenario";
53
+ readonly suffix: "scenario";
54
+ };
55
+ readonly screens: {
56
+ readonly layer: "screen";
57
+ readonly suffix: "screen";
58
+ };
59
+ readonly services: {
60
+ readonly layer: "service";
61
+ readonly suffix: "service";
62
+ };
63
+ readonly steppers: {
64
+ readonly layer: "stepper";
65
+ readonly suffix: "stepper";
66
+ };
67
+ readonly windows: {
68
+ readonly layer: "window";
69
+ readonly suffix: "window";
70
+ };
71
+ };
72
+ type LayerFolder = keyof typeof LAYER_FOLDERS;
73
+ /** Settings accepted under `settings.sparta`. Every key is optional; the defaults are the SPARTA standard. */
74
+ type SpartaSettings = {
75
+ /** Project root that the aliases resolve against. Default: the nearest folder with a `package.json`. */
76
+ root?: string;
77
+ /** Names of the top-level folders. Default: `{ sparta: "sparta", tests: "tests" }`. */
78
+ folders?: {
79
+ sparta?: string;
80
+ tests?: string;
81
+ };
82
+ /** Extra area folders, mapped to the standard area they follow, e.g. `{ web: "ui" }`. */
83
+ areas?: Record<string, Area>;
84
+ /** Extra layer folders, mapped to the standard layer folder they follow, e.g. `{ "page-objects": "pages" }`. */
85
+ layers?: Record<string, LayerFolder>;
86
+ /** Extra path aliases, mapped to the top-level folder they point to, e.g. `{ "@app/*": "sparta" }`. */
87
+ aliases?: Record<string, TopFolder>;
88
+ /** The module `expect` must be imported from inside the sparta folder. Default: `@sparta/support`. */
89
+ supportModule?: string;
90
+ /** Extra retrying methods, added to `toPass`, `toPassAndReturn`, `poll` and `pollAndReturn`. */
91
+ pollingMethods?: string[];
92
+ /** Extra step decorators, added to `step`. */
93
+ stepDecorators?: string[];
94
+ /** Extra assertion functions that tests must not call, added to `expect` and `expectly…`. */
95
+ expectNames?: string[];
96
+ };
97
+ export { TopFolder as i, LayerFolder as n, SpartaSettings as r, Area as t };
package/dist/index.cjs CHANGED
@@ -1,9 +1,10 @@
1
- const require_rules = require("./rules-COk7kmEU.cjs");
1
+
2
+ const require_rules = require("./rules-5VZcw4ds.cjs");
2
3
  // src/index.ts
3
4
  const plugin = {
4
5
  meta: {
5
6
  name: require_rules.PLUGIN_NAME,
6
- version: "0.0.1"
7
+ version: "0.0.3"
7
8
  },
8
9
  rules: require_rules.rules,
9
10
  configs: {}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["PLUGIN_NAME","rules","recommendedRules"],"sources":["../package.json","../src/index.ts"],"sourcesContent":["","import { version } from \"../package.json\";\n\nimport type { SpartaPlugin } from \"./plugin-types\";\nimport { PLUGIN_NAME, recommendedRules, rules } from \"./rules\";\n\nconst plugin: SpartaPlugin = {\n\tmeta: { name: PLUGIN_NAME, version },\n\trules,\n\tconfigs: {} as SpartaPlugin[\"configs\"],\n};\n\nplugin.configs.recommended = {\n\tname: `${PLUGIN_NAME}/recommended`,\n\tplugins: { [PLUGIN_NAME]: plugin },\n\trules: recommendedRules,\n};\n\nexport default plugin;\n"],"mappings":";;ACKA,MAAM,SAAuB;CAC5B,MAAM;EAAE,MAAMA,cAAAA;EAAa;CAAQ;CACnCC,OAAAA,cAAAA;CACA,SAAS,CAAC;AACX;AAEA,OAAO,QAAQ,cAAc;CAC5B,MAAM,GAAGD,cAAAA,YAAY;CACrB,SAAS,GAAGA,cAAAA,cAAc,OAAO;CACjC,OAAOE,cAAAA;AACR"}
1
+ {"version":3,"file":"index.cjs","names":["PLUGIN_NAME","rules","recommendedRules"],"sources":["../package.json","../src/index.ts"],"sourcesContent":["","import { version } from \"../package.json\";\n\nimport type { SpartaPlugin } from \"./plugin-types\";\nimport { PLUGIN_NAME, recommendedRules, rules } from \"./rules\";\nimport type { SpartaSettings } from \"./utils/conventions\";\n\n/**\n * Adds `settings.sparta` to ESLint's config types, so `defineConfig()` from `eslint/config` autocompletes and checks\n * it as soon as the plugin is imported. Needs ESLint 10+: ESLint 9 types `settings` as a plain record.\n *\n * The rule names are deliberately not added: ESLint's `RulesConfig` can only take them as required properties, which\n * would make every `Linter.RulesRecord` value in a project list them all.\n */\ndeclare module \"@eslint/core\" {\n\tinterface SettingsConfig {\n\t\tsparta?: SpartaSettings;\n\t}\n}\n\nconst plugin: SpartaPlugin = {\n\tmeta: { name: PLUGIN_NAME, version },\n\t// The same rule objects run in both linters (both RuleTesters cover them), but oxlint and ESLint type the rule\n\t// context differently, so the oxlint-typed rules are exposed with ESLint's types for ESLint configs.\n\trules: rules as unknown as SpartaPlugin[\"rules\"],\n\tconfigs: {} as SpartaPlugin[\"configs\"],\n};\n\nplugin.configs.recommended = {\n\tname: `${PLUGIN_NAME}/recommended`,\n\tplugins: { [PLUGIN_NAME]: plugin },\n\trules: recommendedRules,\n};\n\nexport default plugin;\n"],"mappings":";;;ACmBA,MAAM,SAAuB;CAC5B,MAAM;EAAE,MAAMA,cAAAA;EAAa;CAAQ;CAGnC,OAAOC,cAAAA;CACP,SAAS,CAAC;AACX;AAEA,OAAO,QAAQ,cAAc;CAC5B,MAAM,GAAGD,cAAAA,YAAY;CACrB,SAAS,GAAGA,cAAAA,cAAc,OAAO;CACjC,OAAOE,cAAAA;AACR"}
package/dist/index.d.cts CHANGED
@@ -1,3 +1,17 @@
1
- import { n as SpartaPlugin } from "./plugin-types-CgeW0cQl.cjs";
1
+
2
+ import { n as SpartaPlugin } from "./plugin-types-7QJakt0Z.cjs";
3
+ import { r as SpartaSettings } from "./conventions-DK3A7JWL.cjs";
4
+ /**
5
+ * Adds `settings.sparta` to ESLint's config types, so `defineConfig()` from `eslint/config` autocompletes and checks
6
+ * it as soon as the plugin is imported. Needs ESLint 10+: ESLint 9 types `settings` as a plain record.
7
+ *
8
+ * The rule names are deliberately not added: ESLint's `RulesConfig` can only take them as required properties, which
9
+ * would make every `Linter.RulesRecord` value in a project list them all.
10
+ */
11
+ declare module "@eslint/core" {
12
+ interface SettingsConfig {
13
+ sparta?: SpartaSettings;
14
+ }
15
+ }
2
16
  declare const plugin: SpartaPlugin;
3
17
  export = plugin;
package/dist/index.d.mts CHANGED
@@ -1,3 +1,17 @@
1
- import { n as SpartaPlugin } from "./plugin-types-CgeW0cQl.mjs";
1
+ /// <reference path="./index.d.cts" />
2
+ import { n as SpartaPlugin } from "./plugin-types-7QJakt0Z.mjs";
3
+ import { r as SpartaSettings } from "./conventions-DK3A7JWL.mjs";
4
+ /**
5
+ * Adds `settings.sparta` to ESLint's config types, so `defineConfig()` from `eslint/config` autocompletes and checks
6
+ * it as soon as the plugin is imported. Needs ESLint 10+: ESLint 9 types `settings` as a plain record.
7
+ *
8
+ * The rule names are deliberately not added: ESLint's `RulesConfig` can only take them as required properties, which
9
+ * would make every `Linter.RulesRecord` value in a project list them all.
10
+ */
11
+ declare module "@eslint/core" {
12
+ interface SettingsConfig {
13
+ sparta?: SpartaSettings;
14
+ }
15
+ }
2
16
  declare const plugin: SpartaPlugin;
3
- export = plugin;
17
+ export { plugin as default };
package/dist/index.mjs CHANGED
@@ -1,9 +1,10 @@
1
- import { n as recommendedRules, r as rules, t as PLUGIN_NAME } from "./rules-BSRYNh4F.mjs";
1
+
2
+ import { n as recommendedRules, r as rules, t as PLUGIN_NAME } from "./rules-Ay2ZlXtg.mjs";
2
3
  // src/index.ts
3
4
  const plugin = {
4
5
  meta: {
5
6
  name: PLUGIN_NAME,
6
- version: "0.0.1"
7
+ version: "0.0.3"
7
8
  },
8
9
  rules,
9
10
  configs: {}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../package.json","../src/index.ts"],"sourcesContent":["","import { version } from \"../package.json\";\n\nimport type { SpartaPlugin } from \"./plugin-types\";\nimport { PLUGIN_NAME, recommendedRules, rules } from \"./rules\";\n\nconst plugin: SpartaPlugin = {\n\tmeta: { name: PLUGIN_NAME, version },\n\trules,\n\tconfigs: {} as SpartaPlugin[\"configs\"],\n};\n\nplugin.configs.recommended = {\n\tname: `${PLUGIN_NAME}/recommended`,\n\tplugins: { [PLUGIN_NAME]: plugin },\n\trules: recommendedRules,\n};\n\nexport default plugin;\n"],"mappings":";;ACKA,MAAM,SAAuB;CAC5B,MAAM;EAAE,MAAM;EAAa;CAAQ;CACnC;CACA,SAAS,CAAC;AACX;AAEA,OAAO,QAAQ,cAAc;CAC5B,MAAM,GAAG,YAAY;CACrB,SAAS,GAAG,cAAc,OAAO;CACjC,OAAO;AACR"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../package.json","../src/index.ts"],"sourcesContent":["","import { version } from \"../package.json\";\n\nimport type { SpartaPlugin } from \"./plugin-types\";\nimport { PLUGIN_NAME, recommendedRules, rules } from \"./rules\";\nimport type { SpartaSettings } from \"./utils/conventions\";\n\n/**\n * Adds `settings.sparta` to ESLint's config types, so `defineConfig()` from `eslint/config` autocompletes and checks\n * it as soon as the plugin is imported. Needs ESLint 10+: ESLint 9 types `settings` as a plain record.\n *\n * The rule names are deliberately not added: ESLint's `RulesConfig` can only take them as required properties, which\n * would make every `Linter.RulesRecord` value in a project list them all.\n */\ndeclare module \"@eslint/core\" {\n\tinterface SettingsConfig {\n\t\tsparta?: SpartaSettings;\n\t}\n}\n\nconst plugin: SpartaPlugin = {\n\tmeta: { name: PLUGIN_NAME, version },\n\t// The same rule objects run in both linters (both RuleTesters cover them), but oxlint and ESLint type the rule\n\t// context differently, so the oxlint-typed rules are exposed with ESLint's types for ESLint configs.\n\trules: rules as unknown as SpartaPlugin[\"rules\"],\n\tconfigs: {} as SpartaPlugin[\"configs\"],\n};\n\nplugin.configs.recommended = {\n\tname: `${PLUGIN_NAME}/recommended`,\n\tplugins: { [PLUGIN_NAME]: plugin },\n\trules: recommendedRules,\n};\n\nexport default plugin;\n"],"mappings":";;;ACmBA,MAAM,SAAuB;CAC5B,MAAM;EAAE,MAAM;EAAa;CAAQ;CAG5B;CACP,SAAS,CAAC;AACX;AAEA,OAAO,QAAQ,cAAc;CAC5B,MAAM,GAAG,YAAY;CACrB,SAAS,GAAG,cAAc,OAAO;CACjC,OAAO;AACR"}
package/dist/oxlint.cjs CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  // src/oxlint.ts
2
3
  /**
3
4
  * Recommended oxlint config, to extend from `oxlint.config.ts`:
@@ -11,7 +12,7 @@
11
12
  */
12
13
  const config = {
13
14
  jsPlugins: ["@cerios/sparta-lint-rules"],
14
- rules: require("./rules-COk7kmEU.cjs").recommendedRules
15
+ rules: require("./rules-5VZcw4ds.cjs").recommendedRules
15
16
  };
16
17
  module.exports = config;
17
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"oxlint.cjs","names":["recommendedRules"],"sources":["../src/oxlint.ts"],"sourcesContent":["import type { SpartaOxlintConfig } from \"./plugin-types\";\nimport { recommendedRules } from \"./rules\";\n\n/**\n * Recommended oxlint config, to extend from `oxlint.config.ts`:\n *\n * ```ts\n * import { defineConfig } from \"oxlint\";\n * import sparta from \"@cerios/sparta-lint-rules/oxlint\";\n *\n * export default defineConfig({ extends: [sparta] });\n * ```\n */\nconst config: SpartaOxlintConfig = {\n\tjsPlugins: [\"@cerios/sparta-lint-rules\"],\n\trules: recommendedRules,\n};\n\nexport default config;\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,SAA6B;CAClC,WAAW,CAAC,2BAA2B;CACvC,O,8BAAOA,CAAAA,CAAAA;AACR"}
1
+ {"version":3,"file":"oxlint.cjs","names":["recommendedRules"],"sources":["../src/oxlint.ts"],"sourcesContent":["import type { AllowWarnDeny, Oxlintrc } from \"oxlint\";\n\nimport type { SpartaOxlintConfig } from \"./plugin-types\";\nimport { type PLUGIN_NAME, type RuleName, recommendedRules } from \"./rules\";\nimport type { SpartaSettings } from \"./utils/conventions\";\n\n/** The sparta rules take no options, so a severity or a one-element tuple. */\ntype SpartaOxlintRules = { [Name in RuleName as `${typeof PLUGIN_NAME}/${Name}`]?: AllowWarnDeny | [AllowWarnDeny] };\n\n/**\n * Adds the sparta rule names and `settings.sparta` to oxlint's own config types, so `defineConfig()` autocompletes\n * them in `oxlint.config.ts` as soon as this entry is imported.\n */\ndeclare module \"oxlint\" {\n\tinterface DummyRuleMap extends SpartaOxlintRules {}\n\n\tinterface OxlintConfig {\n\t\tsettings?: NonNullable<Oxlintrc[\"settings\"]> & { sparta?: SpartaSettings };\n\t}\n}\n\n/**\n * Recommended oxlint config, to extend from `oxlint.config.ts`:\n *\n * ```ts\n * import { defineConfig } from \"oxlint\";\n * import sparta from \"@cerios/sparta-lint-rules/oxlint\";\n *\n * export default defineConfig({ extends: [sparta] });\n * ```\n */\nconst config: SpartaOxlintConfig = {\n\tjsPlugins: [\"@cerios/sparta-lint-rules\"],\n\trules: recommendedRules,\n};\n\nexport default config;\n"],"mappings":";;;;;;;;;;;;AA+BA,MAAM,SAA6B;CAClC,WAAW,CAAC,2BAA2B;CACvC,O,8BAAOA,CAAAA,CAAAA;AACR"}
package/dist/oxlint.d.cts CHANGED
@@ -1,4 +1,21 @@
1
- import { t as SpartaOxlintConfig } from "./plugin-types-CgeW0cQl.cjs";
1
+
2
+ import { i as RuleName, r as PLUGIN_NAME, t as SpartaOxlintConfig } from "./plugin-types-7QJakt0Z.cjs";
3
+ import { r as SpartaSettings } from "./conventions-DK3A7JWL.cjs";
4
+ import { AllowWarnDeny, Oxlintrc } from "oxlint";
5
+ /** The sparta rules take no options, so a severity or a one-element tuple. */
6
+ type SpartaOxlintRules = { [Name in RuleName as `${typeof PLUGIN_NAME}/${Name}`]?: AllowWarnDeny | [AllowWarnDeny]; };
7
+ /**
8
+ * Adds the sparta rule names and `settings.sparta` to oxlint's own config types, so `defineConfig()` autocompletes
9
+ * them in `oxlint.config.ts` as soon as this entry is imported.
10
+ */
11
+ declare module "oxlint" {
12
+ interface DummyRuleMap extends SpartaOxlintRules {}
13
+ interface OxlintConfig {
14
+ settings?: NonNullable<Oxlintrc["settings"]> & {
15
+ sparta?: SpartaSettings;
16
+ };
17
+ }
18
+ }
2
19
  /**
3
20
  * Recommended oxlint config, to extend from `oxlint.config.ts`:
4
21
  *
package/dist/oxlint.d.mts CHANGED
@@ -1,4 +1,21 @@
1
- import { t as SpartaOxlintConfig } from "./plugin-types-CgeW0cQl.mjs";
1
+
2
+ import { i as RuleName, r as PLUGIN_NAME, t as SpartaOxlintConfig } from "./plugin-types-7QJakt0Z.mjs";
3
+ import { r as SpartaSettings } from "./conventions-DK3A7JWL.mjs";
4
+ import { AllowWarnDeny, Oxlintrc } from "oxlint";
5
+ /** The sparta rules take no options, so a severity or a one-element tuple. */
6
+ type SpartaOxlintRules = { [Name in RuleName as `${typeof PLUGIN_NAME}/${Name}`]?: AllowWarnDeny | [AllowWarnDeny]; };
7
+ /**
8
+ * Adds the sparta rule names and `settings.sparta` to oxlint's own config types, so `defineConfig()` autocompletes
9
+ * them in `oxlint.config.ts` as soon as this entry is imported.
10
+ */
11
+ declare module "oxlint" {
12
+ interface DummyRuleMap extends SpartaOxlintRules {}
13
+ interface OxlintConfig {
14
+ settings?: NonNullable<Oxlintrc["settings"]> & {
15
+ sparta?: SpartaSettings;
16
+ };
17
+ }
18
+ }
2
19
  /**
3
20
  * Recommended oxlint config, to extend from `oxlint.config.ts`:
4
21
  *
@@ -10,4 +27,4 @@ import { t as SpartaOxlintConfig } from "./plugin-types-CgeW0cQl.mjs";
10
27
  * ```
11
28
  */
12
29
  declare const config: SpartaOxlintConfig;
13
- export = config;
30
+ export { config as default };
package/dist/oxlint.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { n as recommendedRules } from "./rules-BSRYNh4F.mjs";
1
+
2
+ import { n as recommendedRules } from "./rules-Ay2ZlXtg.mjs";
2
3
  // src/oxlint.ts
3
4
  /**
4
5
  * Recommended oxlint config, to extend from `oxlint.config.ts`: