@sarj/eslint-plugin 16.2.0 → 16.2.1
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 +8 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -728,7 +728,7 @@ var no_reduce_accumulator_copy_default = createRule({
|
|
|
728
728
|
if (!accumulator || accumulator.references.some((reference) => reference.isWrite())) return;
|
|
729
729
|
const referencesAccumulator = (value) => value.type === import_utils5.AST_NODE_TYPES.Identifier && import_utils5.ASTUtils.findVariable(context.sourceCode.getScope(value), value.name) === accumulator;
|
|
730
730
|
const inspect = (current) => {
|
|
731
|
-
if (current !== callback.body && [import_utils5.AST_NODE_TYPES.ArrowFunctionExpression, import_utils5.AST_NODE_TYPES.FunctionExpression, import_utils5.AST_NODE_TYPES.FunctionDeclaration].some((kind) => kind === current.type)) return;
|
|
731
|
+
if (current !== callback.body && [import_utils5.AST_NODE_TYPES.ArrowFunctionExpression, import_utils5.AST_NODE_TYPES.FunctionExpression, import_utils5.AST_NODE_TYPES.FunctionDeclaration, import_utils5.AST_NODE_TYPES.ClassDeclaration, import_utils5.AST_NODE_TYPES.ClassExpression, import_utils5.AST_NODE_TYPES.ForStatement, import_utils5.AST_NODE_TYPES.ForInStatement, import_utils5.AST_NODE_TYPES.ForOfStatement, import_utils5.AST_NODE_TYPES.WhileStatement, import_utils5.AST_NODE_TYPES.DoWhileStatement].some((kind) => kind === current.type)) return;
|
|
732
732
|
if (current.type === import_utils5.AST_NODE_TYPES.SpreadElement && (arraySeed && current.parent.type === import_utils5.AST_NODE_TYPES.ArrayExpression || objectSeed && current.parent.type === import_utils5.AST_NODE_TYPES.ObjectExpression) && referencesAccumulator(current.argument)) {
|
|
733
733
|
context.report({ node: current, messageId: "copy" });
|
|
734
734
|
}
|
|
@@ -776,6 +776,10 @@ function erasesContract(type, checker) {
|
|
|
776
776
|
const indexes = checker.getIndexInfosOfType(type);
|
|
777
777
|
return indexes.length > 0 && checker.getPropertiesOfType(type).length === 0 && indexes.every((index) => (index.type.flags & import_typescript4.default.TypeFlags.Unknown) !== 0);
|
|
778
778
|
}
|
|
779
|
+
function hasUnknownContract(type, checker) {
|
|
780
|
+
if (type.isUnionOrIntersection()) return type.types.some((part) => hasUnknownContract(part, checker));
|
|
781
|
+
return (type.flags & (import_typescript4.default.TypeFlags.Any | import_typescript4.default.TypeFlags.Unknown | import_typescript4.default.TypeFlags.Never | import_typescript4.default.TypeFlags.TypeParameter | import_typescript4.default.TypeFlags.Conditional | import_typescript4.default.TypeFlags.IndexedAccess | import_typescript4.default.TypeFlags.Substitution)) !== 0 || erasesContract(type, checker);
|
|
782
|
+
}
|
|
779
783
|
var no_known_value_widening_default = createRule({
|
|
780
784
|
name: "no-known-value-widening",
|
|
781
785
|
documentation: NO_KNOWN_VALUE_WIDENING_DOCUMENTATION,
|
|
@@ -796,7 +800,7 @@ var no_known_value_widening_default = createRule({
|
|
|
796
800
|
VariableDeclarator(node) {
|
|
797
801
|
if (node.id.type !== import_utils6.AST_NODE_TYPES.Identifier || !node.id.typeAnnotation || node.init?.type !== import_utils6.AST_NODE_TYPES.Identifier || node.parent.kind !== "const" || node.parent.parent.type === import_utils6.AST_NODE_TYPES.ExportNamedDeclaration) return;
|
|
798
802
|
const source = checker.getTypeAtLocation(services.esTreeNodeToTSNodeMap.get(node.init));
|
|
799
|
-
if ((source
|
|
803
|
+
if (hasUnknownContract(source, checker)) return;
|
|
800
804
|
const target = checker.getTypeAtLocation(services.esTreeNodeToTSNodeMap.get(node.id.typeAnnotation.typeAnnotation));
|
|
801
805
|
if (erasesContract(target, checker)) context.report({ node: node.id.typeAnnotation, messageId: "widening" });
|
|
802
806
|
}
|
|
@@ -1048,7 +1052,7 @@ var REQUIRE_CAMELCASE_PROPERTIES_DOCUMENTATION = {
|
|
|
1048
1052
|
autofix: "none",
|
|
1049
1053
|
limitations: [
|
|
1050
1054
|
"Quoted string keys and bracket access are treated as explicit external-wire boundaries.",
|
|
1051
|
-
"Computed, numeric, symbol, private, generated,
|
|
1055
|
+
"Computed, numeric, symbol, private, generated, and PascalCase property names are excluded. External-library ownership is not inferred: preserve its spelling using quoted keys and bracket access, or an exact local suppression.",
|
|
1052
1056
|
"Renaming a property can cross module or protocol boundaries, so the rule does not autofix."
|
|
1053
1057
|
],
|
|
1054
1058
|
examples: [
|
|
@@ -23477,7 +23481,7 @@ var RULES = {
|
|
|
23477
23481
|
};
|
|
23478
23482
|
var meta = {
|
|
23479
23483
|
name: "@sarj/eslint-plugin",
|
|
23480
|
-
version: "16.2.
|
|
23484
|
+
version: "16.2.1"
|
|
23481
23485
|
};
|
|
23482
23486
|
var APPLICATION_ONLY_RULES = [];
|
|
23483
23487
|
var LIBRARY_IMPORT_POLICY = ["error", {
|
package/dist/index.d.cts
CHANGED
|
@@ -916,7 +916,7 @@ type FlatPreset = {
|
|
|
916
916
|
declare const PLUGIN: {
|
|
917
917
|
readonly meta: {
|
|
918
918
|
readonly name: "@sarj/eslint-plugin";
|
|
919
|
-
readonly version: "16.2.
|
|
919
|
+
readonly version: "16.2.1";
|
|
920
920
|
};
|
|
921
921
|
readonly rules: {
|
|
922
922
|
readonly "no-conditional-empty-object-spread": DocumentedRule<[], "avoid">;
|
package/dist/index.d.ts
CHANGED
|
@@ -916,7 +916,7 @@ type FlatPreset = {
|
|
|
916
916
|
declare const PLUGIN: {
|
|
917
917
|
readonly meta: {
|
|
918
918
|
readonly name: "@sarj/eslint-plugin";
|
|
919
|
-
readonly version: "16.2.
|
|
919
|
+
readonly version: "16.2.1";
|
|
920
920
|
};
|
|
921
921
|
readonly rules: {
|
|
922
922
|
readonly "no-conditional-empty-object-spread": DocumentedRule<[], "avoid">;
|
package/dist/index.js
CHANGED
|
@@ -684,7 +684,7 @@ var no_reduce_accumulator_copy_default = createRule({
|
|
|
684
684
|
if (!accumulator || accumulator.references.some((reference) => reference.isWrite())) return;
|
|
685
685
|
const referencesAccumulator = (value) => value.type === AST_NODE_TYPES4.Identifier && ASTUtils2.findVariable(context.sourceCode.getScope(value), value.name) === accumulator;
|
|
686
686
|
const inspect = (current) => {
|
|
687
|
-
if (current !== callback.body && [AST_NODE_TYPES4.ArrowFunctionExpression, AST_NODE_TYPES4.FunctionExpression, AST_NODE_TYPES4.FunctionDeclaration].some((kind) => kind === current.type)) return;
|
|
687
|
+
if (current !== callback.body && [AST_NODE_TYPES4.ArrowFunctionExpression, AST_NODE_TYPES4.FunctionExpression, AST_NODE_TYPES4.FunctionDeclaration, AST_NODE_TYPES4.ClassDeclaration, AST_NODE_TYPES4.ClassExpression, AST_NODE_TYPES4.ForStatement, AST_NODE_TYPES4.ForInStatement, AST_NODE_TYPES4.ForOfStatement, AST_NODE_TYPES4.WhileStatement, AST_NODE_TYPES4.DoWhileStatement].some((kind) => kind === current.type)) return;
|
|
688
688
|
if (current.type === AST_NODE_TYPES4.SpreadElement && (arraySeed && current.parent.type === AST_NODE_TYPES4.ArrayExpression || objectSeed && current.parent.type === AST_NODE_TYPES4.ObjectExpression) && referencesAccumulator(current.argument)) {
|
|
689
689
|
context.report({ node: current, messageId: "copy" });
|
|
690
690
|
}
|
|
@@ -732,6 +732,10 @@ function erasesContract(type, checker) {
|
|
|
732
732
|
const indexes = checker.getIndexInfosOfType(type);
|
|
733
733
|
return indexes.length > 0 && checker.getPropertiesOfType(type).length === 0 && indexes.every((index) => (index.type.flags & ts4.TypeFlags.Unknown) !== 0);
|
|
734
734
|
}
|
|
735
|
+
function hasUnknownContract(type, checker) {
|
|
736
|
+
if (type.isUnionOrIntersection()) return type.types.some((part) => hasUnknownContract(part, checker));
|
|
737
|
+
return (type.flags & (ts4.TypeFlags.Any | ts4.TypeFlags.Unknown | ts4.TypeFlags.Never | ts4.TypeFlags.TypeParameter | ts4.TypeFlags.Conditional | ts4.TypeFlags.IndexedAccess | ts4.TypeFlags.Substitution)) !== 0 || erasesContract(type, checker);
|
|
738
|
+
}
|
|
735
739
|
var no_known_value_widening_default = createRule({
|
|
736
740
|
name: "no-known-value-widening",
|
|
737
741
|
documentation: NO_KNOWN_VALUE_WIDENING_DOCUMENTATION,
|
|
@@ -752,7 +756,7 @@ var no_known_value_widening_default = createRule({
|
|
|
752
756
|
VariableDeclarator(node) {
|
|
753
757
|
if (node.id.type !== AST_NODE_TYPES5.Identifier || !node.id.typeAnnotation || node.init?.type !== AST_NODE_TYPES5.Identifier || node.parent.kind !== "const" || node.parent.parent.type === AST_NODE_TYPES5.ExportNamedDeclaration) return;
|
|
754
758
|
const source = checker.getTypeAtLocation(services.esTreeNodeToTSNodeMap.get(node.init));
|
|
755
|
-
if ((source
|
|
759
|
+
if (hasUnknownContract(source, checker)) return;
|
|
756
760
|
const target = checker.getTypeAtLocation(services.esTreeNodeToTSNodeMap.get(node.id.typeAnnotation.typeAnnotation));
|
|
757
761
|
if (erasesContract(target, checker)) context.report({ node: node.id.typeAnnotation, messageId: "widening" });
|
|
758
762
|
}
|
|
@@ -1007,7 +1011,7 @@ var REQUIRE_CAMELCASE_PROPERTIES_DOCUMENTATION = {
|
|
|
1007
1011
|
autofix: "none",
|
|
1008
1012
|
limitations: [
|
|
1009
1013
|
"Quoted string keys and bracket access are treated as explicit external-wire boundaries.",
|
|
1010
|
-
"Computed, numeric, symbol, private, generated,
|
|
1014
|
+
"Computed, numeric, symbol, private, generated, and PascalCase property names are excluded. External-library ownership is not inferred: preserve its spelling using quoted keys and bracket access, or an exact local suppression.",
|
|
1011
1015
|
"Renaming a property can cross module or protocol boundaries, so the rule does not autofix."
|
|
1012
1016
|
],
|
|
1013
1017
|
examples: [
|
|
@@ -23498,7 +23502,7 @@ var RULES = {
|
|
|
23498
23502
|
};
|
|
23499
23503
|
var meta = {
|
|
23500
23504
|
name: "@sarj/eslint-plugin",
|
|
23501
|
-
version: "16.2.
|
|
23505
|
+
version: "16.2.1"
|
|
23502
23506
|
};
|
|
23503
23507
|
var APPLICATION_ONLY_RULES = [];
|
|
23504
23508
|
var LIBRARY_IMPORT_POLICY = ["error", {
|