@luxass/spectral-ruleset 0.0.5 → 1.1.0
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 +70 -0
- package/dist/ruleset.cjs +10 -1
- package/dist/ruleset.js +10 -0
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -35,6 +35,76 @@ You can also use it directly from unpkg:
|
|
|
35
35
|
echo 'extends: ["https://unpkg.com/@luxass/spectral-ruleset"]' > .spectral.yml
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
## Rules
|
|
39
|
+
|
|
40
|
+
This ruleset extends the official OpenAPI and AsyncAPI rulesets from `@stoplight/spectral-rulesets`, with some built-in rules modified (`operation-tags` and `operation-operationId` are disabled, `operation-success-response` is set to error level).
|
|
41
|
+
|
|
42
|
+
### Custom Rules
|
|
43
|
+
|
|
44
|
+
<details>
|
|
45
|
+
<summary><strong>General Rules</strong></summary>
|
|
46
|
+
|
|
47
|
+
##### `luxass/api-homepage` ⚠️
|
|
48
|
+
Ensures that APIs have a root path (`/`) defined. This helps with API discoverability and provides a clear entry point for consumers.
|
|
49
|
+
|
|
50
|
+
##### `luxass/api-homepage-get` ⚠️
|
|
51
|
+
Ensures that the API root path (`/`) has a GET operation defined. This allows consumers to discover what the API offers.
|
|
52
|
+
|
|
53
|
+
##### `luxass/version-in-info` ⚠️
|
|
54
|
+
Enforces semantic versioning format for the `info.version` field (e.g., `1.0.0`).
|
|
55
|
+
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
<details>
|
|
59
|
+
<summary><strong>Path Rules</strong></summary>
|
|
60
|
+
|
|
61
|
+
##### `luxass/paths-kebab-case` ⚠️
|
|
62
|
+
Enforces kebab-case naming convention for all API paths (e.g., `/user-profiles` instead of `/userProfiles`).
|
|
63
|
+
|
|
64
|
+
##### `luxass/no-file-extensions-in-paths` ❌
|
|
65
|
+
Prevents file extensions (`.json`, `.xml`, `.html`, `.txt`) in API paths. Use the `content` field to specify media types instead.
|
|
66
|
+
|
|
67
|
+
##### `luxass/no-trailing-slash` ⚠️
|
|
68
|
+
Prevents trailing slashes in paths (except for the root path `/`), avoiding confusion about resource identity.
|
|
69
|
+
|
|
70
|
+
##### `luxass/plural-resource-names` ⚠️
|
|
71
|
+
Encourages using plural nouns for resource collections (e.g., `/users` instead of `/user`).
|
|
72
|
+
|
|
73
|
+
</details>
|
|
74
|
+
|
|
75
|
+
<details>
|
|
76
|
+
<summary><strong>Header Rules</strong></summary>
|
|
77
|
+
|
|
78
|
+
##### `luxass/no-x-headers` ❌
|
|
79
|
+
Prevents usage of headers starting with `X-` prefix. Encourages using standardized headers instead of the deprecated X- convention.
|
|
80
|
+
|
|
81
|
+
##### `luxass/headers-hyphenated-pascal-case` ❌
|
|
82
|
+
Enforces `Hyphenated-Pascal-Case` notation for HTTP headers (e.g., `Content-Type`, `Accept-Language`).
|
|
83
|
+
|
|
84
|
+
</details>
|
|
85
|
+
|
|
86
|
+
<details>
|
|
87
|
+
<summary><strong>OpenAPI 2.0 Specific Rules</strong></summary>
|
|
88
|
+
|
|
89
|
+
##### `luxass/oas2/protocol-https-only` ❌
|
|
90
|
+
Ensures that only HTTPS protocol is used in the `schemes` array.
|
|
91
|
+
|
|
92
|
+
##### `luxass/oas2/get-request-no-body` ❌
|
|
93
|
+
Prevents GET requests from having request bodies, following HTTP best practices.
|
|
94
|
+
|
|
95
|
+
</details>
|
|
96
|
+
|
|
97
|
+
<details>
|
|
98
|
+
<summary><strong>OpenAPI 3.x Specific Rules</strong></summary>
|
|
99
|
+
|
|
100
|
+
##### `luxass/oas3/protocol-https-only` ❌
|
|
101
|
+
Ensures that all server URLs use HTTPS protocol only.
|
|
102
|
+
|
|
103
|
+
##### `luxass/oas3/get-request-no-body` ❌
|
|
104
|
+
Prevents GET requests from having `requestBody` defined, following HTTP best practices.
|
|
105
|
+
|
|
106
|
+
</details>
|
|
107
|
+
|
|
38
108
|
## 📄 License
|
|
39
109
|
|
|
40
110
|
Published under [MIT License](./LICENSE).
|
package/dist/ruleset.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//#region rolldown:runtime
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
@@ -283,6 +282,16 @@ var ruleset_default = {
|
|
|
283
282
|
functionOptions: { match: "^[A-Z][a-z0-9]*(-[A-Z][a-z0-9]*)*$" }
|
|
284
283
|
}
|
|
285
284
|
},
|
|
285
|
+
"luxass/version-in-info": {
|
|
286
|
+
message: "API version should follow semantic versioning.",
|
|
287
|
+
description: "The info.version field should follow semantic versioning (e.g., 1.0.0).",
|
|
288
|
+
given: "$.info.version",
|
|
289
|
+
then: {
|
|
290
|
+
function: __stoplight_spectral_functions.pattern,
|
|
291
|
+
functionOptions: { match: "^\\d+\\.\\d+\\.\\d+" }
|
|
292
|
+
},
|
|
293
|
+
severity: DiagnosticSeverity.Warning
|
|
294
|
+
},
|
|
286
295
|
...oas2_default,
|
|
287
296
|
...oas3_default
|
|
288
297
|
}
|
package/dist/ruleset.js
CHANGED
|
@@ -259,6 +259,16 @@ var ruleset_default = {
|
|
|
259
259
|
functionOptions: { match: "^[A-Z][a-z0-9]*(-[A-Z][a-z0-9]*)*$" }
|
|
260
260
|
}
|
|
261
261
|
},
|
|
262
|
+
"luxass/version-in-info": {
|
|
263
|
+
message: "API version should follow semantic versioning.",
|
|
264
|
+
description: "The info.version field should follow semantic versioning (e.g., 1.0.0).",
|
|
265
|
+
given: "$.info.version",
|
|
266
|
+
then: {
|
|
267
|
+
function: pattern,
|
|
268
|
+
functionOptions: { match: "^\\d+\\.\\d+\\.\\d+" }
|
|
269
|
+
},
|
|
270
|
+
severity: DiagnosticSeverity.Warning
|
|
271
|
+
},
|
|
262
272
|
...oas2_default,
|
|
263
273
|
...oas3_default
|
|
264
274
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxass/spectral-ruleset",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Opinonated ruleset for Spectral",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -9,18 +9,18 @@
|
|
|
9
9
|
},
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"types": "./dist/ruleset.d.ts",
|
|
13
12
|
"import": "./dist/ruleset.js",
|
|
14
13
|
"require": "./dist/ruleset.cjs"
|
|
15
|
-
}
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
16
|
},
|
|
17
|
-
"main": "dist/ruleset.cjs",
|
|
18
|
-
"module": "dist/ruleset.js",
|
|
17
|
+
"main": "./dist/ruleset.cjs",
|
|
18
|
+
"module": "./dist/ruleset.js",
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@luxass/eslint-config": "^
|
|
23
|
+
"@luxass/eslint-config": "^5.1.1",
|
|
24
24
|
"@stoplight/spectral-core": "^1.20.0",
|
|
25
25
|
"@stoplight/spectral-formats": "^1.8.2",
|
|
26
26
|
"@stoplight/spectral-functions": "^1.10.1",
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
"@stoplight/spectral-rulesets": "^1.22.0",
|
|
29
29
|
"@stoplight/types": "^14.1.1",
|
|
30
30
|
"@types/node": "^22.15.18",
|
|
31
|
-
"eslint": "^9.
|
|
32
|
-
"
|
|
31
|
+
"eslint": "^9.31.0",
|
|
32
|
+
"publint": "^0.3.12",
|
|
33
|
+
"tsdown": "^0.12.9",
|
|
33
34
|
"typescript": "^5.8.3",
|
|
34
|
-
"vitest": "^3.
|
|
35
|
+
"vitest": "^3.2.4"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
38
|
"build": "tsdown",
|