@ts-kizuna/eslint-plugin 1.53.0 → 1.55.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/dist/index.cjs +4 -24
- package/dist/index.mjs +4 -24
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -30,14 +30,10 @@ typescript = __toESM(typescript, 1);
|
|
|
30
30
|
let _ts_kizuna_core_authoring_names = require("@ts-kizuna/core/authoring-names");
|
|
31
31
|
//#region package.json
|
|
32
32
|
var name = "@ts-kizuna/eslint-plugin";
|
|
33
|
-
var version = "1.
|
|
33
|
+
var version = "1.54.0";
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/schema-violations.ts
|
|
36
36
|
/**
|
|
37
|
-
* A JSDoc inline tag, `{@link …}`, `{@linkcode …}`, any `{@tag}`.
|
|
38
|
-
*/
|
|
39
|
-
const JSDOC_INLINE_TAG = /\{@[a-zA-Z][\w-]*/;
|
|
40
|
-
/**
|
|
41
37
|
* Walks a schema expression, following `z.object` shapes, nested objects, and identifier
|
|
42
38
|
* references to other schemas (across files), and returns every issue it carries, each
|
|
43
39
|
* paired with the node it sits on. The walk is bounded by a visited set so cycles end.
|
|
@@ -56,16 +52,8 @@ const collectSchemaIssues = (root, resolve) => {
|
|
|
56
52
|
viaReference
|
|
57
53
|
});
|
|
58
54
|
};
|
|
59
|
-
const checkFieldJsDoc = (property, viaReference) => {
|
|
60
|
-
const deprecatedTags = typescript.default.getJSDocTags(property).filter((tag) => tag.tagName.text === "deprecated");
|
|
61
|
-
if (deprecatedTags.length > 1) add("duplicate-deprecated", property, viaReference);
|
|
62
|
-
for (const tag of deprecatedTags) if (JSDOC_INLINE_TAG.test(typescript.default.getTextOfJSDocComment(tag.comment) ?? "")) add("jsdoc-tag", property, viaReference);
|
|
63
|
-
};
|
|
64
55
|
const walk = (node, viaReference) => {
|
|
65
56
|
if (typescript.default.isPropertyAccessExpression(node) && node.name.text === "coerce" && typescript.default.isIdentifier(node.expression) && node.expression.text === "z") add("coerce", node, viaReference);
|
|
66
|
-
if (typescript.default.isObjectLiteralExpression(node)) {
|
|
67
|
-
for (const property of node.properties) if (typescript.default.isPropertyAssignment(property) || typescript.default.isShorthandPropertyAssignment(property)) checkFieldJsDoc(property, viaReference);
|
|
68
|
-
}
|
|
69
57
|
if (typescript.default.isIdentifier(node)) {
|
|
70
58
|
const target = resolve(node);
|
|
71
59
|
if (target && !visited.has(target)) {
|
|
@@ -143,11 +131,7 @@ const createSourceResolver = () => {
|
|
|
143
131
|
return target ? constNamed(target, imported.exportedName) : void 0;
|
|
144
132
|
};
|
|
145
133
|
};
|
|
146
|
-
const MESSAGE_IDS = {
|
|
147
|
-
coerce: ["coerce", "coerceReference"],
|
|
148
|
-
"jsdoc-tag": ["jsdocTag", "jsdocTagReference"],
|
|
149
|
-
"duplicate-deprecated": ["duplicateDeprecated", "duplicateDeprecatedReference"]
|
|
150
|
-
};
|
|
134
|
+
const MESSAGE_IDS = { coerce: ["coerce", "coerceReference"] };
|
|
151
135
|
const calleeName = (node) => {
|
|
152
136
|
const { callee } = node;
|
|
153
137
|
if (callee.type === "Identifier") return callee.name;
|
|
@@ -181,14 +165,10 @@ const schemaNodesOf = (call) => {
|
|
|
181
165
|
const noUnsupportedSchema = _typescript_eslint_utils.ESLintUtils.RuleCreator.withoutDocs({
|
|
182
166
|
meta: {
|
|
183
167
|
type: "problem",
|
|
184
|
-
docs: { description: "Disallow constructs unsupported by ts-kizuna (z.coerce
|
|
168
|
+
docs: { description: "Disallow constructs unsupported by ts-kizuna (z.coerce) in contract and model schemas, including imported ones." },
|
|
185
169
|
messages: {
|
|
186
170
|
coerce: "z.coerce is not supported in a ts-kizuna schema. kizuna coerces query, path, and header params automatically, use z.number(), z.date(), or z.bigint() instead.",
|
|
187
|
-
|
|
188
|
-
duplicateDeprecated: "This field has more than one @deprecated tag. kizuna serializes only the first and silently drops the rest, collapse them into a single message.",
|
|
189
|
-
coerceReference: "This schema uses z.coerce, which ts-kizuna does not support. kizuna coerces query, path, and header params automatically, use z.number(), z.date(), or z.bigint() instead.",
|
|
190
|
-
jsdocTagReference: "This schema has a @deprecated message with JSDoc inline tags like {@link}. kizuna surfaces deprecation text verbatim to generated clients that cannot parse it, use plain text instead (backticks are fine).",
|
|
191
|
-
duplicateDeprecatedReference: "This schema has a field with more than one @deprecated tag. kizuna serializes only the first and silently drops the rest, collapse them into a single message."
|
|
171
|
+
coerceReference: "This schema uses z.coerce, which ts-kizuna does not support. kizuna coerces query, path, and header params automatically, use z.number(), z.date(), or z.bigint() instead."
|
|
192
172
|
},
|
|
193
173
|
schema: []
|
|
194
174
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -5,14 +5,10 @@ import ts from "typescript";
|
|
|
5
5
|
import { AUTHORING_NAMES } from "@ts-kizuna/core/authoring-names";
|
|
6
6
|
//#region package.json
|
|
7
7
|
var name = "@ts-kizuna/eslint-plugin";
|
|
8
|
-
var version = "1.
|
|
8
|
+
var version = "1.54.0";
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/schema-violations.ts
|
|
11
11
|
/**
|
|
12
|
-
* A JSDoc inline tag, `{@link …}`, `{@linkcode …}`, any `{@tag}`.
|
|
13
|
-
*/
|
|
14
|
-
const JSDOC_INLINE_TAG = /\{@[a-zA-Z][\w-]*/;
|
|
15
|
-
/**
|
|
16
12
|
* Walks a schema expression, following `z.object` shapes, nested objects, and identifier
|
|
17
13
|
* references to other schemas (across files), and returns every issue it carries, each
|
|
18
14
|
* paired with the node it sits on. The walk is bounded by a visited set so cycles end.
|
|
@@ -31,16 +27,8 @@ const collectSchemaIssues = (root, resolve) => {
|
|
|
31
27
|
viaReference
|
|
32
28
|
});
|
|
33
29
|
};
|
|
34
|
-
const checkFieldJsDoc = (property, viaReference) => {
|
|
35
|
-
const deprecatedTags = ts.getJSDocTags(property).filter((tag) => tag.tagName.text === "deprecated");
|
|
36
|
-
if (deprecatedTags.length > 1) add("duplicate-deprecated", property, viaReference);
|
|
37
|
-
for (const tag of deprecatedTags) if (JSDOC_INLINE_TAG.test(ts.getTextOfJSDocComment(tag.comment) ?? "")) add("jsdoc-tag", property, viaReference);
|
|
38
|
-
};
|
|
39
30
|
const walk = (node, viaReference) => {
|
|
40
31
|
if (ts.isPropertyAccessExpression(node) && node.name.text === "coerce" && ts.isIdentifier(node.expression) && node.expression.text === "z") add("coerce", node, viaReference);
|
|
41
|
-
if (ts.isObjectLiteralExpression(node)) {
|
|
42
|
-
for (const property of node.properties) if (ts.isPropertyAssignment(property) || ts.isShorthandPropertyAssignment(property)) checkFieldJsDoc(property, viaReference);
|
|
43
|
-
}
|
|
44
32
|
if (ts.isIdentifier(node)) {
|
|
45
33
|
const target = resolve(node);
|
|
46
34
|
if (target && !visited.has(target)) {
|
|
@@ -118,11 +106,7 @@ const createSourceResolver = () => {
|
|
|
118
106
|
return target ? constNamed(target, imported.exportedName) : void 0;
|
|
119
107
|
};
|
|
120
108
|
};
|
|
121
|
-
const MESSAGE_IDS = {
|
|
122
|
-
coerce: ["coerce", "coerceReference"],
|
|
123
|
-
"jsdoc-tag": ["jsdocTag", "jsdocTagReference"],
|
|
124
|
-
"duplicate-deprecated": ["duplicateDeprecated", "duplicateDeprecatedReference"]
|
|
125
|
-
};
|
|
109
|
+
const MESSAGE_IDS = { coerce: ["coerce", "coerceReference"] };
|
|
126
110
|
const calleeName = (node) => {
|
|
127
111
|
const { callee } = node;
|
|
128
112
|
if (callee.type === "Identifier") return callee.name;
|
|
@@ -156,14 +140,10 @@ const schemaNodesOf = (call) => {
|
|
|
156
140
|
const noUnsupportedSchema = ESLintUtils.RuleCreator.withoutDocs({
|
|
157
141
|
meta: {
|
|
158
142
|
type: "problem",
|
|
159
|
-
docs: { description: "Disallow constructs unsupported by ts-kizuna (z.coerce
|
|
143
|
+
docs: { description: "Disallow constructs unsupported by ts-kizuna (z.coerce) in contract and model schemas, including imported ones." },
|
|
160
144
|
messages: {
|
|
161
145
|
coerce: "z.coerce is not supported in a ts-kizuna schema. kizuna coerces query, path, and header params automatically, use z.number(), z.date(), or z.bigint() instead.",
|
|
162
|
-
|
|
163
|
-
duplicateDeprecated: "This field has more than one @deprecated tag. kizuna serializes only the first and silently drops the rest, collapse them into a single message.",
|
|
164
|
-
coerceReference: "This schema uses z.coerce, which ts-kizuna does not support. kizuna coerces query, path, and header params automatically, use z.number(), z.date(), or z.bigint() instead.",
|
|
165
|
-
jsdocTagReference: "This schema has a @deprecated message with JSDoc inline tags like {@link}. kizuna surfaces deprecation text verbatim to generated clients that cannot parse it, use plain text instead (backticks are fine).",
|
|
166
|
-
duplicateDeprecatedReference: "This schema has a field with more than one @deprecated tag. kizuna serializes only the first and silently drops the rest, collapse them into a single message."
|
|
146
|
+
coerceReference: "This schema uses z.coerce, which ts-kizuna does not support. kizuna coerces query, path, and header params automatically, use z.number(), z.date(), or z.bigint() instead."
|
|
167
147
|
},
|
|
168
148
|
schema: []
|
|
169
149
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-kizuna/eslint-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.55.0",
|
|
4
4
|
"description": "ESLint rules for ts-kizuna",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ts-kizuna",
|
|
@@ -62,14 +62,14 @@
|
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"eslint": ">=9.0.0",
|
|
64
64
|
"typescript": ">=5.0.0",
|
|
65
|
-
"@ts-kizuna/core": "1.
|
|
65
|
+
"@ts-kizuna/core": "1.55.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"eslint": "^9.39.4",
|
|
69
69
|
"tsdown": "^0.21.0",
|
|
70
70
|
"typescript": "^6.0.3",
|
|
71
71
|
"zod": "^4.0.0",
|
|
72
|
-
"@ts-kizuna/core": "1.
|
|
72
|
+
"@ts-kizuna/core": "1.55.0"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "tsdown src/index.ts --format esm,cjs --dts --clean --external eslint --external typescript --external @typescript-eslint/utils --external @typescript-eslint/parser --external @ts-kizuna/core",
|