@sarj/eslint-plugin 18.1.3 → 18.1.4
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 +15 -10
- package/dist/index.js +15 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2896,6 +2896,11 @@ var prefer_dependency_interface_default = createRule({
|
|
|
2896
2896
|
}
|
|
2897
2897
|
});
|
|
2898
2898
|
|
|
2899
|
+
// src/rules/_is-present.ts
|
|
2900
|
+
function isPresent(value) {
|
|
2901
|
+
return value !== null && value !== void 0;
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2899
2904
|
// src/rules/no-mutating-input-with-result.ts
|
|
2900
2905
|
var import_utils22 = require("@typescript-eslint/utils");
|
|
2901
2906
|
var NO_MUTATING_INPUT_WITH_RESULT_DOCUMENTATION = {
|
|
@@ -3000,7 +3005,7 @@ var no_mutating_input_with_result_default = createRule({
|
|
|
3000
3005
|
if (annotation === void 0 || command(annotation) || node.body === void 0) return;
|
|
3001
3006
|
const inputs = /* @__PURE__ */ new Map();
|
|
3002
3007
|
for (const parameter of node.params) {
|
|
3003
|
-
if (parameter.type !== import_utils22.AST_NODE_TYPES.Identifier || parameter.typeAnnotation
|
|
3008
|
+
if (parameter.type !== import_utils22.AST_NODE_TYPES.Identifier || !isPresent(parameter.typeAnnotation)) continue;
|
|
3004
3009
|
const variable = import_utils22.ASTUtils.findVariable(sourceCode.getScope(parameter), parameter.name);
|
|
3005
3010
|
if (variable === null || variable.references.some((reference) => reference.isWrite())) continue;
|
|
3006
3011
|
const names = fields(parameter.typeAnnotation.typeAnnotation, sourceCode);
|
|
@@ -4508,7 +4513,7 @@ var no_mutating_container_transform_default = createRule({
|
|
|
4508
4513
|
if (node.body?.type !== import_utils37.AST_NODE_TYPES.BlockStatement || !returnsArray(node, sourceCode) || !supported(node.body.body)) return;
|
|
4509
4514
|
const initial = /* @__PURE__ */ new Map();
|
|
4510
4515
|
for (const parameter of node.params) {
|
|
4511
|
-
if (parameter.type !== import_utils37.AST_NODE_TYPES.Identifier || parameter.typeAnnotation
|
|
4516
|
+
if (parameter.type !== import_utils37.AST_NODE_TYPES.Identifier || !isPresent(parameter.typeAnnotation)) continue;
|
|
4512
4517
|
const element = arrayElement(parameter.typeAnnotation.typeAnnotation, sourceCode);
|
|
4513
4518
|
const variable = binding3(parameter);
|
|
4514
4519
|
if (element !== null && PRIMITIVES.has(element.type) && variable !== null) initial.set(variable, parameter.name);
|
|
@@ -6121,7 +6126,7 @@ function isSearchParamReceiver(call, services) {
|
|
|
6121
6126
|
// package.json
|
|
6122
6127
|
var package_default = {
|
|
6123
6128
|
name: "@sarj/eslint-plugin",
|
|
6124
|
-
version: "18.1.
|
|
6129
|
+
version: "18.1.4",
|
|
6125
6130
|
packageManager: "npm@12.2.1",
|
|
6126
6131
|
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
6127
6132
|
type: "module",
|
|
@@ -26359,7 +26364,7 @@ function discriminatedUnionReturns(node, sourceCode) {
|
|
|
26359
26364
|
}
|
|
26360
26365
|
function returnContract(node, sourceCode) {
|
|
26361
26366
|
const annotation = node.returnType;
|
|
26362
|
-
if (annotation
|
|
26367
|
+
if (!isPresent(annotation)) return void 0;
|
|
26363
26368
|
let type = annotation.typeAnnotation;
|
|
26364
26369
|
if (node.async && type.type === import_utils153.AST_NODE_TYPES.TSTypeReference && type.typeName.type === import_utils153.AST_NODE_TYPES.Identifier && type.typeName.name === "Promise" && type.typeArguments?.params.length === 1 && definitions(type, sourceCode).length === 0) {
|
|
26365
26370
|
const inner = type.typeArguments.params[0];
|
|
@@ -29438,7 +29443,7 @@ function checkBoundary(node, context) {
|
|
|
29438
29443
|
const roles = /* @__PURE__ */ new Map();
|
|
29439
29444
|
for (const parameter of node.params) {
|
|
29440
29445
|
const identifier = parameterIdentifier(parameter);
|
|
29441
|
-
if (identifier?.typeAnnotation
|
|
29446
|
+
if (!isPresent(identifier?.typeAnnotation)) continue;
|
|
29442
29447
|
const role = identifierRole(identifier.name);
|
|
29443
29448
|
if (role === void 0) continue;
|
|
29444
29449
|
const carrier = rawCarrier(
|
|
@@ -30586,7 +30591,7 @@ function processOwnershipValue(identifier, source, graph) {
|
|
|
30586
30591
|
if (binding3 === null || graph.values.has(binding3)) return;
|
|
30587
30592
|
graph.values.add(binding3);
|
|
30588
30593
|
const annotation = exportedValueAnnotation(source, identifier);
|
|
30589
|
-
if (annotation
|
|
30594
|
+
if (isPresent(annotation)) graph.pending.push({ kind: "syntax", node: annotation });
|
|
30590
30595
|
const resolved = exportedCallable(source, identifier, graph.cache);
|
|
30591
30596
|
if (resolved === null) return;
|
|
30592
30597
|
if (resolved.callable !== null) graph.callables.add(resolved.callable);
|
|
@@ -30672,7 +30677,7 @@ function exportedCallable(source, identifier, cache) {
|
|
|
30672
30677
|
}
|
|
30673
30678
|
const step = constantCallableStep(binding3);
|
|
30674
30679
|
if (step === null) break;
|
|
30675
|
-
if (step.annotation
|
|
30680
|
+
if (isPresent(step.annotation)) annotations.push(step.annotation);
|
|
30676
30681
|
if (isFunctionNode2(step.target)) {
|
|
30677
30682
|
target = { callable: step.target, signatures: [step.target] };
|
|
30678
30683
|
break;
|
|
@@ -30711,11 +30716,11 @@ function valueBinding(source, identifier) {
|
|
|
30711
30716
|
}
|
|
30712
30717
|
function callableAnnotations(callable) {
|
|
30713
30718
|
const annotations = [];
|
|
30714
|
-
if (callable.returnType
|
|
30715
|
-
if (callable.typeParameters
|
|
30719
|
+
if (isPresent(callable.returnType)) annotations.push(callable.returnType);
|
|
30720
|
+
if (isPresent(callable.typeParameters)) annotations.push(callable.typeParameters);
|
|
30716
30721
|
for (const raw of callable.params) {
|
|
30717
30722
|
const parameter = raw.type === import_utils173.AST_NODE_TYPES.AssignmentPattern ? raw.left : raw;
|
|
30718
|
-
if ((parameter.type === import_utils173.AST_NODE_TYPES.Identifier || parameter.type === import_utils173.AST_NODE_TYPES.ObjectPattern || parameter.type === import_utils173.AST_NODE_TYPES.ArrayPattern || parameter.type === import_utils173.AST_NODE_TYPES.RestElement) && parameter.typeAnnotation
|
|
30723
|
+
if ((parameter.type === import_utils173.AST_NODE_TYPES.Identifier || parameter.type === import_utils173.AST_NODE_TYPES.ObjectPattern || parameter.type === import_utils173.AST_NODE_TYPES.ArrayPattern || parameter.type === import_utils173.AST_NODE_TYPES.RestElement) && isPresent(parameter.typeAnnotation)) annotations.push(parameter.typeAnnotation);
|
|
30719
30724
|
}
|
|
30720
30725
|
return annotations;
|
|
30721
30726
|
}
|
package/dist/index.js
CHANGED
|
@@ -2854,6 +2854,11 @@ var prefer_dependency_interface_default = createRule({
|
|
|
2854
2854
|
}
|
|
2855
2855
|
});
|
|
2856
2856
|
|
|
2857
|
+
// src/rules/_is-present.ts
|
|
2858
|
+
function isPresent(value) {
|
|
2859
|
+
return value !== null && value !== void 0;
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2857
2862
|
// src/rules/no-mutating-input-with-result.ts
|
|
2858
2863
|
import { AST_NODE_TYPES as AST_NODE_TYPES20, ASTUtils as ASTUtils8 } from "@typescript-eslint/utils";
|
|
2859
2864
|
var NO_MUTATING_INPUT_WITH_RESULT_DOCUMENTATION = {
|
|
@@ -2958,7 +2963,7 @@ var no_mutating_input_with_result_default = createRule({
|
|
|
2958
2963
|
if (annotation === void 0 || command(annotation) || node.body === void 0) return;
|
|
2959
2964
|
const inputs = /* @__PURE__ */ new Map();
|
|
2960
2965
|
for (const parameter of node.params) {
|
|
2961
|
-
if (parameter.type !== AST_NODE_TYPES20.Identifier || parameter.typeAnnotation
|
|
2966
|
+
if (parameter.type !== AST_NODE_TYPES20.Identifier || !isPresent(parameter.typeAnnotation)) continue;
|
|
2962
2967
|
const variable = ASTUtils8.findVariable(sourceCode.getScope(parameter), parameter.name);
|
|
2963
2968
|
if (variable === null || variable.references.some((reference) => reference.isWrite())) continue;
|
|
2964
2969
|
const names = fields(parameter.typeAnnotation.typeAnnotation, sourceCode);
|
|
@@ -4469,7 +4474,7 @@ var no_mutating_container_transform_default = createRule({
|
|
|
4469
4474
|
if (node.body?.type !== AST_NODE_TYPES35.BlockStatement || !returnsArray(node, sourceCode) || !supported(node.body.body)) return;
|
|
4470
4475
|
const initial = /* @__PURE__ */ new Map();
|
|
4471
4476
|
for (const parameter of node.params) {
|
|
4472
|
-
if (parameter.type !== AST_NODE_TYPES35.Identifier || parameter.typeAnnotation
|
|
4477
|
+
if (parameter.type !== AST_NODE_TYPES35.Identifier || !isPresent(parameter.typeAnnotation)) continue;
|
|
4473
4478
|
const element = arrayElement(parameter.typeAnnotation.typeAnnotation, sourceCode);
|
|
4474
4479
|
const variable = binding3(parameter);
|
|
4475
4480
|
if (element !== null && PRIMITIVES.has(element.type) && variable !== null) initial.set(variable, parameter.name);
|
|
@@ -6082,7 +6087,7 @@ function isSearchParamReceiver(call, services) {
|
|
|
6082
6087
|
// package.json
|
|
6083
6088
|
var package_default = {
|
|
6084
6089
|
name: "@sarj/eslint-plugin",
|
|
6085
|
-
version: "18.1.
|
|
6090
|
+
version: "18.1.4",
|
|
6086
6091
|
packageManager: "npm@12.2.1",
|
|
6087
6092
|
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
6088
6093
|
type: "module",
|
|
@@ -26337,7 +26342,7 @@ function discriminatedUnionReturns(node, sourceCode) {
|
|
|
26337
26342
|
}
|
|
26338
26343
|
function returnContract(node, sourceCode) {
|
|
26339
26344
|
const annotation = node.returnType;
|
|
26340
|
-
if (annotation
|
|
26345
|
+
if (!isPresent(annotation)) return void 0;
|
|
26341
26346
|
let type = annotation.typeAnnotation;
|
|
26342
26347
|
if (node.async && type.type === AST_NODE_TYPES138.TSTypeReference && type.typeName.type === AST_NODE_TYPES138.Identifier && type.typeName.name === "Promise" && type.typeArguments?.params.length === 1 && definitions(type, sourceCode).length === 0) {
|
|
26343
26348
|
const inner = type.typeArguments.params[0];
|
|
@@ -29427,7 +29432,7 @@ function checkBoundary(node, context) {
|
|
|
29427
29432
|
const roles = /* @__PURE__ */ new Map();
|
|
29428
29433
|
for (const parameter of node.params) {
|
|
29429
29434
|
const identifier = parameterIdentifier(parameter);
|
|
29430
|
-
if (identifier?.typeAnnotation
|
|
29435
|
+
if (!isPresent(identifier?.typeAnnotation)) continue;
|
|
29431
29436
|
const role = identifierRole(identifier.name);
|
|
29432
29437
|
if (role === void 0) continue;
|
|
29433
29438
|
const carrier = rawCarrier(
|
|
@@ -30581,7 +30586,7 @@ function processOwnershipValue(identifier, source, graph) {
|
|
|
30581
30586
|
if (binding3 === null || graph.values.has(binding3)) return;
|
|
30582
30587
|
graph.values.add(binding3);
|
|
30583
30588
|
const annotation = exportedValueAnnotation(source, identifier);
|
|
30584
|
-
if (annotation
|
|
30589
|
+
if (isPresent(annotation)) graph.pending.push({ kind: "syntax", node: annotation });
|
|
30585
30590
|
const resolved = exportedCallable(source, identifier, graph.cache);
|
|
30586
30591
|
if (resolved === null) return;
|
|
30587
30592
|
if (resolved.callable !== null) graph.callables.add(resolved.callable);
|
|
@@ -30667,7 +30672,7 @@ function exportedCallable(source, identifier, cache) {
|
|
|
30667
30672
|
}
|
|
30668
30673
|
const step = constantCallableStep(binding3);
|
|
30669
30674
|
if (step === null) break;
|
|
30670
|
-
if (step.annotation
|
|
30675
|
+
if (isPresent(step.annotation)) annotations.push(step.annotation);
|
|
30671
30676
|
if (isFunctionNode2(step.target)) {
|
|
30672
30677
|
target = { callable: step.target, signatures: [step.target] };
|
|
30673
30678
|
break;
|
|
@@ -30706,11 +30711,11 @@ function valueBinding(source, identifier) {
|
|
|
30706
30711
|
}
|
|
30707
30712
|
function callableAnnotations(callable) {
|
|
30708
30713
|
const annotations = [];
|
|
30709
|
-
if (callable.returnType
|
|
30710
|
-
if (callable.typeParameters
|
|
30714
|
+
if (isPresent(callable.returnType)) annotations.push(callable.returnType);
|
|
30715
|
+
if (isPresent(callable.typeParameters)) annotations.push(callable.typeParameters);
|
|
30711
30716
|
for (const raw of callable.params) {
|
|
30712
30717
|
const parameter = raw.type === AST_NODE_TYPES157.AssignmentPattern ? raw.left : raw;
|
|
30713
|
-
if ((parameter.type === AST_NODE_TYPES157.Identifier || parameter.type === AST_NODE_TYPES157.ObjectPattern || parameter.type === AST_NODE_TYPES157.ArrayPattern || parameter.type === AST_NODE_TYPES157.RestElement) && parameter.typeAnnotation
|
|
30718
|
+
if ((parameter.type === AST_NODE_TYPES157.Identifier || parameter.type === AST_NODE_TYPES157.ObjectPattern || parameter.type === AST_NODE_TYPES157.ArrayPattern || parameter.type === AST_NODE_TYPES157.RestElement) && isPresent(parameter.typeAnnotation)) annotations.push(parameter.typeAnnotation);
|
|
30714
30719
|
}
|
|
30715
30720
|
return annotations;
|
|
30716
30721
|
}
|