@cerios/sparta-lint-rules 0.0.2 → 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/README.md +41 -10
- package/dist/conventions-DK3A7JWL.d.cts +97 -0
- package/dist/conventions-DK3A7JWL.d.mts +97 -0
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -1
- package/dist/index.d.mts +16 -2
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/oxlint.cjs +2 -1
- package/dist/oxlint.cjs.map +1 -1
- package/dist/oxlint.d.cts +18 -1
- package/dist/oxlint.d.mts +19 -2
- package/dist/oxlint.mjs +2 -1
- package/dist/oxlint.mjs.map +1 -1
- package/dist/{plugin-types-CXFDQLJF.d.cts → plugin-types-7QJakt0Z.d.cts} +8 -3
- package/dist/{plugin-types-CXFDQLJF.d.mts → plugin-types-7QJakt0Z.d.mts} +8 -3
- package/dist/{rules-T_C5segG.cjs → rules-5VZcw4ds.cjs} +43 -29
- package/dist/rules-5VZcw4ds.cjs.map +1 -0
- package/dist/{rules-D94N3gGx.mjs → rules-Ay2ZlXtg.mjs} +43 -29
- package/dist/rules-Ay2ZlXtg.mjs.map +1 -0
- package/dist/settings.cjs +1 -0
- package/dist/settings.d.cts +5 -96
- package/dist/settings.d.mts +5 -96
- package/dist/settings.mjs +1 -0
- package/oxlintrc.schema.json +718 -0
- package/package.json +10 -3
- package/dist/rules-D94N3gGx.mjs.map +0 -1
- package/dist/rules-T_C5segG.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ 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",
|
|
@@ -69,13 +70,42 @@ Register the plugin with `jsPlugins` and enable the rules you want:
|
|
|
69
70
|
### ESLint (flat config)
|
|
70
71
|
|
|
71
72
|
```js
|
|
72
|
-
import sparta from "@cerios/sparta-lint-rules";
|
|
73
73
|
// eslint.config.mjs
|
|
74
|
+
import sparta from "@cerios/sparta-lint-rules";
|
|
74
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`. |
|
|
75
90
|
|
|
76
|
-
|
|
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
|
|
94
|
+
|
|
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
|
+
}
|
|
77
105
|
```
|
|
78
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
|
+
|
|
79
109
|
---
|
|
80
110
|
|
|
81
111
|
## Project layout
|
|
@@ -86,7 +116,7 @@ The rules recognise files by their path, so they rely on the SPARTA folder conve
|
|
|
86
116
|
<project>/
|
|
87
117
|
├── sparta/
|
|
88
118
|
│ ├── api/ # area: api, database, ui, mobile or desktop
|
|
89
|
-
│ │ ├── common/ # shared within the area
|
|
119
|
+
│ │ ├── common/ # shared within the area; may hold builders/ and directors/
|
|
90
120
|
│ │ ├── builders/ # *-builder.ts, test data builders shared by the area's groups
|
|
91
121
|
│ │ ├── directors/ # *-director.ts, compose several builders
|
|
92
122
|
│ │ └── <group>/ # e.g. orders
|
|
@@ -94,14 +124,15 @@ The rules recognise files by their path, so they rely on the SPARTA folder conve
|
|
|
94
124
|
│ │ ├── services/ # *-service.ts
|
|
95
125
|
│ │ ├── steppers/ # *-stepper.ts
|
|
96
126
|
│ │ ├── asserters/ # *-asserter.ts
|
|
97
|
-
│ │
|
|
127
|
+
│ │ ├── scenarios/ # *-scenario.ts
|
|
128
|
+
│ │ └── builders/ # *-builder.ts (and directors/), private to the group
|
|
98
129
|
│ ├── database/<group>/ # repositories/, services/, steppers/, asserters/, scenarios/, ...
|
|
99
130
|
│ ├── ui/<group>/ # pages/, components/, steppers/, asserters/, scenarios/
|
|
100
131
|
│ ├── mobile/<group>/ # like ui, with screens/ (*-screen.ts) in place of pages/
|
|
101
132
|
│ ├── desktop/<group>/ # like ui, with windows/ (*-window.ts) in place of pages/, for Windows apps
|
|
102
133
|
│ ├── scenarios/ # cross-area scenarios
|
|
103
134
|
│ ├── fixtures/ # Playwright fixtures that wire everything up
|
|
104
|
-
│ ├── common/ # shared, area-independent code
|
|
135
|
+
│ ├── common/ # shared, area-independent code; may hold builders/ and directors/
|
|
105
136
|
│ └── support/ # expect with custom matchers, helpers
|
|
106
137
|
└── tests/ # the tests themselves
|
|
107
138
|
└── framework/ # framework tests; never checked
|
|
@@ -146,7 +177,6 @@ A name can't turn one SPARTA concept into another, so `areas: { ui: "api" }`, `a
|
|
|
146
177
|
|
|
147
178
|
```ts
|
|
148
179
|
import sparta from "@cerios/sparta-lint-rules/oxlint";
|
|
149
|
-
import type { SpartaSettings } from "@cerios/sparta-lint-rules/settings";
|
|
150
180
|
import { defineConfig } from "oxlint";
|
|
151
181
|
|
|
152
182
|
export default defineConfig({
|
|
@@ -157,7 +187,7 @@ export default defineConfig({
|
|
|
157
187
|
layers: { "page-objects": "pages" },
|
|
158
188
|
aliases: { "@app/*": "sparta" },
|
|
159
189
|
supportModule: "@app/support",
|
|
160
|
-
}
|
|
190
|
+
},
|
|
161
191
|
},
|
|
162
192
|
});
|
|
163
193
|
```
|
|
@@ -166,6 +196,7 @@ export default defineConfig({
|
|
|
166
196
|
|
|
167
197
|
```json
|
|
168
198
|
{
|
|
199
|
+
"$schema": "./node_modules/@cerios/sparta-lint-rules/oxlintrc.schema.json",
|
|
169
200
|
"jsPlugins": ["@cerios/sparta-lint-rules"],
|
|
170
201
|
"settings": {
|
|
171
202
|
"sparta": { "areas": { "web": "ui" } }
|
|
@@ -176,11 +207,11 @@ export default defineConfig({
|
|
|
176
207
|
### ESLint (flat config)
|
|
177
208
|
|
|
178
209
|
```js
|
|
179
|
-
export default
|
|
210
|
+
export default defineConfig(
|
|
180
211
|
// ...
|
|
181
212
|
sparta.configs.recommended,
|
|
182
|
-
{ settings: { sparta: { areas: { web: "ui" } } } }
|
|
183
|
-
|
|
213
|
+
{ settings: { sparta: { areas: { web: "ui" } } } }
|
|
214
|
+
);
|
|
184
215
|
```
|
|
185
216
|
|
|
186
217
|
### Project root
|
|
@@ -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
|
-
|
|
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.
|
|
7
|
+
version: "0.0.3"
|
|
7
8
|
},
|
|
8
9
|
rules: require_rules.rules,
|
|
9
10
|
configs: {}
|
package/dist/index.cjs.map
CHANGED
|
@@ -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":"
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
17
|
+
export { plugin as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
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.
|
|
7
|
+
version: "0.0.3"
|
|
7
8
|
},
|
|
8
9
|
rules,
|
|
9
10
|
configs: {}
|
package/dist/index.mjs.map
CHANGED
|
@@ -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":"
|
|
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-
|
|
15
|
+
rules: require("./rules-5VZcw4ds.cjs").recommendedRules
|
|
15
16
|
};
|
|
16
17
|
module.exports = config;
|
|
17
18
|
|
package/dist/oxlint.cjs.map
CHANGED
|
@@ -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":"
|
|
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
|
-
|
|
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
|
-
|
|
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-CXFDQLJF.mjs";
|
|
|
10
27
|
* ```
|
|
11
28
|
*/
|
|
12
29
|
declare const config: SpartaOxlintConfig;
|
|
13
|
-
export
|
|
30
|
+
export { config as default };
|
package/dist/oxlint.mjs
CHANGED
package/dist/oxlint.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint.mjs","names":[],"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":"
|
|
1
|
+
{"version":3,"file":"oxlint.mjs","names":[],"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,OAAO;AACR"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
import { RuleDefinition } from "@eslint/core";
|
|
1
3
|
declare const rules: {
|
|
2
4
|
"architecture-boundaries": import("@oxlint/plugins").CreateRule;
|
|
3
5
|
"class-matches-filename": import("@oxlint/plugins").CreateRule;
|
|
@@ -14,8 +16,10 @@ declare const rules: {
|
|
|
14
16
|
"step-placeholders": import("@oxlint/plugins").CreateRule;
|
|
15
17
|
"step-required": import("@oxlint/plugins").CreateRule;
|
|
16
18
|
};
|
|
19
|
+
type RuleName = keyof typeof rules;
|
|
20
|
+
declare const PLUGIN_NAME = "sparta";
|
|
17
21
|
type Severity = "error" | "warn";
|
|
18
|
-
/** ESLint flat config entry. Typed structurally so
|
|
22
|
+
/** ESLint flat config entry. Typed structurally so it fits ESLint's `defineConfig()`. */
|
|
19
23
|
interface SpartaFlatConfig {
|
|
20
24
|
name: string;
|
|
21
25
|
plugins: Record<string, SpartaPlugin>;
|
|
@@ -26,7 +30,8 @@ interface SpartaPlugin {
|
|
|
26
30
|
name: string;
|
|
27
31
|
version: string;
|
|
28
32
|
};
|
|
29
|
-
rules
|
|
33
|
+
/** Typed as ESLint rules for ESLint configs; oxlint loads the plugin by name and doesn't read these types. */
|
|
34
|
+
rules: Record<RuleName, RuleDefinition>;
|
|
30
35
|
configs: {
|
|
31
36
|
recommended: SpartaFlatConfig;
|
|
32
37
|
};
|
|
@@ -35,4 +40,4 @@ interface SpartaOxlintConfig {
|
|
|
35
40
|
jsPlugins: string[];
|
|
36
41
|
rules: Record<string, Severity>;
|
|
37
42
|
}
|
|
38
|
-
export { SpartaPlugin as n, SpartaOxlintConfig as t };
|
|
43
|
+
export { RuleName as i, SpartaPlugin as n, PLUGIN_NAME as r, SpartaOxlintConfig as t };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
import { RuleDefinition } from "@eslint/core";
|
|
1
3
|
declare const rules: {
|
|
2
4
|
"architecture-boundaries": import("@oxlint/plugins").CreateRule;
|
|
3
5
|
"class-matches-filename": import("@oxlint/plugins").CreateRule;
|
|
@@ -14,8 +16,10 @@ declare const rules: {
|
|
|
14
16
|
"step-placeholders": import("@oxlint/plugins").CreateRule;
|
|
15
17
|
"step-required": import("@oxlint/plugins").CreateRule;
|
|
16
18
|
};
|
|
19
|
+
type RuleName = keyof typeof rules;
|
|
20
|
+
declare const PLUGIN_NAME = "sparta";
|
|
17
21
|
type Severity = "error" | "warn";
|
|
18
|
-
/** ESLint flat config entry. Typed structurally so
|
|
22
|
+
/** ESLint flat config entry. Typed structurally so it fits ESLint's `defineConfig()`. */
|
|
19
23
|
interface SpartaFlatConfig {
|
|
20
24
|
name: string;
|
|
21
25
|
plugins: Record<string, SpartaPlugin>;
|
|
@@ -26,7 +30,8 @@ interface SpartaPlugin {
|
|
|
26
30
|
name: string;
|
|
27
31
|
version: string;
|
|
28
32
|
};
|
|
29
|
-
rules
|
|
33
|
+
/** Typed as ESLint rules for ESLint configs; oxlint loads the plugin by name and doesn't read these types. */
|
|
34
|
+
rules: Record<RuleName, RuleDefinition>;
|
|
30
35
|
configs: {
|
|
31
36
|
recommended: SpartaFlatConfig;
|
|
32
37
|
};
|
|
@@ -35,4 +40,4 @@ interface SpartaOxlintConfig {
|
|
|
35
40
|
jsPlugins: string[];
|
|
36
41
|
rules: Record<string, Severity>;
|
|
37
42
|
}
|
|
38
|
-
export { SpartaPlugin as n, SpartaOxlintConfig as t };
|
|
43
|
+
export { RuleName as i, SpartaPlugin as n, PLUGIN_NAME as r, SpartaOxlintConfig as t };
|