eslint-plugin-nextfriday 4.1.0 → 4.2.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/CHANGELOG.md +12 -0
- package/README.md +13 -5
- package/docs/rules/ENFORCE_RENDER_NAMING.md +96 -0
- package/docs/rules/JSX_NO_DATA_ARRAY.md +63 -0
- package/docs/rules/JSX_NO_DATA_OBJECT.md +71 -0
- package/docs/rules/JSX_NO_SUB_INTERFACE.md +86 -0
- package/lib/index.cjs +923 -454
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +168 -0
- package/lib/index.d.ts +168 -0
- package/lib/index.js +923 -454
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "eslint-plugin-nextfriday",
|
|
4
|
-
version: "4.
|
|
4
|
+
version: "4.2.0",
|
|
5
5
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
6
6
|
keywords: [
|
|
7
7
|
"eslint",
|
|
@@ -765,18 +765,168 @@ var enforceReadonlyComponentProps = createRule7({
|
|
|
765
765
|
});
|
|
766
766
|
var enforce_readonly_component_props_default = enforceReadonlyComponentProps;
|
|
767
767
|
|
|
768
|
-
// src/rules/enforce-
|
|
768
|
+
// src/rules/enforce-render-naming.ts
|
|
769
769
|
import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as ESLintUtils8 } from "@typescript-eslint/utils";
|
|
770
770
|
var createRule8 = ESLintUtils8.RuleCreator(
|
|
771
771
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
772
772
|
);
|
|
773
|
+
var ARRAY_RETURNING_METHODS = /* @__PURE__ */ new Set(["map", "flatMap", "filter"]);
|
|
774
|
+
function hasRenderPrefix(name) {
|
|
775
|
+
if (!name.startsWith("render")) {
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
if (name.length === "render".length) {
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
const nextChar = name["render".length];
|
|
782
|
+
return nextChar === nextChar.toUpperCase() && nextChar !== nextChar.toLowerCase();
|
|
783
|
+
}
|
|
784
|
+
function functionBodyReturnsJsx(body) {
|
|
785
|
+
if (body.type === AST_NODE_TYPES9.JSXElement || body.type === AST_NODE_TYPES9.JSXFragment) {
|
|
786
|
+
return true;
|
|
787
|
+
}
|
|
788
|
+
if (body.type === AST_NODE_TYPES9.ConditionalExpression) {
|
|
789
|
+
return isJsxProducingExpression(body.consequent) || isJsxProducingExpression(body.alternate);
|
|
790
|
+
}
|
|
791
|
+
if (body.type === AST_NODE_TYPES9.LogicalExpression) {
|
|
792
|
+
return isJsxProducingExpression(body.right);
|
|
793
|
+
}
|
|
794
|
+
if (body.type !== AST_NODE_TYPES9.BlockStatement) {
|
|
795
|
+
return false;
|
|
796
|
+
}
|
|
797
|
+
for (const statement of body.body) {
|
|
798
|
+
if (statement.type === AST_NODE_TYPES9.ReturnStatement && statement.argument) {
|
|
799
|
+
if (isJsxProducingExpression(statement.argument)) {
|
|
800
|
+
return true;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
function isJsxProducingExpression(node) {
|
|
807
|
+
if (node.type === AST_NODE_TYPES9.JSXElement || node.type === AST_NODE_TYPES9.JSXFragment) {
|
|
808
|
+
return true;
|
|
809
|
+
}
|
|
810
|
+
if (node.type === AST_NODE_TYPES9.ConditionalExpression) {
|
|
811
|
+
return isJsxProducingExpression(node.consequent) || isJsxProducingExpression(node.alternate);
|
|
812
|
+
}
|
|
813
|
+
if (node.type === AST_NODE_TYPES9.LogicalExpression) {
|
|
814
|
+
return isJsxProducingExpression(node.right);
|
|
815
|
+
}
|
|
816
|
+
if (node.type === AST_NODE_TYPES9.ArrayExpression) {
|
|
817
|
+
return node.elements.some((element) => {
|
|
818
|
+
if (!element || element.type === AST_NODE_TYPES9.SpreadElement) {
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
return isJsxProducingExpression(element);
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
if (node.type === AST_NODE_TYPES9.ArrowFunctionExpression || node.type === AST_NODE_TYPES9.FunctionExpression) {
|
|
825
|
+
return functionBodyReturnsJsx(node.body);
|
|
826
|
+
}
|
|
827
|
+
if (node.type === AST_NODE_TYPES9.CallExpression) {
|
|
828
|
+
if (node.callee.type === AST_NODE_TYPES9.MemberExpression && node.callee.property.type === AST_NODE_TYPES9.Identifier && ARRAY_RETURNING_METHODS.has(node.callee.property.name)) {
|
|
829
|
+
const callback = node.arguments[0];
|
|
830
|
+
if (callback && (callback.type === AST_NODE_TYPES9.ArrowFunctionExpression || callback.type === AST_NODE_TYPES9.FunctionExpression)) {
|
|
831
|
+
return functionBodyReturnsJsx(callback.body);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
if (node.type === AST_NODE_TYPES9.TSAsExpression || node.type === AST_NODE_TYPES9.TSSatisfiesExpression) {
|
|
836
|
+
return isJsxProducingExpression(node.expression);
|
|
837
|
+
}
|
|
838
|
+
return false;
|
|
839
|
+
}
|
|
840
|
+
function isPascalCase(name) {
|
|
841
|
+
return /^[A-Z]/.test(name);
|
|
842
|
+
}
|
|
843
|
+
function isComponentFunction2(node) {
|
|
844
|
+
if (node.type === AST_NODE_TYPES9.FunctionDeclaration && node.id && isPascalCase(node.id.name)) {
|
|
845
|
+
return true;
|
|
846
|
+
}
|
|
847
|
+
const parent = node.parent;
|
|
848
|
+
if (parent?.type === AST_NODE_TYPES9.VariableDeclarator && parent.id.type === AST_NODE_TYPES9.Identifier && isPascalCase(parent.id.name)) {
|
|
849
|
+
return true;
|
|
850
|
+
}
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
var enforceRenderNaming = createRule8({
|
|
854
|
+
name: "enforce-render-naming",
|
|
855
|
+
meta: {
|
|
856
|
+
type: "problem",
|
|
857
|
+
docs: {
|
|
858
|
+
description: "Enforce 'render' prefix for variables that hold or return JSX inside React components"
|
|
859
|
+
},
|
|
860
|
+
schema: [],
|
|
861
|
+
messages: {
|
|
862
|
+
missingRenderPrefix: "Variable '{{ name }}' holds JSX-producing content inside a component. Rename it to 'render{{ pascalName }}' so the intent is explicit."
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
defaultOptions: [],
|
|
866
|
+
create(context) {
|
|
867
|
+
const { filename } = context;
|
|
868
|
+
const extension = getFileExtension(filename);
|
|
869
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
870
|
+
return {};
|
|
871
|
+
}
|
|
872
|
+
const componentStack = [];
|
|
873
|
+
function isInsideComponent() {
|
|
874
|
+
return componentStack.some((value) => value);
|
|
875
|
+
}
|
|
876
|
+
function pushFunction(node) {
|
|
877
|
+
componentStack.push(isComponentFunction2(node));
|
|
878
|
+
}
|
|
879
|
+
function popFunction() {
|
|
880
|
+
componentStack.pop();
|
|
881
|
+
}
|
|
882
|
+
return {
|
|
883
|
+
ArrowFunctionExpression: pushFunction,
|
|
884
|
+
FunctionDeclaration: pushFunction,
|
|
885
|
+
FunctionExpression: pushFunction,
|
|
886
|
+
"ArrowFunctionExpression:exit": popFunction,
|
|
887
|
+
"FunctionDeclaration:exit": popFunction,
|
|
888
|
+
"FunctionExpression:exit": popFunction,
|
|
889
|
+
VariableDeclarator(node) {
|
|
890
|
+
if (!isInsideComponent()) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
if (node.id.type !== AST_NODE_TYPES9.Identifier) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (!node.init) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (!isJsxProducingExpression(node.init)) {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
const name = node.id.name;
|
|
903
|
+
if (hasRenderPrefix(name)) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
const pascalName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
907
|
+
context.report({
|
|
908
|
+
node: node.id,
|
|
909
|
+
messageId: "missingRenderPrefix",
|
|
910
|
+
data: { name, pascalName }
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
var enforce_render_naming_default = enforceRenderNaming;
|
|
917
|
+
|
|
918
|
+
// src/rules/enforce-service-naming.ts
|
|
919
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES10, ESLintUtils as ESLintUtils9 } from "@typescript-eslint/utils";
|
|
920
|
+
var createRule9 = ESLintUtils9.RuleCreator(
|
|
921
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
922
|
+
);
|
|
773
923
|
var BANNED_PREFIXES = {
|
|
774
924
|
delete: ["remove", "archive"],
|
|
775
925
|
do: ["submit", "process"],
|
|
776
926
|
handle: ["create", "verify"],
|
|
777
927
|
set: ["update", "save", "patch"]
|
|
778
928
|
};
|
|
779
|
-
var enforceServiceNaming =
|
|
929
|
+
var enforceServiceNaming = createRule9({
|
|
780
930
|
name: "enforce-service-naming",
|
|
781
931
|
meta: {
|
|
782
932
|
type: "suggestion",
|
|
@@ -819,12 +969,12 @@ var enforceServiceNaming = createRule8({
|
|
|
819
969
|
};
|
|
820
970
|
return {
|
|
821
971
|
ExportNamedDeclaration(node) {
|
|
822
|
-
if (node.declaration?.type ===
|
|
972
|
+
if (node.declaration?.type === AST_NODE_TYPES10.FunctionDeclaration && node.declaration.id) {
|
|
823
973
|
checkExportedFunction(node.declaration, node.declaration.id);
|
|
824
974
|
}
|
|
825
|
-
if (node.declaration?.type ===
|
|
975
|
+
if (node.declaration?.type === AST_NODE_TYPES10.VariableDeclaration) {
|
|
826
976
|
node.declaration.declarations.forEach((declarator) => {
|
|
827
|
-
if (declarator.id.type ===
|
|
977
|
+
if (declarator.id.type === AST_NODE_TYPES10.Identifier && declarator.init?.type === AST_NODE_TYPES10.ArrowFunctionExpression) {
|
|
828
978
|
checkExportedFunction(declarator.init, declarator.id);
|
|
829
979
|
}
|
|
830
980
|
});
|
|
@@ -836,11 +986,11 @@ var enforceServiceNaming = createRule8({
|
|
|
836
986
|
var enforce_service_naming_default = enforceServiceNaming;
|
|
837
987
|
|
|
838
988
|
// src/rules/enforce-sorted-destructuring.ts
|
|
839
|
-
import { AST_NODE_TYPES as
|
|
840
|
-
var
|
|
989
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES11, ESLintUtils as ESLintUtils10 } from "@typescript-eslint/utils";
|
|
990
|
+
var createRule10 = ESLintUtils10.RuleCreator(
|
|
841
991
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
842
992
|
);
|
|
843
|
-
var enforceSortedDestructuring =
|
|
993
|
+
var enforceSortedDestructuring = createRule10({
|
|
844
994
|
name: "enforce-sorted-destructuring",
|
|
845
995
|
meta: {
|
|
846
996
|
type: "suggestion",
|
|
@@ -856,19 +1006,19 @@ var enforceSortedDestructuring = createRule9({
|
|
|
856
1006
|
defaultOptions: [],
|
|
857
1007
|
create(context) {
|
|
858
1008
|
function getPropertyName(property) {
|
|
859
|
-
if (property.type ===
|
|
1009
|
+
if (property.type === AST_NODE_TYPES11.RestElement) {
|
|
860
1010
|
return null;
|
|
861
1011
|
}
|
|
862
|
-
if (property.key.type ===
|
|
1012
|
+
if (property.key.type === AST_NODE_TYPES11.Identifier) {
|
|
863
1013
|
return property.key.name;
|
|
864
1014
|
}
|
|
865
1015
|
return null;
|
|
866
1016
|
}
|
|
867
1017
|
function hasDefaultValue(property) {
|
|
868
|
-
return property.value.type ===
|
|
1018
|
+
return property.value.type === AST_NODE_TYPES11.AssignmentPattern && Boolean(property.value.right);
|
|
869
1019
|
}
|
|
870
1020
|
function checkVariableDeclarator(node) {
|
|
871
|
-
if (node.id.type !==
|
|
1021
|
+
if (node.id.type !== AST_NODE_TYPES11.ObjectPattern) {
|
|
872
1022
|
return;
|
|
873
1023
|
}
|
|
874
1024
|
const { properties } = node.id;
|
|
@@ -876,7 +1026,7 @@ var enforceSortedDestructuring = createRule9({
|
|
|
876
1026
|
return;
|
|
877
1027
|
}
|
|
878
1028
|
const propertyInfo = properties.map((prop) => {
|
|
879
|
-
if (prop.type ===
|
|
1029
|
+
if (prop.type === AST_NODE_TYPES11.RestElement) {
|
|
880
1030
|
return null;
|
|
881
1031
|
}
|
|
882
1032
|
return {
|
|
@@ -915,20 +1065,20 @@ var enforceSortedDestructuring = createRule9({
|
|
|
915
1065
|
var enforce_sorted_destructuring_default = enforceSortedDestructuring;
|
|
916
1066
|
|
|
917
1067
|
// src/rules/enforce-type-declaration-order.ts
|
|
918
|
-
import { AST_NODE_TYPES as
|
|
919
|
-
var
|
|
1068
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES12, ESLintUtils as ESLintUtils11 } from "@typescript-eslint/utils";
|
|
1069
|
+
var createRule11 = ESLintUtils11.RuleCreator(
|
|
920
1070
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
921
1071
|
);
|
|
922
1072
|
function getTypeDeclarationName(node) {
|
|
923
|
-
if (node.type ===
|
|
1073
|
+
if (node.type === AST_NODE_TYPES12.TSInterfaceDeclaration && node.id.type === AST_NODE_TYPES12.Identifier) {
|
|
924
1074
|
return { name: node.id.name, position: node.range[0] };
|
|
925
1075
|
}
|
|
926
|
-
if (node.type ===
|
|
1076
|
+
if (node.type === AST_NODE_TYPES12.TSTypeAliasDeclaration && node.id.type === AST_NODE_TYPES12.Identifier) {
|
|
927
1077
|
return { name: node.id.name, position: node.range[0] };
|
|
928
1078
|
}
|
|
929
1079
|
return null;
|
|
930
1080
|
}
|
|
931
|
-
var enforceTypeDeclarationOrder =
|
|
1081
|
+
var enforceTypeDeclarationOrder = createRule11({
|
|
932
1082
|
name: "enforce-type-declaration-order",
|
|
933
1083
|
meta: {
|
|
934
1084
|
type: "suggestion",
|
|
@@ -959,7 +1109,7 @@ var enforceTypeDeclarationOrder = createRule10({
|
|
|
959
1109
|
}
|
|
960
1110
|
},
|
|
961
1111
|
"TSPropertySignature TSTypeReference": function checkTypeReference(node) {
|
|
962
|
-
if (node.typeName.type !==
|
|
1112
|
+
if (node.typeName.type !== AST_NODE_TYPES12.Identifier) {
|
|
963
1113
|
return;
|
|
964
1114
|
}
|
|
965
1115
|
const referencedName = node.typeName.name;
|
|
@@ -996,8 +1146,8 @@ var enforceTypeDeclarationOrder = createRule10({
|
|
|
996
1146
|
var enforce_type_declaration_order_default = enforceTypeDeclarationOrder;
|
|
997
1147
|
|
|
998
1148
|
// src/rules/index-export-only.ts
|
|
999
|
-
import { AST_NODE_TYPES as
|
|
1000
|
-
var
|
|
1149
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES13, ESLintUtils as ESLintUtils12 } from "@typescript-eslint/utils";
|
|
1150
|
+
var createRule12 = ESLintUtils12.RuleCreator(
|
|
1001
1151
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1002
1152
|
);
|
|
1003
1153
|
var isIndexFile = (filename) => getBaseName(filename) === "index";
|
|
@@ -1005,26 +1155,26 @@ var isAllowedExportNamed = (node) => {
|
|
|
1005
1155
|
if (!node.declaration) {
|
|
1006
1156
|
return true;
|
|
1007
1157
|
}
|
|
1008
|
-
return node.declaration.type ===
|
|
1158
|
+
return node.declaration.type === AST_NODE_TYPES13.TSTypeAliasDeclaration || node.declaration.type === AST_NODE_TYPES13.TSInterfaceDeclaration;
|
|
1009
1159
|
};
|
|
1010
|
-
var isAllowedExportDefault = (node) => node.declaration.type ===
|
|
1160
|
+
var isAllowedExportDefault = (node) => node.declaration.type === AST_NODE_TYPES13.Identifier;
|
|
1011
1161
|
var isAllowedTopLevel = (node) => {
|
|
1012
1162
|
switch (node.type) {
|
|
1013
|
-
case
|
|
1014
|
-
case
|
|
1015
|
-
case
|
|
1016
|
-
case
|
|
1017
|
-
case
|
|
1163
|
+
case AST_NODE_TYPES13.ImportDeclaration:
|
|
1164
|
+
case AST_NODE_TYPES13.ExportAllDeclaration:
|
|
1165
|
+
case AST_NODE_TYPES13.TSTypeAliasDeclaration:
|
|
1166
|
+
case AST_NODE_TYPES13.TSInterfaceDeclaration:
|
|
1167
|
+
case AST_NODE_TYPES13.TSImportEqualsDeclaration:
|
|
1018
1168
|
return true;
|
|
1019
|
-
case
|
|
1169
|
+
case AST_NODE_TYPES13.ExportNamedDeclaration:
|
|
1020
1170
|
return isAllowedExportNamed(node);
|
|
1021
|
-
case
|
|
1171
|
+
case AST_NODE_TYPES13.ExportDefaultDeclaration:
|
|
1022
1172
|
return isAllowedExportDefault(node);
|
|
1023
1173
|
default:
|
|
1024
1174
|
return false;
|
|
1025
1175
|
}
|
|
1026
1176
|
};
|
|
1027
|
-
var indexExportOnly =
|
|
1177
|
+
var indexExportOnly = createRule12({
|
|
1028
1178
|
name: "index-export-only",
|
|
1029
1179
|
meta: {
|
|
1030
1180
|
type: "suggestion",
|
|
@@ -1058,11 +1208,11 @@ var indexExportOnly = createRule11({
|
|
|
1058
1208
|
var index_export_only_default = indexExportOnly;
|
|
1059
1209
|
|
|
1060
1210
|
// src/rules/jsx-newline-between-elements.ts
|
|
1061
|
-
import { AST_NODE_TYPES as
|
|
1062
|
-
var
|
|
1211
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14, ESLintUtils as ESLintUtils13 } from "@typescript-eslint/utils";
|
|
1212
|
+
var createRule13 = ESLintUtils13.RuleCreator(
|
|
1063
1213
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1064
1214
|
);
|
|
1065
|
-
var jsxNewlineBetweenElements =
|
|
1215
|
+
var jsxNewlineBetweenElements = createRule13({
|
|
1066
1216
|
name: "jsx-newline-between-elements",
|
|
1067
1217
|
meta: {
|
|
1068
1218
|
type: "layout",
|
|
@@ -1080,7 +1230,7 @@ var jsxNewlineBetweenElements = createRule12({
|
|
|
1080
1230
|
create(context) {
|
|
1081
1231
|
const { sourceCode } = context;
|
|
1082
1232
|
function isSignificantJSXChild(node) {
|
|
1083
|
-
return node.type ===
|
|
1233
|
+
return node.type === AST_NODE_TYPES14.JSXElement || node.type === AST_NODE_TYPES14.JSXFragment || node.type === AST_NODE_TYPES14.JSXExpressionContainer;
|
|
1084
1234
|
}
|
|
1085
1235
|
function isMultiLine(node) {
|
|
1086
1236
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1129,12 +1279,194 @@ var jsxNewlineBetweenElements = createRule12({
|
|
|
1129
1279
|
});
|
|
1130
1280
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1131
1281
|
|
|
1282
|
+
// src/rules/jsx-no-data-array.ts
|
|
1283
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15, ESLintUtils as ESLintUtils14 } from "@typescript-eslint/utils";
|
|
1284
|
+
var createRule14 = ESLintUtils14.RuleCreator(
|
|
1285
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1286
|
+
);
|
|
1287
|
+
function isObjectLikeElement(node) {
|
|
1288
|
+
if (!node) {
|
|
1289
|
+
return false;
|
|
1290
|
+
}
|
|
1291
|
+
if (node.type === AST_NODE_TYPES15.ObjectExpression) {
|
|
1292
|
+
return true;
|
|
1293
|
+
}
|
|
1294
|
+
if (node.type === AST_NODE_TYPES15.TSAsExpression || node.type === AST_NODE_TYPES15.TSSatisfiesExpression) {
|
|
1295
|
+
return isObjectLikeElement(node.expression);
|
|
1296
|
+
}
|
|
1297
|
+
return false;
|
|
1298
|
+
}
|
|
1299
|
+
function getArrayInitializer(init) {
|
|
1300
|
+
if (!init) {
|
|
1301
|
+
return null;
|
|
1302
|
+
}
|
|
1303
|
+
if (init.type === AST_NODE_TYPES15.ArrayExpression) {
|
|
1304
|
+
return init;
|
|
1305
|
+
}
|
|
1306
|
+
if (init.type === AST_NODE_TYPES15.TSAsExpression || init.type === AST_NODE_TYPES15.TSSatisfiesExpression) {
|
|
1307
|
+
return getArrayInitializer(init.expression);
|
|
1308
|
+
}
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
var jsxNoDataArray = createRule14({
|
|
1312
|
+
name: "jsx-no-data-array",
|
|
1313
|
+
meta: {
|
|
1314
|
+
type: "problem",
|
|
1315
|
+
docs: {
|
|
1316
|
+
description: "Disallow top-level arrays of object literals in .tsx/.jsx files (extract to a data file)"
|
|
1317
|
+
},
|
|
1318
|
+
schema: [],
|
|
1319
|
+
messages: {
|
|
1320
|
+
noDataArray: "Top-level array of object literals belongs in a data file (e.g. *.data.ts), not a .tsx/.jsx component file. Extract '{{ name }}' to a sibling data module."
|
|
1321
|
+
}
|
|
1322
|
+
},
|
|
1323
|
+
defaultOptions: [],
|
|
1324
|
+
create(context) {
|
|
1325
|
+
const { filename } = context;
|
|
1326
|
+
const extension = getFileExtension(filename);
|
|
1327
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
1328
|
+
return {};
|
|
1329
|
+
}
|
|
1330
|
+
return {
|
|
1331
|
+
"Program > VariableDeclaration > VariableDeclarator": function checkDeclarator(node) {
|
|
1332
|
+
const arrayInit = getArrayInitializer(node.init);
|
|
1333
|
+
if (!arrayInit) {
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
const hasObjectElement = arrayInit.elements.some((element) => isObjectLikeElement(element));
|
|
1337
|
+
if (!hasObjectElement) {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
const name = node.id.type === AST_NODE_TYPES15.Identifier ? node.id.name : "<destructured>";
|
|
1341
|
+
context.report({
|
|
1342
|
+
node,
|
|
1343
|
+
messageId: "noDataArray",
|
|
1344
|
+
data: { name }
|
|
1345
|
+
});
|
|
1346
|
+
},
|
|
1347
|
+
"Program > ExportNamedDeclaration > VariableDeclaration > VariableDeclarator": function checkExportedDeclarator(node) {
|
|
1348
|
+
const arrayInit = getArrayInitializer(node.init);
|
|
1349
|
+
if (!arrayInit) {
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
const hasObjectElement = arrayInit.elements.some((element) => isObjectLikeElement(element));
|
|
1353
|
+
if (!hasObjectElement) {
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
const name = node.id.type === AST_NODE_TYPES15.Identifier ? node.id.name : "<destructured>";
|
|
1357
|
+
context.report({
|
|
1358
|
+
node,
|
|
1359
|
+
messageId: "noDataArray",
|
|
1360
|
+
data: { name }
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
});
|
|
1366
|
+
var jsx_no_data_array_default = jsxNoDataArray;
|
|
1367
|
+
|
|
1368
|
+
// src/rules/jsx-no-data-object.ts
|
|
1369
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES16, ESLintUtils as ESLintUtils15 } from "@typescript-eslint/utils";
|
|
1370
|
+
var createRule15 = ESLintUtils15.RuleCreator(
|
|
1371
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1372
|
+
);
|
|
1373
|
+
function unwrapAssertion(node) {
|
|
1374
|
+
if (!node) {
|
|
1375
|
+
return null;
|
|
1376
|
+
}
|
|
1377
|
+
if (node.type === AST_NODE_TYPES16.TSAsExpression || node.type === AST_NODE_TYPES16.TSSatisfiesExpression) {
|
|
1378
|
+
return unwrapAssertion(node.expression);
|
|
1379
|
+
}
|
|
1380
|
+
return node;
|
|
1381
|
+
}
|
|
1382
|
+
function isNestedValue(value) {
|
|
1383
|
+
const unwrapped = unwrapAssertion(value);
|
|
1384
|
+
if (!unwrapped) {
|
|
1385
|
+
return false;
|
|
1386
|
+
}
|
|
1387
|
+
if (unwrapped.type === AST_NODE_TYPES16.ObjectExpression) {
|
|
1388
|
+
return true;
|
|
1389
|
+
}
|
|
1390
|
+
if (unwrapped.type === AST_NODE_TYPES16.ArrayExpression) {
|
|
1391
|
+
return unwrapped.elements.some((element) => {
|
|
1392
|
+
if (!element || element.type === AST_NODE_TYPES16.SpreadElement) {
|
|
1393
|
+
return false;
|
|
1394
|
+
}
|
|
1395
|
+
const inner = unwrapAssertion(element);
|
|
1396
|
+
return inner?.type === AST_NODE_TYPES16.ObjectExpression || inner?.type === AST_NODE_TYPES16.ArrayExpression;
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
return false;
|
|
1400
|
+
}
|
|
1401
|
+
function hasNestedProperty(object) {
|
|
1402
|
+
return object.properties.some((property) => {
|
|
1403
|
+
if (property.type !== AST_NODE_TYPES16.Property) {
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1406
|
+
if (property.value.type === AST_NODE_TYPES16.AssignmentPattern) {
|
|
1407
|
+
return false;
|
|
1408
|
+
}
|
|
1409
|
+
return isNestedValue(property.value);
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
function getObjectInitializer(init) {
|
|
1413
|
+
const unwrapped = unwrapAssertion(init);
|
|
1414
|
+
if (!unwrapped) {
|
|
1415
|
+
return null;
|
|
1416
|
+
}
|
|
1417
|
+
if (unwrapped.type === AST_NODE_TYPES16.ObjectExpression) {
|
|
1418
|
+
return unwrapped;
|
|
1419
|
+
}
|
|
1420
|
+
return null;
|
|
1421
|
+
}
|
|
1422
|
+
var jsxNoDataObject = createRule15({
|
|
1423
|
+
name: "jsx-no-data-object",
|
|
1424
|
+
meta: {
|
|
1425
|
+
type: "problem",
|
|
1426
|
+
docs: {
|
|
1427
|
+
description: "Disallow top-level nested object literals in .tsx/.jsx files (extract to a data file)"
|
|
1428
|
+
},
|
|
1429
|
+
schema: [],
|
|
1430
|
+
messages: {
|
|
1431
|
+
noDataObject: "Top-level nested object literal belongs in a data file (e.g. *.data.ts), not a .tsx/.jsx component file. Extract '{{ name }}' to a sibling data module."
|
|
1432
|
+
}
|
|
1433
|
+
},
|
|
1434
|
+
defaultOptions: [],
|
|
1435
|
+
create(context) {
|
|
1436
|
+
const { filename } = context;
|
|
1437
|
+
const extension = getFileExtension(filename);
|
|
1438
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
1439
|
+
return {};
|
|
1440
|
+
}
|
|
1441
|
+
function checkDeclarator(node) {
|
|
1442
|
+
const objectInit = getObjectInitializer(node.init);
|
|
1443
|
+
if (!objectInit) {
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
if (!hasNestedProperty(objectInit)) {
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
const name = node.id.type === AST_NODE_TYPES16.Identifier ? node.id.name : "<destructured>";
|
|
1450
|
+
context.report({
|
|
1451
|
+
node,
|
|
1452
|
+
messageId: "noDataObject",
|
|
1453
|
+
data: { name }
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
return {
|
|
1457
|
+
"Program > VariableDeclaration > VariableDeclarator": checkDeclarator,
|
|
1458
|
+
"Program > ExportNamedDeclaration > VariableDeclaration > VariableDeclarator": checkDeclarator
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
var jsx_no_data_object_default = jsxNoDataObject;
|
|
1463
|
+
|
|
1132
1464
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1133
|
-
import { AST_NODE_TYPES as
|
|
1134
|
-
var
|
|
1465
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES17, ESLintUtils as ESLintUtils16 } from "@typescript-eslint/utils";
|
|
1466
|
+
var createRule16 = ESLintUtils16.RuleCreator(
|
|
1135
1467
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1136
1468
|
);
|
|
1137
|
-
var jsxNoInlineObjectProp =
|
|
1469
|
+
var jsxNoInlineObjectProp = createRule16({
|
|
1138
1470
|
name: "jsx-no-inline-object-prop",
|
|
1139
1471
|
meta: {
|
|
1140
1472
|
type: "suggestion",
|
|
@@ -1150,7 +1482,7 @@ var jsxNoInlineObjectProp = createRule13({
|
|
|
1150
1482
|
create(context) {
|
|
1151
1483
|
return {
|
|
1152
1484
|
JSXAttribute(node) {
|
|
1153
|
-
if (node.value?.type ===
|
|
1485
|
+
if (node.value?.type === AST_NODE_TYPES17.JSXExpressionContainer && node.value.expression.type === AST_NODE_TYPES17.ObjectExpression) {
|
|
1154
1486
|
context.report({
|
|
1155
1487
|
node: node.value,
|
|
1156
1488
|
messageId: "noInlineObject"
|
|
@@ -1163,17 +1495,17 @@ var jsxNoInlineObjectProp = createRule13({
|
|
|
1163
1495
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1164
1496
|
|
|
1165
1497
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1166
|
-
import { AST_NODE_TYPES as
|
|
1167
|
-
var
|
|
1498
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES18, ESLintUtils as ESLintUtils17 } from "@typescript-eslint/utils";
|
|
1499
|
+
var createRule17 = ESLintUtils17.RuleCreator(
|
|
1168
1500
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1169
1501
|
);
|
|
1170
1502
|
function isJSXElementOrFragment(node) {
|
|
1171
|
-
return node.type ===
|
|
1503
|
+
return node.type === AST_NODE_TYPES18.JSXElement || node.type === AST_NODE_TYPES18.JSXFragment;
|
|
1172
1504
|
}
|
|
1173
1505
|
function isSingleLine(node) {
|
|
1174
1506
|
return node.loc.start.line === node.loc.end.line;
|
|
1175
1507
|
}
|
|
1176
|
-
var jsxNoNewlineSingleLineElements =
|
|
1508
|
+
var jsxNoNewlineSingleLineElements = createRule17({
|
|
1177
1509
|
name: "jsx-no-newline-single-line-elements",
|
|
1178
1510
|
meta: {
|
|
1179
1511
|
type: "layout",
|
|
@@ -1191,7 +1523,7 @@ var jsxNoNewlineSingleLineElements = createRule14({
|
|
|
1191
1523
|
const { sourceCode } = context;
|
|
1192
1524
|
function checkSiblings(children) {
|
|
1193
1525
|
const nonWhitespace = children.filter(
|
|
1194
|
-
(child) => !(child.type ===
|
|
1526
|
+
(child) => !(child.type === AST_NODE_TYPES18.JSXText && child.value.trim() === "")
|
|
1195
1527
|
);
|
|
1196
1528
|
nonWhitespace.forEach((next, index) => {
|
|
1197
1529
|
if (index === 0) {
|
|
@@ -1242,11 +1574,11 @@ ${indent}`);
|
|
|
1242
1574
|
var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements;
|
|
1243
1575
|
|
|
1244
1576
|
// src/rules/jsx-no-non-component-function.ts
|
|
1245
|
-
import { AST_NODE_TYPES as
|
|
1246
|
-
var
|
|
1577
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES19, ESLintUtils as ESLintUtils18 } from "@typescript-eslint/utils";
|
|
1578
|
+
var createRule18 = ESLintUtils18.RuleCreator(
|
|
1247
1579
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1248
1580
|
);
|
|
1249
|
-
var jsxNoNonComponentFunction =
|
|
1581
|
+
var jsxNoNonComponentFunction = createRule18({
|
|
1250
1582
|
name: "jsx-no-non-component-function",
|
|
1251
1583
|
meta: {
|
|
1252
1584
|
type: "problem",
|
|
@@ -1266,13 +1598,13 @@ var jsxNoNonComponentFunction = createRule15({
|
|
|
1266
1598
|
return {};
|
|
1267
1599
|
}
|
|
1268
1600
|
function isReactComponent2(node) {
|
|
1269
|
-
const functionName = node.type ===
|
|
1601
|
+
const functionName = node.type === AST_NODE_TYPES19.FunctionDeclaration && node.id ? node.id.name : null;
|
|
1270
1602
|
if (functionName && /^[A-Z]/.test(functionName)) {
|
|
1271
1603
|
return true;
|
|
1272
1604
|
}
|
|
1273
1605
|
if (node.returnType?.typeAnnotation) {
|
|
1274
1606
|
const returnTypeNode = node.returnType.typeAnnotation;
|
|
1275
|
-
if (returnTypeNode.type ===
|
|
1607
|
+
if (returnTypeNode.type === AST_NODE_TYPES19.TSTypeReference && returnTypeNode.typeName.type === AST_NODE_TYPES19.Identifier) {
|
|
1276
1608
|
const typeName = returnTypeNode.typeName.name;
|
|
1277
1609
|
if (typeName === "JSX" || typeName === "ReactElement" || typeName === "ReactNode") {
|
|
1278
1610
|
return true;
|
|
@@ -1289,13 +1621,13 @@ var jsxNoNonComponentFunction = createRule15({
|
|
|
1289
1621
|
if (!parent) {
|
|
1290
1622
|
return;
|
|
1291
1623
|
}
|
|
1292
|
-
if (parent.type ===
|
|
1624
|
+
if (parent.type === AST_NODE_TYPES19.ExportDefaultDeclaration || parent.type === AST_NODE_TYPES19.ExportNamedDeclaration) {
|
|
1293
1625
|
return;
|
|
1294
1626
|
}
|
|
1295
|
-
if (declaratorNode?.parent?.parent?.type ===
|
|
1627
|
+
if (declaratorNode?.parent?.parent?.type === AST_NODE_TYPES19.ExportNamedDeclaration) {
|
|
1296
1628
|
return;
|
|
1297
1629
|
}
|
|
1298
|
-
if (declaratorNode?.id.type ===
|
|
1630
|
+
if (declaratorNode?.id.type === AST_NODE_TYPES19.Identifier) {
|
|
1299
1631
|
const varName = declaratorNode.id.name;
|
|
1300
1632
|
if (/^[A-Z]/.test(varName)) {
|
|
1301
1633
|
return;
|
|
@@ -1319,21 +1651,146 @@ var jsxNoNonComponentFunction = createRule15({
|
|
|
1319
1651
|
});
|
|
1320
1652
|
var jsx_no_non_component_function_default = jsxNoNonComponentFunction;
|
|
1321
1653
|
|
|
1654
|
+
// src/rules/jsx-no-sub-interface.ts
|
|
1655
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES20, ESLintUtils as ESLintUtils19 } from "@typescript-eslint/utils";
|
|
1656
|
+
var createRule19 = ESLintUtils19.RuleCreator(
|
|
1657
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1658
|
+
);
|
|
1659
|
+
var PROPS_WRAPPER_NAMES = /* @__PURE__ */ new Set(["Readonly", "Required", "Partial", "PropsWithChildren", "NoInfer"]);
|
|
1660
|
+
function unwrapWrapperType(node) {
|
|
1661
|
+
if (node.type === AST_NODE_TYPES20.TSTypeReference && node.typeName.type === AST_NODE_TYPES20.Identifier && PROPS_WRAPPER_NAMES.has(node.typeName.name) && node.typeArguments && node.typeArguments.params.length > 0) {
|
|
1662
|
+
return unwrapWrapperType(node.typeArguments.params[0]);
|
|
1663
|
+
}
|
|
1664
|
+
return node;
|
|
1665
|
+
}
|
|
1666
|
+
function getMainTypeName(typeNode) {
|
|
1667
|
+
if (!typeNode) {
|
|
1668
|
+
return null;
|
|
1669
|
+
}
|
|
1670
|
+
const unwrapped = unwrapWrapperType(typeNode);
|
|
1671
|
+
if (unwrapped.type === AST_NODE_TYPES20.TSTypeReference && unwrapped.typeName.type === AST_NODE_TYPES20.Identifier) {
|
|
1672
|
+
return unwrapped.typeName.name;
|
|
1673
|
+
}
|
|
1674
|
+
return null;
|
|
1675
|
+
}
|
|
1676
|
+
function getComponentMainTypeName(node) {
|
|
1677
|
+
const firstParam = node.params[0];
|
|
1678
|
+
if (!firstParam) {
|
|
1679
|
+
return null;
|
|
1680
|
+
}
|
|
1681
|
+
if ("typeAnnotation" in firstParam && firstParam.typeAnnotation) {
|
|
1682
|
+
return getMainTypeName(firstParam.typeAnnotation.typeAnnotation);
|
|
1683
|
+
}
|
|
1684
|
+
return null;
|
|
1685
|
+
}
|
|
1686
|
+
function isPascalCase2(name) {
|
|
1687
|
+
return /^[A-Z]/.test(name);
|
|
1688
|
+
}
|
|
1689
|
+
function getDeclarationFromExportWrapper(node) {
|
|
1690
|
+
if (node.type === AST_NODE_TYPES20.ExportNamedDeclaration && node.declaration) {
|
|
1691
|
+
return node.declaration;
|
|
1692
|
+
}
|
|
1693
|
+
if (node.type === AST_NODE_TYPES20.ExportDefaultDeclaration) {
|
|
1694
|
+
return node.declaration;
|
|
1695
|
+
}
|
|
1696
|
+
return node;
|
|
1697
|
+
}
|
|
1698
|
+
var jsxNoSubInterface = createRule19({
|
|
1699
|
+
name: "jsx-no-sub-interface",
|
|
1700
|
+
meta: {
|
|
1701
|
+
type: "problem",
|
|
1702
|
+
docs: {
|
|
1703
|
+
description: "Disallow sub-interfaces and helper types in component files; keep only the main component props (extract the rest)"
|
|
1704
|
+
},
|
|
1705
|
+
schema: [],
|
|
1706
|
+
messages: {
|
|
1707
|
+
noSubInterface: "Sub-interface or helper type '{{ name }}' should not live in a component file. Extract it to a sibling module (e.g., a *.types.ts file or its own component file)."
|
|
1708
|
+
}
|
|
1709
|
+
},
|
|
1710
|
+
defaultOptions: [],
|
|
1711
|
+
create(context) {
|
|
1712
|
+
const { filename } = context;
|
|
1713
|
+
const extension = getFileExtension(filename);
|
|
1714
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
1715
|
+
return {};
|
|
1716
|
+
}
|
|
1717
|
+
return {
|
|
1718
|
+
Program(programNode) {
|
|
1719
|
+
const mainTypes = /* @__PURE__ */ new Set();
|
|
1720
|
+
const typeDeclarations = [];
|
|
1721
|
+
let componentCount = 0;
|
|
1722
|
+
for (const statement of programNode.body) {
|
|
1723
|
+
const declaration = getDeclarationFromExportWrapper(statement);
|
|
1724
|
+
if (declaration.type === AST_NODE_TYPES20.FunctionDeclaration && declaration.id && isPascalCase2(declaration.id.name)) {
|
|
1725
|
+
componentCount += 1;
|
|
1726
|
+
const mainType = getComponentMainTypeName(declaration);
|
|
1727
|
+
if (mainType) {
|
|
1728
|
+
mainTypes.add(mainType);
|
|
1729
|
+
}
|
|
1730
|
+
continue;
|
|
1731
|
+
}
|
|
1732
|
+
if (declaration.type === AST_NODE_TYPES20.VariableDeclaration) {
|
|
1733
|
+
for (const declarator of declaration.declarations) {
|
|
1734
|
+
if (declarator.id.type !== AST_NODE_TYPES20.Identifier) {
|
|
1735
|
+
continue;
|
|
1736
|
+
}
|
|
1737
|
+
if (!isPascalCase2(declarator.id.name)) {
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1740
|
+
const init = declarator.init;
|
|
1741
|
+
if (init && (init.type === AST_NODE_TYPES20.ArrowFunctionExpression || init.type === AST_NODE_TYPES20.FunctionExpression)) {
|
|
1742
|
+
componentCount += 1;
|
|
1743
|
+
const mainType = getComponentMainTypeName(init);
|
|
1744
|
+
if (mainType) {
|
|
1745
|
+
mainTypes.add(mainType);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
continue;
|
|
1750
|
+
}
|
|
1751
|
+
if (declaration.type === AST_NODE_TYPES20.TSInterfaceDeclaration) {
|
|
1752
|
+
typeDeclarations.push({ name: declaration.id.name, node: declaration });
|
|
1753
|
+
continue;
|
|
1754
|
+
}
|
|
1755
|
+
if (declaration.type === AST_NODE_TYPES20.TSTypeAliasDeclaration) {
|
|
1756
|
+
typeDeclarations.push({ name: declaration.id.name, node: declaration });
|
|
1757
|
+
continue;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
if (componentCount === 0) {
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
for (const declaration of typeDeclarations) {
|
|
1764
|
+
if (mainTypes.has(declaration.name)) {
|
|
1765
|
+
continue;
|
|
1766
|
+
}
|
|
1767
|
+
context.report({
|
|
1768
|
+
node: declaration.node,
|
|
1769
|
+
messageId: "noSubInterface",
|
|
1770
|
+
data: { name: declaration.name }
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
var jsx_no_sub_interface_default = jsxNoSubInterface;
|
|
1778
|
+
|
|
1322
1779
|
// src/rules/jsx-no-ternary-null.ts
|
|
1323
|
-
import { AST_NODE_TYPES as
|
|
1324
|
-
var
|
|
1780
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES21, ESLintUtils as ESLintUtils20 } from "@typescript-eslint/utils";
|
|
1781
|
+
var createRule20 = ESLintUtils20.RuleCreator(
|
|
1325
1782
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1326
1783
|
);
|
|
1327
1784
|
function isNullOrUndefined(node) {
|
|
1328
|
-
if (node.type ===
|
|
1785
|
+
if (node.type === AST_NODE_TYPES21.Literal && node.value === null) {
|
|
1329
1786
|
return true;
|
|
1330
1787
|
}
|
|
1331
|
-
if (node.type ===
|
|
1788
|
+
if (node.type === AST_NODE_TYPES21.Identifier && node.name === "undefined") {
|
|
1332
1789
|
return true;
|
|
1333
1790
|
}
|
|
1334
1791
|
return false;
|
|
1335
1792
|
}
|
|
1336
|
-
var jsxNoTernaryNull =
|
|
1793
|
+
var jsxNoTernaryNull = createRule20({
|
|
1337
1794
|
name: "jsx-no-ternary-null",
|
|
1338
1795
|
meta: {
|
|
1339
1796
|
type: "suggestion",
|
|
@@ -1351,7 +1808,7 @@ var jsxNoTernaryNull = createRule16({
|
|
|
1351
1808
|
return {
|
|
1352
1809
|
JSXExpressionContainer(node) {
|
|
1353
1810
|
const { expression } = node;
|
|
1354
|
-
if (expression.type !==
|
|
1811
|
+
if (expression.type !== AST_NODE_TYPES21.ConditionalExpression) {
|
|
1355
1812
|
return;
|
|
1356
1813
|
}
|
|
1357
1814
|
const { test, consequent, alternate } = expression;
|
|
@@ -1383,11 +1840,11 @@ var jsxNoTernaryNull = createRule16({
|
|
|
1383
1840
|
var jsx_no_ternary_null_default = jsxNoTernaryNull;
|
|
1384
1841
|
|
|
1385
1842
|
// src/rules/jsx-no-variable-in-callback.ts
|
|
1386
|
-
import { AST_NODE_TYPES as
|
|
1387
|
-
var
|
|
1843
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES22, ESLintUtils as ESLintUtils21 } from "@typescript-eslint/utils";
|
|
1844
|
+
var createRule21 = ESLintUtils21.RuleCreator(
|
|
1388
1845
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1389
1846
|
);
|
|
1390
|
-
var jsxNoVariableInCallback =
|
|
1847
|
+
var jsxNoVariableInCallback = createRule21({
|
|
1391
1848
|
name: "jsx-no-variable-in-callback",
|
|
1392
1849
|
meta: {
|
|
1393
1850
|
type: "suggestion",
|
|
@@ -1404,7 +1861,7 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1404
1861
|
function isInsideJSX(node) {
|
|
1405
1862
|
let current = node.parent;
|
|
1406
1863
|
while (current) {
|
|
1407
|
-
if (current.type ===
|
|
1864
|
+
if (current.type === AST_NODE_TYPES22.JSXElement || current.type === AST_NODE_TYPES22.JSXFragment) {
|
|
1408
1865
|
return true;
|
|
1409
1866
|
}
|
|
1410
1867
|
current = current.parent;
|
|
@@ -1418,11 +1875,11 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1418
1875
|
if (!isInsideJSX(node)) {
|
|
1419
1876
|
return false;
|
|
1420
1877
|
}
|
|
1421
|
-
if (node.parent.type ===
|
|
1878
|
+
if (node.parent.type === AST_NODE_TYPES22.CallExpression || node.parent.type === AST_NODE_TYPES22.JSXExpressionContainer) {
|
|
1422
1879
|
return true;
|
|
1423
1880
|
}
|
|
1424
|
-
if (node.parent.type ===
|
|
1425
|
-
if (node.parent.parent.type ===
|
|
1881
|
+
if (node.parent.type === AST_NODE_TYPES22.ArrayExpression && node.parent.parent) {
|
|
1882
|
+
if (node.parent.parent.type === AST_NODE_TYPES22.CallExpression || node.parent.parent.type === AST_NODE_TYPES22.JSXExpressionContainer) {
|
|
1426
1883
|
return true;
|
|
1427
1884
|
}
|
|
1428
1885
|
}
|
|
@@ -1433,11 +1890,11 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1433
1890
|
return;
|
|
1434
1891
|
}
|
|
1435
1892
|
const { body } = node;
|
|
1436
|
-
if (body.type !==
|
|
1893
|
+
if (body.type !== AST_NODE_TYPES22.BlockStatement) {
|
|
1437
1894
|
return;
|
|
1438
1895
|
}
|
|
1439
1896
|
body.body.forEach((statement) => {
|
|
1440
|
-
if (statement.type ===
|
|
1897
|
+
if (statement.type === AST_NODE_TYPES22.VariableDeclaration) {
|
|
1441
1898
|
context.report({
|
|
1442
1899
|
node: statement,
|
|
1443
1900
|
messageId: "noVariableInCallback"
|
|
@@ -1454,11 +1911,11 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1454
1911
|
var jsx_no_variable_in_callback_default = jsxNoVariableInCallback;
|
|
1455
1912
|
|
|
1456
1913
|
// src/rules/jsx-require-suspense.ts
|
|
1457
|
-
import { AST_NODE_TYPES as
|
|
1458
|
-
var
|
|
1914
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES23, ESLintUtils as ESLintUtils22 } from "@typescript-eslint/utils";
|
|
1915
|
+
var createRule22 = ESLintUtils22.RuleCreator(
|
|
1459
1916
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1460
1917
|
);
|
|
1461
|
-
var jsxRequireSuspense =
|
|
1918
|
+
var jsxRequireSuspense = createRule22({
|
|
1462
1919
|
name: "jsx-require-suspense",
|
|
1463
1920
|
meta: {
|
|
1464
1921
|
type: "problem",
|
|
@@ -1476,7 +1933,7 @@ var jsxRequireSuspense = createRule18({
|
|
|
1476
1933
|
const isInsideSuspense = (node) => {
|
|
1477
1934
|
let current = node.parent;
|
|
1478
1935
|
while (current) {
|
|
1479
|
-
if (current.type ===
|
|
1936
|
+
if (current.type === AST_NODE_TYPES23.JSXElement && current.openingElement.name.type === AST_NODE_TYPES23.JSXIdentifier && current.openingElement.name.name === "Suspense") {
|
|
1480
1937
|
return true;
|
|
1481
1938
|
}
|
|
1482
1939
|
current = current.parent;
|
|
@@ -1485,16 +1942,16 @@ var jsxRequireSuspense = createRule18({
|
|
|
1485
1942
|
};
|
|
1486
1943
|
return {
|
|
1487
1944
|
VariableDeclarator(node) {
|
|
1488
|
-
if (node.id.type ===
|
|
1945
|
+
if (node.id.type === AST_NODE_TYPES23.Identifier && node.init?.type === AST_NODE_TYPES23.CallExpression) {
|
|
1489
1946
|
const { callee } = node.init;
|
|
1490
|
-
const isLazyCall = callee.type ===
|
|
1947
|
+
const isLazyCall = callee.type === AST_NODE_TYPES23.Identifier && callee.name === "lazy" || callee.type === AST_NODE_TYPES23.MemberExpression && callee.object.type === AST_NODE_TYPES23.Identifier && callee.object.name === "React" && callee.property.type === AST_NODE_TYPES23.Identifier && callee.property.name === "lazy";
|
|
1491
1948
|
if (isLazyCall) {
|
|
1492
1949
|
lazyComponents.add(node.id.name);
|
|
1493
1950
|
}
|
|
1494
1951
|
}
|
|
1495
1952
|
},
|
|
1496
1953
|
JSXOpeningElement(node) {
|
|
1497
|
-
if (node.name.type ===
|
|
1954
|
+
if (node.name.type === AST_NODE_TYPES23.JSXIdentifier) {
|
|
1498
1955
|
const componentName = node.name.name;
|
|
1499
1956
|
if (lazyComponents.has(componentName) && !isInsideSuspense(node)) {
|
|
1500
1957
|
context.report({
|
|
@@ -1513,11 +1970,11 @@ var jsxRequireSuspense = createRule18({
|
|
|
1513
1970
|
var jsx_require_suspense_default = jsxRequireSuspense;
|
|
1514
1971
|
|
|
1515
1972
|
// src/rules/jsx-simple-props.ts
|
|
1516
|
-
import { AST_NODE_TYPES as
|
|
1517
|
-
var
|
|
1973
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES24, ESLintUtils as ESLintUtils23 } from "@typescript-eslint/utils";
|
|
1974
|
+
var createRule23 = ESLintUtils23.RuleCreator(
|
|
1518
1975
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1519
1976
|
);
|
|
1520
|
-
var jsxSimpleProps =
|
|
1977
|
+
var jsxSimpleProps = createRule23({
|
|
1521
1978
|
name: "jsx-simple-props",
|
|
1522
1979
|
meta: {
|
|
1523
1980
|
type: "suggestion",
|
|
@@ -1532,25 +1989,25 @@ var jsxSimpleProps = createRule19({
|
|
|
1532
1989
|
defaultOptions: [],
|
|
1533
1990
|
create(context) {
|
|
1534
1991
|
const allowedExpressionTypes = /* @__PURE__ */ new Set([
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1992
|
+
AST_NODE_TYPES24.Identifier,
|
|
1993
|
+
AST_NODE_TYPES24.Literal,
|
|
1994
|
+
AST_NODE_TYPES24.JSXElement,
|
|
1995
|
+
AST_NODE_TYPES24.JSXFragment,
|
|
1996
|
+
AST_NODE_TYPES24.MemberExpression,
|
|
1997
|
+
AST_NODE_TYPES24.ArrowFunctionExpression,
|
|
1998
|
+
AST_NODE_TYPES24.FunctionExpression
|
|
1542
1999
|
]);
|
|
1543
2000
|
return {
|
|
1544
2001
|
JSXAttribute(node) {
|
|
1545
2002
|
if (!node.value) {
|
|
1546
2003
|
return;
|
|
1547
2004
|
}
|
|
1548
|
-
if (node.value.type ===
|
|
2005
|
+
if (node.value.type === AST_NODE_TYPES24.Literal) {
|
|
1549
2006
|
return;
|
|
1550
2007
|
}
|
|
1551
|
-
if (node.value.type ===
|
|
2008
|
+
if (node.value.type === AST_NODE_TYPES24.JSXExpressionContainer) {
|
|
1552
2009
|
const { expression } = node.value;
|
|
1553
|
-
if (expression.type ===
|
|
2010
|
+
if (expression.type === AST_NODE_TYPES24.JSXEmptyExpression) {
|
|
1554
2011
|
return;
|
|
1555
2012
|
}
|
|
1556
2013
|
if (!allowedExpressionTypes.has(expression.type)) {
|
|
@@ -1567,8 +2024,8 @@ var jsxSimpleProps = createRule19({
|
|
|
1567
2024
|
var jsx_simple_props_default = jsxSimpleProps;
|
|
1568
2025
|
|
|
1569
2026
|
// src/rules/jsx-sort-props.ts
|
|
1570
|
-
import { AST_NODE_TYPES as
|
|
1571
|
-
var
|
|
2027
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES25, ESLintUtils as ESLintUtils24 } from "@typescript-eslint/utils";
|
|
2028
|
+
var createRule24 = ESLintUtils24.RuleCreator(
|
|
1572
2029
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1573
2030
|
);
|
|
1574
2031
|
var TYPE_GROUP = {
|
|
@@ -1582,15 +2039,15 @@ var TYPE_GROUP = {
|
|
|
1582
2039
|
SHORTHAND: 8
|
|
1583
2040
|
};
|
|
1584
2041
|
var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
|
|
1585
|
-
[
|
|
1586
|
-
[
|
|
1587
|
-
[
|
|
1588
|
-
[
|
|
1589
|
-
[
|
|
1590
|
-
[
|
|
2042
|
+
[AST_NODE_TYPES25.ObjectExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
2043
|
+
[AST_NODE_TYPES25.ArrayExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
2044
|
+
[AST_NODE_TYPES25.ArrowFunctionExpression, TYPE_GROUP.FUNCTION],
|
|
2045
|
+
[AST_NODE_TYPES25.FunctionExpression, TYPE_GROUP.FUNCTION],
|
|
2046
|
+
[AST_NODE_TYPES25.JSXElement, TYPE_GROUP.JSX],
|
|
2047
|
+
[AST_NODE_TYPES25.JSXFragment, TYPE_GROUP.JSX]
|
|
1591
2048
|
]);
|
|
1592
2049
|
function isHyphenatedName(node) {
|
|
1593
|
-
return node.name.type ===
|
|
2050
|
+
return node.name.type === AST_NODE_TYPES25.JSXIdentifier && node.name.name.includes("-");
|
|
1594
2051
|
}
|
|
1595
2052
|
function getStringGroup(node) {
|
|
1596
2053
|
return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
|
|
@@ -1602,13 +2059,13 @@ function getLiteralValueGroup(value) {
|
|
|
1602
2059
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1603
2060
|
}
|
|
1604
2061
|
function getExpressionGroup(expression) {
|
|
1605
|
-
if (expression.type ===
|
|
2062
|
+
if (expression.type === AST_NODE_TYPES25.Literal) {
|
|
1606
2063
|
return getLiteralValueGroup(expression.value);
|
|
1607
2064
|
}
|
|
1608
|
-
if (expression.type ===
|
|
2065
|
+
if (expression.type === AST_NODE_TYPES25.TemplateLiteral) {
|
|
1609
2066
|
return null;
|
|
1610
2067
|
}
|
|
1611
|
-
if (expression.type ===
|
|
2068
|
+
if (expression.type === AST_NODE_TYPES25.Identifier && expression.name === "undefined") {
|
|
1612
2069
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1613
2070
|
}
|
|
1614
2071
|
return EXPRESSION_TYPE_TO_GROUP.get(expression.type) ?? TYPE_GROUP.EXPRESSION;
|
|
@@ -1617,17 +2074,17 @@ function getTypeGroup(node) {
|
|
|
1617
2074
|
if (node.value === null) {
|
|
1618
2075
|
return TYPE_GROUP.SHORTHAND;
|
|
1619
2076
|
}
|
|
1620
|
-
if (node.value.type ===
|
|
2077
|
+
if (node.value.type === AST_NODE_TYPES25.Literal) {
|
|
1621
2078
|
if (typeof node.value.value === "string") {
|
|
1622
2079
|
return getStringGroup(node);
|
|
1623
2080
|
}
|
|
1624
2081
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1625
2082
|
}
|
|
1626
|
-
if (node.value.type !==
|
|
2083
|
+
if (node.value.type !== AST_NODE_TYPES25.JSXExpressionContainer) {
|
|
1627
2084
|
return null;
|
|
1628
2085
|
}
|
|
1629
2086
|
const { expression } = node.value;
|
|
1630
|
-
if (expression.type ===
|
|
2087
|
+
if (expression.type === AST_NODE_TYPES25.JSXEmptyExpression) {
|
|
1631
2088
|
return null;
|
|
1632
2089
|
}
|
|
1633
2090
|
const group = getExpressionGroup(expression);
|
|
@@ -1639,7 +2096,7 @@ function getTypeGroup(node) {
|
|
|
1639
2096
|
function hasUnsortedProps(attributes) {
|
|
1640
2097
|
let lastGroup = 0;
|
|
1641
2098
|
return attributes.some((attribute) => {
|
|
1642
|
-
if (attribute.type ===
|
|
2099
|
+
if (attribute.type === AST_NODE_TYPES25.JSXSpreadAttribute) {
|
|
1643
2100
|
lastGroup = 0;
|
|
1644
2101
|
return false;
|
|
1645
2102
|
}
|
|
@@ -1663,7 +2120,7 @@ function getSegments(attributes) {
|
|
|
1663
2120
|
const result = [];
|
|
1664
2121
|
let current = [];
|
|
1665
2122
|
attributes.forEach((attr) => {
|
|
1666
|
-
if (attr.type ===
|
|
2123
|
+
if (attr.type === AST_NODE_TYPES25.JSXSpreadAttribute) {
|
|
1667
2124
|
if (current.length > 0) {
|
|
1668
2125
|
result.push(current);
|
|
1669
2126
|
current = [];
|
|
@@ -1677,7 +2134,7 @@ function getSegments(attributes) {
|
|
|
1677
2134
|
}
|
|
1678
2135
|
return result;
|
|
1679
2136
|
}
|
|
1680
|
-
var jsxSortProps =
|
|
2137
|
+
var jsxSortProps = createRule24({
|
|
1681
2138
|
name: "jsx-sort-props",
|
|
1682
2139
|
meta: {
|
|
1683
2140
|
type: "suggestion",
|
|
@@ -1712,11 +2169,11 @@ var jsxSortProps = createRule20({
|
|
|
1712
2169
|
var jsx_sort_props_default = jsxSortProps;
|
|
1713
2170
|
|
|
1714
2171
|
// src/rules/jsx-spread-props-last.ts
|
|
1715
|
-
import { AST_NODE_TYPES as
|
|
1716
|
-
var
|
|
2172
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES26, ESLintUtils as ESLintUtils25 } from "@typescript-eslint/utils";
|
|
2173
|
+
var createRule25 = ESLintUtils25.RuleCreator(
|
|
1717
2174
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1718
2175
|
);
|
|
1719
|
-
var jsxSpreadPropsLast =
|
|
2176
|
+
var jsxSpreadPropsLast = createRule25({
|
|
1720
2177
|
name: "jsx-spread-props-last",
|
|
1721
2178
|
meta: {
|
|
1722
2179
|
type: "suggestion",
|
|
@@ -1735,12 +2192,12 @@ var jsxSpreadPropsLast = createRule21({
|
|
|
1735
2192
|
const { attributes } = node;
|
|
1736
2193
|
let lastNonSpreadIndex = -1;
|
|
1737
2194
|
attributes.forEach((attribute, index) => {
|
|
1738
|
-
if (attribute.type !==
|
|
2195
|
+
if (attribute.type !== AST_NODE_TYPES26.JSXSpreadAttribute) {
|
|
1739
2196
|
lastNonSpreadIndex = index;
|
|
1740
2197
|
}
|
|
1741
2198
|
});
|
|
1742
2199
|
attributes.forEach((attribute, index) => {
|
|
1743
|
-
if (attribute.type ===
|
|
2200
|
+
if (attribute.type === AST_NODE_TYPES26.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1744
2201
|
context.report({
|
|
1745
2202
|
node: attribute,
|
|
1746
2203
|
messageId: "spreadNotLast"
|
|
@@ -1754,12 +2211,12 @@ var jsxSpreadPropsLast = createRule21({
|
|
|
1754
2211
|
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1755
2212
|
|
|
1756
2213
|
// src/rules/newline-after-multiline-block.ts
|
|
1757
|
-
import { AST_NODE_TYPES as
|
|
1758
|
-
var
|
|
2214
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES27, ESLintUtils as ESLintUtils26 } from "@typescript-eslint/utils";
|
|
2215
|
+
var createRule26 = ESLintUtils26.RuleCreator(
|
|
1759
2216
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1760
2217
|
);
|
|
1761
2218
|
function isImportDeclaration(node) {
|
|
1762
|
-
return node.type ===
|
|
2219
|
+
return node.type === AST_NODE_TYPES27.ImportDeclaration;
|
|
1763
2220
|
}
|
|
1764
2221
|
function checkStatements(statements, context) {
|
|
1765
2222
|
const { sourceCode } = context;
|
|
@@ -1794,7 +2251,7 @@ function checkStatements(statements, context) {
|
|
|
1794
2251
|
}
|
|
1795
2252
|
});
|
|
1796
2253
|
}
|
|
1797
|
-
var newlineAfterMultilineBlock =
|
|
2254
|
+
var newlineAfterMultilineBlock = createRule26({
|
|
1798
2255
|
name: "newline-after-multiline-block",
|
|
1799
2256
|
meta: {
|
|
1800
2257
|
type: "layout",
|
|
@@ -1822,11 +2279,11 @@ var newlineAfterMultilineBlock = createRule22({
|
|
|
1822
2279
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
1823
2280
|
|
|
1824
2281
|
// src/rules/newline-before-return.ts
|
|
1825
|
-
import { AST_NODE_TYPES as
|
|
1826
|
-
var
|
|
2282
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES28, ESLintUtils as ESLintUtils27 } from "@typescript-eslint/utils";
|
|
2283
|
+
var createRule27 = ESLintUtils27.RuleCreator(
|
|
1827
2284
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1828
2285
|
);
|
|
1829
|
-
var newlineBeforeReturn =
|
|
2286
|
+
var newlineBeforeReturn = createRule27({
|
|
1830
2287
|
name: "newline-before-return",
|
|
1831
2288
|
meta: {
|
|
1832
2289
|
type: "layout",
|
|
@@ -1844,7 +2301,7 @@ var newlineBeforeReturn = createRule23({
|
|
|
1844
2301
|
const { sourceCode } = context;
|
|
1845
2302
|
function checkReturnStatement(node) {
|
|
1846
2303
|
const { parent } = node;
|
|
1847
|
-
if (!parent || parent.type !==
|
|
2304
|
+
if (!parent || parent.type !== AST_NODE_TYPES28.BlockStatement) {
|
|
1848
2305
|
return;
|
|
1849
2306
|
}
|
|
1850
2307
|
const { body: statements } = parent;
|
|
@@ -1881,11 +2338,11 @@ var newlineBeforeReturn = createRule23({
|
|
|
1881
2338
|
var newline_before_return_default = newlineBeforeReturn;
|
|
1882
2339
|
|
|
1883
2340
|
// src/rules/no-complex-inline-return.ts
|
|
1884
|
-
import { AST_NODE_TYPES as
|
|
1885
|
-
var
|
|
2341
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES29, ESLintUtils as ESLintUtils28 } from "@typescript-eslint/utils";
|
|
2342
|
+
var createRule28 = ESLintUtils28.RuleCreator(
|
|
1886
2343
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1887
2344
|
);
|
|
1888
|
-
var noComplexInlineReturn =
|
|
2345
|
+
var noComplexInlineReturn = createRule28({
|
|
1889
2346
|
name: "no-complex-inline-return",
|
|
1890
2347
|
meta: {
|
|
1891
2348
|
type: "suggestion",
|
|
@@ -1901,13 +2358,13 @@ var noComplexInlineReturn = createRule24({
|
|
|
1901
2358
|
create(context) {
|
|
1902
2359
|
const isComplexExpression = (node) => {
|
|
1903
2360
|
if (!node) return false;
|
|
1904
|
-
if (node.type ===
|
|
2361
|
+
if (node.type === AST_NODE_TYPES29.ConditionalExpression) {
|
|
1905
2362
|
return true;
|
|
1906
2363
|
}
|
|
1907
|
-
if (node.type ===
|
|
2364
|
+
if (node.type === AST_NODE_TYPES29.LogicalExpression) {
|
|
1908
2365
|
return true;
|
|
1909
2366
|
}
|
|
1910
|
-
if (node.type ===
|
|
2367
|
+
if (node.type === AST_NODE_TYPES29.NewExpression) {
|
|
1911
2368
|
return true;
|
|
1912
2369
|
}
|
|
1913
2370
|
return false;
|
|
@@ -1927,11 +2384,11 @@ var noComplexInlineReturn = createRule24({
|
|
|
1927
2384
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
1928
2385
|
|
|
1929
2386
|
// src/rules/no-direct-date.ts
|
|
1930
|
-
import { AST_NODE_TYPES as
|
|
1931
|
-
var
|
|
2387
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES30, ESLintUtils as ESLintUtils29 } from "@typescript-eslint/utils";
|
|
2388
|
+
var createRule29 = ESLintUtils29.RuleCreator(
|
|
1932
2389
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1933
2390
|
);
|
|
1934
|
-
var noDirectDate =
|
|
2391
|
+
var noDirectDate = createRule29({
|
|
1935
2392
|
name: "no-direct-date",
|
|
1936
2393
|
meta: {
|
|
1937
2394
|
type: "problem",
|
|
@@ -1949,7 +2406,7 @@ var noDirectDate = createRule25({
|
|
|
1949
2406
|
create(context) {
|
|
1950
2407
|
return {
|
|
1951
2408
|
NewExpression(node) {
|
|
1952
|
-
if (node.callee.type ===
|
|
2409
|
+
if (node.callee.type === AST_NODE_TYPES30.Identifier && node.callee.name === "Date") {
|
|
1953
2410
|
context.report({
|
|
1954
2411
|
node,
|
|
1955
2412
|
messageId: "noNewDate"
|
|
@@ -1957,7 +2414,7 @@ var noDirectDate = createRule25({
|
|
|
1957
2414
|
}
|
|
1958
2415
|
},
|
|
1959
2416
|
CallExpression(node) {
|
|
1960
|
-
if (node.callee.type ===
|
|
2417
|
+
if (node.callee.type === AST_NODE_TYPES30.MemberExpression && node.callee.object.type === AST_NODE_TYPES30.Identifier && node.callee.object.name === "Date" && node.callee.property.type === AST_NODE_TYPES30.Identifier) {
|
|
1961
2418
|
const methodName = node.callee.property.name;
|
|
1962
2419
|
if (methodName === "now") {
|
|
1963
2420
|
context.report({
|
|
@@ -1980,11 +2437,11 @@ var no_direct_date_default = noDirectDate;
|
|
|
1980
2437
|
|
|
1981
2438
|
// src/rules/no-emoji.ts
|
|
1982
2439
|
import emojiRegex from "emoji-regex";
|
|
1983
|
-
import { ESLintUtils as
|
|
1984
|
-
var
|
|
2440
|
+
import { ESLintUtils as ESLintUtils30 } from "@typescript-eslint/utils";
|
|
2441
|
+
var createRule30 = ESLintUtils30.RuleCreator(
|
|
1985
2442
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1986
2443
|
);
|
|
1987
|
-
var noEmoji =
|
|
2444
|
+
var noEmoji = createRule30({
|
|
1988
2445
|
name: "no-emoji",
|
|
1989
2446
|
meta: {
|
|
1990
2447
|
type: "problem",
|
|
@@ -2018,11 +2475,11 @@ var noEmoji = createRule26({
|
|
|
2018
2475
|
var no_emoji_default = noEmoji;
|
|
2019
2476
|
|
|
2020
2477
|
// src/rules/no-env-fallback.ts
|
|
2021
|
-
import { AST_NODE_TYPES as
|
|
2022
|
-
var
|
|
2478
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES31, ESLintUtils as ESLintUtils31 } from "@typescript-eslint/utils";
|
|
2479
|
+
var createRule31 = ESLintUtils31.RuleCreator(
|
|
2023
2480
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2024
2481
|
);
|
|
2025
|
-
var noEnvFallback =
|
|
2482
|
+
var noEnvFallback = createRule31({
|
|
2026
2483
|
name: "no-env-fallback",
|
|
2027
2484
|
meta: {
|
|
2028
2485
|
type: "problem",
|
|
@@ -2037,16 +2494,16 @@ var noEnvFallback = createRule27({
|
|
|
2037
2494
|
defaultOptions: [],
|
|
2038
2495
|
create(context) {
|
|
2039
2496
|
const isProcessEnvAccess = (node) => {
|
|
2040
|
-
if (node.type !==
|
|
2497
|
+
if (node.type !== AST_NODE_TYPES31.MemberExpression) {
|
|
2041
2498
|
return false;
|
|
2042
2499
|
}
|
|
2043
2500
|
const { object } = node;
|
|
2044
|
-
if (object.type !==
|
|
2501
|
+
if (object.type !== AST_NODE_TYPES31.MemberExpression) {
|
|
2045
2502
|
return false;
|
|
2046
2503
|
}
|
|
2047
2504
|
const processNode = object.object;
|
|
2048
2505
|
const envNode = object.property;
|
|
2049
|
-
return processNode.type ===
|
|
2506
|
+
return processNode.type === AST_NODE_TYPES31.Identifier && processNode.name === "process" && envNode.type === AST_NODE_TYPES31.Identifier && envNode.name === "env";
|
|
2050
2507
|
};
|
|
2051
2508
|
return {
|
|
2052
2509
|
LogicalExpression(node) {
|
|
@@ -2071,15 +2528,15 @@ var noEnvFallback = createRule27({
|
|
|
2071
2528
|
var no_env_fallback_default = noEnvFallback;
|
|
2072
2529
|
|
|
2073
2530
|
// src/rules/no-ghost-wrapper.ts
|
|
2074
|
-
import { AST_NODE_TYPES as
|
|
2075
|
-
var
|
|
2531
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES32, ESLintUtils as ESLintUtils32 } from "@typescript-eslint/utils";
|
|
2532
|
+
var createRule32 = ESLintUtils32.RuleCreator(
|
|
2076
2533
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2077
2534
|
);
|
|
2078
2535
|
var GHOST_TAGS = /* @__PURE__ */ new Set(["div", "span"]);
|
|
2079
2536
|
function isKeyAttribute(attribute) {
|
|
2080
|
-
return attribute.type ===
|
|
2537
|
+
return attribute.type === AST_NODE_TYPES32.JSXAttribute && attribute.name.type === AST_NODE_TYPES32.JSXIdentifier && attribute.name.name === "key";
|
|
2081
2538
|
}
|
|
2082
|
-
var noGhostWrapper =
|
|
2539
|
+
var noGhostWrapper = createRule32({
|
|
2083
2540
|
name: "no-ghost-wrapper",
|
|
2084
2541
|
meta: {
|
|
2085
2542
|
type: "problem",
|
|
@@ -2095,7 +2552,7 @@ var noGhostWrapper = createRule28({
|
|
|
2095
2552
|
create(context) {
|
|
2096
2553
|
return {
|
|
2097
2554
|
JSXOpeningElement(node) {
|
|
2098
|
-
if (node.name.type !==
|
|
2555
|
+
if (node.name.type !== AST_NODE_TYPES32.JSXIdentifier) {
|
|
2099
2556
|
return;
|
|
2100
2557
|
}
|
|
2101
2558
|
const tagName = node.name.name;
|
|
@@ -2117,11 +2574,11 @@ var noGhostWrapper = createRule28({
|
|
|
2117
2574
|
var no_ghost_wrapper_default = noGhostWrapper;
|
|
2118
2575
|
|
|
2119
2576
|
// src/rules/no-inline-default-export.ts
|
|
2120
|
-
import { AST_NODE_TYPES as
|
|
2121
|
-
var
|
|
2577
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES33, ESLintUtils as ESLintUtils33 } from "@typescript-eslint/utils";
|
|
2578
|
+
var createRule33 = ESLintUtils33.RuleCreator(
|
|
2122
2579
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2123
2580
|
);
|
|
2124
|
-
var noInlineDefaultExport =
|
|
2581
|
+
var noInlineDefaultExport = createRule33({
|
|
2125
2582
|
name: "no-inline-default-export",
|
|
2126
2583
|
meta: {
|
|
2127
2584
|
type: "suggestion",
|
|
@@ -2140,7 +2597,7 @@ var noInlineDefaultExport = createRule29({
|
|
|
2140
2597
|
return {
|
|
2141
2598
|
ExportDefaultDeclaration(node) {
|
|
2142
2599
|
const { declaration } = node;
|
|
2143
|
-
if (declaration.type ===
|
|
2600
|
+
if (declaration.type === AST_NODE_TYPES33.FunctionDeclaration) {
|
|
2144
2601
|
if (declaration.id) {
|
|
2145
2602
|
context.report({
|
|
2146
2603
|
node,
|
|
@@ -2155,7 +2612,7 @@ var noInlineDefaultExport = createRule29({
|
|
|
2155
2612
|
});
|
|
2156
2613
|
}
|
|
2157
2614
|
}
|
|
2158
|
-
if (declaration.type ===
|
|
2615
|
+
if (declaration.type === AST_NODE_TYPES33.ClassDeclaration) {
|
|
2159
2616
|
if (declaration.id) {
|
|
2160
2617
|
context.report({
|
|
2161
2618
|
node,
|
|
@@ -2170,7 +2627,7 @@ var noInlineDefaultExport = createRule29({
|
|
|
2170
2627
|
});
|
|
2171
2628
|
}
|
|
2172
2629
|
}
|
|
2173
|
-
if (declaration.type ===
|
|
2630
|
+
if (declaration.type === AST_NODE_TYPES33.ArrowFunctionExpression || declaration.type === AST_NODE_TYPES33.FunctionExpression) {
|
|
2174
2631
|
context.report({
|
|
2175
2632
|
node,
|
|
2176
2633
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2183,14 +2640,14 @@ var noInlineDefaultExport = createRule29({
|
|
|
2183
2640
|
if (!declaration) {
|
|
2184
2641
|
return;
|
|
2185
2642
|
}
|
|
2186
|
-
if (declaration.type ===
|
|
2643
|
+
if (declaration.type === AST_NODE_TYPES33.FunctionDeclaration && declaration.id) {
|
|
2187
2644
|
context.report({
|
|
2188
2645
|
node,
|
|
2189
2646
|
messageId: "noInlineNamedExport",
|
|
2190
2647
|
data: { type: "function", name: declaration.id.name }
|
|
2191
2648
|
});
|
|
2192
2649
|
}
|
|
2193
|
-
if (declaration.type ===
|
|
2650
|
+
if (declaration.type === AST_NODE_TYPES33.ClassDeclaration && declaration.id) {
|
|
2194
2651
|
context.report({
|
|
2195
2652
|
node,
|
|
2196
2653
|
messageId: "noInlineNamedExport",
|
|
@@ -2204,27 +2661,27 @@ var noInlineDefaultExport = createRule29({
|
|
|
2204
2661
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2205
2662
|
|
|
2206
2663
|
// src/rules/no-inline-nested-object.ts
|
|
2207
|
-
import { AST_NODE_TYPES as
|
|
2208
|
-
var
|
|
2664
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES34, ESLintUtils as ESLintUtils34 } from "@typescript-eslint/utils";
|
|
2665
|
+
var createRule34 = ESLintUtils34.RuleCreator(
|
|
2209
2666
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2210
2667
|
);
|
|
2211
2668
|
function isObjectOrArray(node) {
|
|
2212
|
-
return node.type ===
|
|
2669
|
+
return node.type === AST_NODE_TYPES34.ObjectExpression || node.type === AST_NODE_TYPES34.ArrayExpression || node.type === AST_NODE_TYPES34.TSAsExpression;
|
|
2213
2670
|
}
|
|
2214
2671
|
function getInnerExpression(node) {
|
|
2215
|
-
if (node.type ===
|
|
2672
|
+
if (node.type === AST_NODE_TYPES34.TSAsExpression) {
|
|
2216
2673
|
return getInnerExpression(node.expression);
|
|
2217
2674
|
}
|
|
2218
2675
|
return node;
|
|
2219
2676
|
}
|
|
2220
2677
|
function isNestedStructure(node) {
|
|
2221
2678
|
const inner = getInnerExpression(node);
|
|
2222
|
-
return inner.type ===
|
|
2679
|
+
return inner.type === AST_NODE_TYPES34.ObjectExpression || inner.type === AST_NODE_TYPES34.ArrayExpression;
|
|
2223
2680
|
}
|
|
2224
2681
|
function containsNestedStructure(node) {
|
|
2225
|
-
if (node.type ===
|
|
2682
|
+
if (node.type === AST_NODE_TYPES34.ObjectExpression) {
|
|
2226
2683
|
return node.properties.some((prop) => {
|
|
2227
|
-
if (prop.type !==
|
|
2684
|
+
if (prop.type !== AST_NODE_TYPES34.Property) return false;
|
|
2228
2685
|
return isNestedStructure(prop.value);
|
|
2229
2686
|
});
|
|
2230
2687
|
}
|
|
@@ -2233,7 +2690,7 @@ function containsNestedStructure(node) {
|
|
|
2233
2690
|
return isNestedStructure(el);
|
|
2234
2691
|
});
|
|
2235
2692
|
}
|
|
2236
|
-
var noInlineNestedObject =
|
|
2693
|
+
var noInlineNestedObject = createRule34({
|
|
2237
2694
|
name: "no-inline-nested-object",
|
|
2238
2695
|
meta: {
|
|
2239
2696
|
type: "layout",
|
|
@@ -2255,7 +2712,7 @@ var noInlineNestedObject = createRule30({
|
|
|
2255
2712
|
return;
|
|
2256
2713
|
}
|
|
2257
2714
|
const valueNode = getInnerExpression(node.value);
|
|
2258
|
-
if (valueNode.type !==
|
|
2715
|
+
if (valueNode.type !== AST_NODE_TYPES34.ObjectExpression && valueNode.type !== AST_NODE_TYPES34.ArrayExpression) {
|
|
2259
2716
|
return;
|
|
2260
2717
|
}
|
|
2261
2718
|
if (!valueNode.loc) {
|
|
@@ -2268,7 +2725,7 @@ var noInlineNestedObject = createRule30({
|
|
|
2268
2725
|
if (!containsNestedStructure(valueNode)) {
|
|
2269
2726
|
return;
|
|
2270
2727
|
}
|
|
2271
|
-
const elements = valueNode.type ===
|
|
2728
|
+
const elements = valueNode.type === AST_NODE_TYPES34.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2272
2729
|
context.report({
|
|
2273
2730
|
node: valueNode,
|
|
2274
2731
|
messageId: "requireMultiline",
|
|
@@ -2281,7 +2738,7 @@ var noInlineNestedObject = createRule30({
|
|
|
2281
2738
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2282
2739
|
const innerIndent = `${indent} `;
|
|
2283
2740
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2284
|
-
const isObject = valueNode.type ===
|
|
2741
|
+
const isObject = valueNode.type === AST_NODE_TYPES34.ObjectExpression;
|
|
2285
2742
|
const openChar = isObject ? "{" : "[";
|
|
2286
2743
|
const closeChar = isObject ? "}" : "]";
|
|
2287
2744
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2298,20 +2755,20 @@ ${indent}${closeChar}`;
|
|
|
2298
2755
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2299
2756
|
|
|
2300
2757
|
// src/rules/no-inline-return-properties.ts
|
|
2301
|
-
import { AST_NODE_TYPES as
|
|
2302
|
-
var
|
|
2758
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES35, ESLintUtils as ESLintUtils35 } from "@typescript-eslint/utils";
|
|
2759
|
+
var createRule35 = ESLintUtils35.RuleCreator(
|
|
2303
2760
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2304
2761
|
);
|
|
2305
2762
|
var isShorthandProperty = (property) => {
|
|
2306
|
-
if (property.type ===
|
|
2763
|
+
if (property.type === AST_NODE_TYPES35.SpreadElement) {
|
|
2307
2764
|
return true;
|
|
2308
2765
|
}
|
|
2309
|
-
if (property.type !==
|
|
2766
|
+
if (property.type !== AST_NODE_TYPES35.Property) {
|
|
2310
2767
|
return false;
|
|
2311
2768
|
}
|
|
2312
2769
|
return property.shorthand;
|
|
2313
2770
|
};
|
|
2314
|
-
var noInlineReturnProperties =
|
|
2771
|
+
var noInlineReturnProperties = createRule35({
|
|
2315
2772
|
name: "no-inline-return-properties",
|
|
2316
2773
|
meta: {
|
|
2317
2774
|
type: "suggestion",
|
|
@@ -2327,20 +2784,20 @@ var noInlineReturnProperties = createRule31({
|
|
|
2327
2784
|
create(context) {
|
|
2328
2785
|
return {
|
|
2329
2786
|
ReturnStatement(node) {
|
|
2330
|
-
if (!node.argument || node.argument.type !==
|
|
2787
|
+
if (!node.argument || node.argument.type !== AST_NODE_TYPES35.ObjectExpression) {
|
|
2331
2788
|
return;
|
|
2332
2789
|
}
|
|
2333
2790
|
node.argument.properties.forEach((property) => {
|
|
2334
2791
|
if (isShorthandProperty(property)) {
|
|
2335
2792
|
return;
|
|
2336
2793
|
}
|
|
2337
|
-
if (property.type !==
|
|
2794
|
+
if (property.type !== AST_NODE_TYPES35.Property) {
|
|
2338
2795
|
return;
|
|
2339
2796
|
}
|
|
2340
2797
|
let keyName = null;
|
|
2341
|
-
if (property.key.type ===
|
|
2798
|
+
if (property.key.type === AST_NODE_TYPES35.Identifier) {
|
|
2342
2799
|
keyName = property.key.name;
|
|
2343
|
-
} else if (property.key.type ===
|
|
2800
|
+
} else if (property.key.type === AST_NODE_TYPES35.Literal) {
|
|
2344
2801
|
keyName = String(property.key.value);
|
|
2345
2802
|
}
|
|
2346
2803
|
context.report({
|
|
@@ -2356,12 +2813,12 @@ var noInlineReturnProperties = createRule31({
|
|
|
2356
2813
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2357
2814
|
|
|
2358
2815
|
// src/rules/no-inline-type-import.ts
|
|
2359
|
-
import { AST_NODE_TYPES as
|
|
2360
|
-
var
|
|
2816
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36, ESLintUtils as ESLintUtils36 } from "@typescript-eslint/utils";
|
|
2817
|
+
var createRule36 = ESLintUtils36.RuleCreator(
|
|
2361
2818
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2362
2819
|
);
|
|
2363
|
-
var isInlineTypeSpecifier = (specifier) => specifier.type ===
|
|
2364
|
-
var noInlineTypeImport =
|
|
2820
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === AST_NODE_TYPES36.ImportSpecifier && specifier.importKind === "type";
|
|
2821
|
+
var noInlineTypeImport = createRule36({
|
|
2365
2822
|
name: "no-inline-type-import",
|
|
2366
2823
|
meta: {
|
|
2367
2824
|
type: "suggestion",
|
|
@@ -2398,7 +2855,7 @@ var noInlineTypeImport = createRule32({
|
|
|
2398
2855
|
);
|
|
2399
2856
|
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2400
2857
|
const valueSpecifiers = node.specifiers.filter(
|
|
2401
|
-
(specifier) => !(specifier.type ===
|
|
2858
|
+
(specifier) => !(specifier.type === AST_NODE_TYPES36.ImportSpecifier && specifier.importKind === "type")
|
|
2402
2859
|
);
|
|
2403
2860
|
if (valueSpecifiers.length === 0) {
|
|
2404
2861
|
return fixer.replaceText(node, typeImport);
|
|
@@ -2406,11 +2863,11 @@ var noInlineTypeImport = createRule32({
|
|
|
2406
2863
|
const parts = [];
|
|
2407
2864
|
const namedValueSpecifiers = [];
|
|
2408
2865
|
for (const specifier of valueSpecifiers) {
|
|
2409
|
-
if (specifier.type ===
|
|
2866
|
+
if (specifier.type === AST_NODE_TYPES36.ImportDefaultSpecifier) {
|
|
2410
2867
|
parts.push(specifier.local.name);
|
|
2411
|
-
} else if (specifier.type ===
|
|
2868
|
+
} else if (specifier.type === AST_NODE_TYPES36.ImportNamespaceSpecifier) {
|
|
2412
2869
|
parts.push(`* as ${specifier.local.name}`);
|
|
2413
|
-
} else if (specifier.type ===
|
|
2870
|
+
} else if (specifier.type === AST_NODE_TYPES36.ImportSpecifier) {
|
|
2414
2871
|
namedValueSpecifiers.push(specifier);
|
|
2415
2872
|
}
|
|
2416
2873
|
}
|
|
@@ -2430,8 +2887,8 @@ ${typeImport}`);
|
|
|
2430
2887
|
var no_inline_type_import_default = noInlineTypeImport;
|
|
2431
2888
|
|
|
2432
2889
|
// src/rules/no-lazy-identifiers.ts
|
|
2433
|
-
import { AST_NODE_TYPES as
|
|
2434
|
-
var
|
|
2890
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37, ESLintUtils as ESLintUtils37 } from "@typescript-eslint/utils";
|
|
2891
|
+
var createRule37 = ESLintUtils37.RuleCreator(
|
|
2435
2892
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2436
2893
|
);
|
|
2437
2894
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2472,7 +2929,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2472
2929
|
}
|
|
2473
2930
|
return false;
|
|
2474
2931
|
};
|
|
2475
|
-
var noLazyIdentifiers =
|
|
2932
|
+
var noLazyIdentifiers = createRule37({
|
|
2476
2933
|
name: "no-lazy-identifiers",
|
|
2477
2934
|
meta: {
|
|
2478
2935
|
type: "problem",
|
|
@@ -2498,27 +2955,27 @@ var noLazyIdentifiers = createRule33({
|
|
|
2498
2955
|
});
|
|
2499
2956
|
};
|
|
2500
2957
|
const checkPattern = (pattern) => {
|
|
2501
|
-
if (pattern.type ===
|
|
2958
|
+
if (pattern.type === AST_NODE_TYPES37.Identifier) {
|
|
2502
2959
|
checkIdentifier(pattern);
|
|
2503
|
-
} else if (pattern.type ===
|
|
2960
|
+
} else if (pattern.type === AST_NODE_TYPES37.ObjectPattern) {
|
|
2504
2961
|
pattern.properties.forEach((prop) => {
|
|
2505
|
-
if (prop.type ===
|
|
2962
|
+
if (prop.type === AST_NODE_TYPES37.Property && prop.value.type === AST_NODE_TYPES37.Identifier) {
|
|
2506
2963
|
checkIdentifier(prop.value);
|
|
2507
|
-
} else if (prop.type ===
|
|
2964
|
+
} else if (prop.type === AST_NODE_TYPES37.RestElement && prop.argument.type === AST_NODE_TYPES37.Identifier) {
|
|
2508
2965
|
checkIdentifier(prop.argument);
|
|
2509
2966
|
}
|
|
2510
2967
|
});
|
|
2511
|
-
} else if (pattern.type ===
|
|
2968
|
+
} else if (pattern.type === AST_NODE_TYPES37.ArrayPattern) {
|
|
2512
2969
|
pattern.elements.forEach((element) => {
|
|
2513
|
-
if (element?.type ===
|
|
2970
|
+
if (element?.type === AST_NODE_TYPES37.Identifier) {
|
|
2514
2971
|
checkIdentifier(element);
|
|
2515
|
-
} else if (element?.type ===
|
|
2972
|
+
} else if (element?.type === AST_NODE_TYPES37.RestElement && element.argument.type === AST_NODE_TYPES37.Identifier) {
|
|
2516
2973
|
checkIdentifier(element.argument);
|
|
2517
2974
|
}
|
|
2518
2975
|
});
|
|
2519
|
-
} else if (pattern.type ===
|
|
2976
|
+
} else if (pattern.type === AST_NODE_TYPES37.AssignmentPattern && pattern.left.type === AST_NODE_TYPES37.Identifier) {
|
|
2520
2977
|
checkIdentifier(pattern.left);
|
|
2521
|
-
} else if (pattern.type ===
|
|
2978
|
+
} else if (pattern.type === AST_NODE_TYPES37.RestElement && pattern.argument.type === AST_NODE_TYPES37.Identifier) {
|
|
2522
2979
|
checkIdentifier(pattern.argument);
|
|
2523
2980
|
}
|
|
2524
2981
|
};
|
|
@@ -2563,11 +3020,11 @@ var noLazyIdentifiers = createRule33({
|
|
|
2563
3020
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2564
3021
|
|
|
2565
3022
|
// src/rules/no-logic-in-params.ts
|
|
2566
|
-
import { AST_NODE_TYPES as
|
|
2567
|
-
var
|
|
3023
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38, ESLintUtils as ESLintUtils38 } from "@typescript-eslint/utils";
|
|
3024
|
+
var createRule38 = ESLintUtils38.RuleCreator(
|
|
2568
3025
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2569
3026
|
);
|
|
2570
|
-
var noLogicInParams =
|
|
3027
|
+
var noLogicInParams = createRule38({
|
|
2571
3028
|
name: "no-logic-in-params",
|
|
2572
3029
|
meta: {
|
|
2573
3030
|
type: "suggestion",
|
|
@@ -2582,20 +3039,20 @@ var noLogicInParams = createRule34({
|
|
|
2582
3039
|
defaultOptions: [],
|
|
2583
3040
|
create(context) {
|
|
2584
3041
|
const isComplexExpression = (node) => {
|
|
2585
|
-
if (node.type ===
|
|
3042
|
+
if (node.type === AST_NODE_TYPES38.SpreadElement) {
|
|
2586
3043
|
return false;
|
|
2587
3044
|
}
|
|
2588
|
-
if (node.type ===
|
|
3045
|
+
if (node.type === AST_NODE_TYPES38.ConditionalExpression) {
|
|
2589
3046
|
return true;
|
|
2590
3047
|
}
|
|
2591
|
-
if (node.type ===
|
|
3048
|
+
if (node.type === AST_NODE_TYPES38.LogicalExpression) {
|
|
2592
3049
|
return true;
|
|
2593
3050
|
}
|
|
2594
|
-
if (node.type ===
|
|
3051
|
+
if (node.type === AST_NODE_TYPES38.BinaryExpression) {
|
|
2595
3052
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2596
3053
|
return logicalOperators.includes(node.operator);
|
|
2597
3054
|
}
|
|
2598
|
-
if (node.type ===
|
|
3055
|
+
if (node.type === AST_NODE_TYPES38.UnaryExpression) {
|
|
2599
3056
|
return node.operator === "!";
|
|
2600
3057
|
}
|
|
2601
3058
|
return false;
|
|
@@ -2608,7 +3065,7 @@ var noLogicInParams = createRule34({
|
|
|
2608
3065
|
messageId: "noLogicInParams"
|
|
2609
3066
|
});
|
|
2610
3067
|
}
|
|
2611
|
-
if (arg.type ===
|
|
3068
|
+
if (arg.type === AST_NODE_TYPES38.ArrayExpression) {
|
|
2612
3069
|
arg.elements.forEach((element) => {
|
|
2613
3070
|
if (element && isComplexExpression(element)) {
|
|
2614
3071
|
context.report({
|
|
@@ -2633,46 +3090,46 @@ var noLogicInParams = createRule34({
|
|
|
2633
3090
|
var no_logic_in_params_default = noLogicInParams;
|
|
2634
3091
|
|
|
2635
3092
|
// src/rules/no-misleading-constant-case.ts
|
|
2636
|
-
import { AST_NODE_TYPES as
|
|
2637
|
-
var
|
|
3093
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39, ESLintUtils as ESLintUtils39 } from "@typescript-eslint/utils";
|
|
3094
|
+
var createRule39 = ESLintUtils39.RuleCreator(
|
|
2638
3095
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2639
3096
|
);
|
|
2640
3097
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2641
|
-
var isAsConstAssertion = (node) => node.type ===
|
|
3098
|
+
var isAsConstAssertion = (node) => node.type === AST_NODE_TYPES39.TSAsExpression && node.typeAnnotation.type === AST_NODE_TYPES39.TSTypeReference && node.typeAnnotation.typeName.type === AST_NODE_TYPES39.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
2642
3099
|
var isStaticValue2 = (init) => {
|
|
2643
3100
|
if (isAsConstAssertion(init)) {
|
|
2644
3101
|
return true;
|
|
2645
3102
|
}
|
|
2646
|
-
if (init.type ===
|
|
3103
|
+
if (init.type === AST_NODE_TYPES39.Literal) {
|
|
2647
3104
|
return true;
|
|
2648
3105
|
}
|
|
2649
|
-
if (init.type ===
|
|
3106
|
+
if (init.type === AST_NODE_TYPES39.UnaryExpression && init.argument.type === AST_NODE_TYPES39.Literal) {
|
|
2650
3107
|
return true;
|
|
2651
3108
|
}
|
|
2652
|
-
if (init.type ===
|
|
3109
|
+
if (init.type === AST_NODE_TYPES39.TemplateLiteral && init.expressions.length === 0) {
|
|
2653
3110
|
return true;
|
|
2654
3111
|
}
|
|
2655
|
-
if (init.type ===
|
|
2656
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
3112
|
+
if (init.type === AST_NODE_TYPES39.ArrayExpression) {
|
|
3113
|
+
return init.elements.every((el) => el !== null && el.type !== AST_NODE_TYPES39.SpreadElement && isStaticValue2(el));
|
|
2657
3114
|
}
|
|
2658
|
-
if (init.type ===
|
|
3115
|
+
if (init.type === AST_NODE_TYPES39.ObjectExpression) {
|
|
2659
3116
|
return init.properties.every(
|
|
2660
|
-
(prop) => prop.type ===
|
|
3117
|
+
(prop) => prop.type === AST_NODE_TYPES39.Property && isStaticValue2(prop.value)
|
|
2661
3118
|
);
|
|
2662
3119
|
}
|
|
2663
3120
|
return false;
|
|
2664
3121
|
};
|
|
2665
3122
|
var isGlobalScope3 = (node) => {
|
|
2666
3123
|
const { parent } = node;
|
|
2667
|
-
if (parent.type ===
|
|
3124
|
+
if (parent.type === AST_NODE_TYPES39.Program) {
|
|
2668
3125
|
return true;
|
|
2669
3126
|
}
|
|
2670
|
-
if (parent.type ===
|
|
3127
|
+
if (parent.type === AST_NODE_TYPES39.ExportNamedDeclaration && parent.parent?.type === AST_NODE_TYPES39.Program) {
|
|
2671
3128
|
return true;
|
|
2672
3129
|
}
|
|
2673
3130
|
return false;
|
|
2674
3131
|
};
|
|
2675
|
-
var noMisleadingConstantCase =
|
|
3132
|
+
var noMisleadingConstantCase = createRule39({
|
|
2676
3133
|
name: "no-misleading-constant-case",
|
|
2677
3134
|
meta: {
|
|
2678
3135
|
type: "suggestion",
|
|
@@ -2691,7 +3148,7 @@ var noMisleadingConstantCase = createRule35({
|
|
|
2691
3148
|
return {
|
|
2692
3149
|
VariableDeclaration(node) {
|
|
2693
3150
|
node.declarations.forEach((declarator) => {
|
|
2694
|
-
if (declarator.id.type !==
|
|
3151
|
+
if (declarator.id.type !== AST_NODE_TYPES39.Identifier) {
|
|
2695
3152
|
return;
|
|
2696
3153
|
}
|
|
2697
3154
|
const { name } = declarator.id;
|
|
@@ -2732,11 +3189,11 @@ var noMisleadingConstantCase = createRule35({
|
|
|
2732
3189
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2733
3190
|
|
|
2734
3191
|
// src/rules/no-nested-interface-declaration.ts
|
|
2735
|
-
import { AST_NODE_TYPES as
|
|
2736
|
-
var
|
|
3192
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40, ESLintUtils as ESLintUtils40 } from "@typescript-eslint/utils";
|
|
3193
|
+
var createRule40 = ESLintUtils40.RuleCreator(
|
|
2737
3194
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2738
3195
|
);
|
|
2739
|
-
var noNestedInterfaceDeclaration =
|
|
3196
|
+
var noNestedInterfaceDeclaration = createRule40({
|
|
2740
3197
|
name: "no-nested-interface-declaration",
|
|
2741
3198
|
meta: {
|
|
2742
3199
|
type: "suggestion",
|
|
@@ -2757,15 +3214,15 @@ var noNestedInterfaceDeclaration = createRule36({
|
|
|
2757
3214
|
return;
|
|
2758
3215
|
}
|
|
2759
3216
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2760
|
-
if (typeAnnotation.type ===
|
|
3217
|
+
if (typeAnnotation.type === AST_NODE_TYPES40.TSTypeLiteral) {
|
|
2761
3218
|
context.report({
|
|
2762
3219
|
node: typeAnnotation,
|
|
2763
3220
|
messageId: "noNestedInterface"
|
|
2764
3221
|
});
|
|
2765
3222
|
return;
|
|
2766
3223
|
}
|
|
2767
|
-
if (typeAnnotation.type ===
|
|
2768
|
-
if (typeAnnotation.elementType.type ===
|
|
3224
|
+
if (typeAnnotation.type === AST_NODE_TYPES40.TSArrayType) {
|
|
3225
|
+
if (typeAnnotation.elementType.type === AST_NODE_TYPES40.TSTypeLiteral) {
|
|
2769
3226
|
context.report({
|
|
2770
3227
|
node: typeAnnotation.elementType,
|
|
2771
3228
|
messageId: "noNestedInterface"
|
|
@@ -2773,9 +3230,9 @@ var noNestedInterfaceDeclaration = createRule36({
|
|
|
2773
3230
|
}
|
|
2774
3231
|
return;
|
|
2775
3232
|
}
|
|
2776
|
-
if (typeAnnotation.type ===
|
|
3233
|
+
if (typeAnnotation.type === AST_NODE_TYPES40.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2777
3234
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2778
|
-
if (param.type ===
|
|
3235
|
+
if (param.type === AST_NODE_TYPES40.TSTypeLiteral) {
|
|
2779
3236
|
context.report({
|
|
2780
3237
|
node: param,
|
|
2781
3238
|
messageId: "noNestedInterface"
|
|
@@ -2790,11 +3247,11 @@ var noNestedInterfaceDeclaration = createRule36({
|
|
|
2790
3247
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2791
3248
|
|
|
2792
3249
|
// src/rules/no-nested-ternary.ts
|
|
2793
|
-
import { AST_NODE_TYPES as
|
|
2794
|
-
var
|
|
3250
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41, ESLintUtils as ESLintUtils41 } from "@typescript-eslint/utils";
|
|
3251
|
+
var createRule41 = ESLintUtils41.RuleCreator(
|
|
2795
3252
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2796
3253
|
);
|
|
2797
|
-
var noNestedTernary =
|
|
3254
|
+
var noNestedTernary = createRule41({
|
|
2798
3255
|
name: "no-nested-ternary",
|
|
2799
3256
|
meta: {
|
|
2800
3257
|
type: "suggestion",
|
|
@@ -2811,13 +3268,13 @@ var noNestedTernary = createRule37({
|
|
|
2811
3268
|
return {
|
|
2812
3269
|
ConditionalExpression(node) {
|
|
2813
3270
|
const { consequent, alternate } = node;
|
|
2814
|
-
if (consequent.type ===
|
|
3271
|
+
if (consequent.type === AST_NODE_TYPES41.ConditionalExpression) {
|
|
2815
3272
|
context.report({
|
|
2816
3273
|
node: consequent,
|
|
2817
3274
|
messageId: "noNestedTernary"
|
|
2818
3275
|
});
|
|
2819
3276
|
}
|
|
2820
|
-
if (alternate.type ===
|
|
3277
|
+
if (alternate.type === AST_NODE_TYPES41.ConditionalExpression) {
|
|
2821
3278
|
context.report({
|
|
2822
3279
|
node: alternate,
|
|
2823
3280
|
messageId: "noNestedTernary"
|
|
@@ -2830,33 +3287,33 @@ var noNestedTernary = createRule37({
|
|
|
2830
3287
|
var no_nested_ternary_default = noNestedTernary;
|
|
2831
3288
|
|
|
2832
3289
|
// src/rules/no-redundant-fragment.ts
|
|
2833
|
-
import { AST_NODE_TYPES as
|
|
2834
|
-
var
|
|
3290
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42, ESLintUtils as ESLintUtils42 } from "@typescript-eslint/utils";
|
|
3291
|
+
var createRule42 = ESLintUtils42.RuleCreator(
|
|
2835
3292
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2836
3293
|
);
|
|
2837
3294
|
function isFragmentName(name) {
|
|
2838
|
-
if (name.type ===
|
|
3295
|
+
if (name.type === AST_NODE_TYPES42.JSXIdentifier && name.name === "Fragment") {
|
|
2839
3296
|
return true;
|
|
2840
3297
|
}
|
|
2841
|
-
if (name.type ===
|
|
3298
|
+
if (name.type === AST_NODE_TYPES42.JSXMemberExpression && name.object.type === AST_NODE_TYPES42.JSXIdentifier && name.object.name === "React" && name.property.type === AST_NODE_TYPES42.JSXIdentifier && name.property.name === "Fragment") {
|
|
2842
3299
|
return true;
|
|
2843
3300
|
}
|
|
2844
3301
|
return false;
|
|
2845
3302
|
}
|
|
2846
3303
|
function hasKeyAttribute(attributes) {
|
|
2847
3304
|
return attributes.some(
|
|
2848
|
-
(attribute) => attribute.type ===
|
|
3305
|
+
(attribute) => attribute.type === AST_NODE_TYPES42.JSXAttribute && attribute.name.type === AST_NODE_TYPES42.JSXIdentifier && attribute.name.name === "key"
|
|
2849
3306
|
);
|
|
2850
3307
|
}
|
|
2851
3308
|
function countMeaningfulChildren(children) {
|
|
2852
3309
|
return children.filter((child) => {
|
|
2853
|
-
if (child.type ===
|
|
3310
|
+
if (child.type === AST_NODE_TYPES42.JSXText) {
|
|
2854
3311
|
return child.value.trim() !== "";
|
|
2855
3312
|
}
|
|
2856
3313
|
return true;
|
|
2857
3314
|
}).length;
|
|
2858
3315
|
}
|
|
2859
|
-
var noRedundantFragment =
|
|
3316
|
+
var noRedundantFragment = createRule42({
|
|
2860
3317
|
name: "no-redundant-fragment",
|
|
2861
3318
|
meta: {
|
|
2862
3319
|
type: "problem",
|
|
@@ -2904,11 +3361,11 @@ var noRedundantFragment = createRule38({
|
|
|
2904
3361
|
var no_redundant_fragment_default = noRedundantFragment;
|
|
2905
3362
|
|
|
2906
3363
|
// src/rules/no-relative-imports.ts
|
|
2907
|
-
import { AST_NODE_TYPES as
|
|
2908
|
-
var
|
|
3364
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43, ESLintUtils as ESLintUtils43 } from "@typescript-eslint/utils";
|
|
3365
|
+
var createRule43 = ESLintUtils43.RuleCreator(
|
|
2909
3366
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2910
3367
|
);
|
|
2911
|
-
var noRelativeImports =
|
|
3368
|
+
var noRelativeImports = createRule43({
|
|
2912
3369
|
name: "no-relative-imports",
|
|
2913
3370
|
meta: {
|
|
2914
3371
|
type: "suggestion",
|
|
@@ -2932,22 +3389,22 @@ var noRelativeImports = createRule39({
|
|
|
2932
3389
|
};
|
|
2933
3390
|
return {
|
|
2934
3391
|
ImportDeclaration(node) {
|
|
2935
|
-
if (node.source.type ===
|
|
3392
|
+
if (node.source.type === AST_NODE_TYPES43.Literal && typeof node.source.value === "string") {
|
|
2936
3393
|
checkImportPath(node.source.value, node);
|
|
2937
3394
|
}
|
|
2938
3395
|
},
|
|
2939
3396
|
ImportExpression(node) {
|
|
2940
|
-
if (node.source.type ===
|
|
3397
|
+
if (node.source.type === AST_NODE_TYPES43.Literal && typeof node.source.value === "string") {
|
|
2941
3398
|
checkImportPath(node.source.value, node);
|
|
2942
3399
|
}
|
|
2943
3400
|
},
|
|
2944
3401
|
ExportNamedDeclaration(node) {
|
|
2945
|
-
if (node.source?.type ===
|
|
3402
|
+
if (node.source?.type === AST_NODE_TYPES43.Literal && typeof node.source.value === "string") {
|
|
2946
3403
|
checkImportPath(node.source.value, node);
|
|
2947
3404
|
}
|
|
2948
3405
|
},
|
|
2949
3406
|
ExportAllDeclaration(node) {
|
|
2950
|
-
if (node.source.type ===
|
|
3407
|
+
if (node.source.type === AST_NODE_TYPES43.Literal && typeof node.source.value === "string") {
|
|
2951
3408
|
checkImportPath(node.source.value, node);
|
|
2952
3409
|
}
|
|
2953
3410
|
}
|
|
@@ -2957,8 +3414,8 @@ var noRelativeImports = createRule39({
|
|
|
2957
3414
|
var no_relative_imports_default = noRelativeImports;
|
|
2958
3415
|
|
|
2959
3416
|
// src/rules/no-single-char-variables.ts
|
|
2960
|
-
import { AST_NODE_TYPES as
|
|
2961
|
-
var
|
|
3417
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44, ESLintUtils as ESLintUtils44 } from "@typescript-eslint/utils";
|
|
3418
|
+
var createRule44 = ESLintUtils44.RuleCreator(
|
|
2962
3419
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2963
3420
|
);
|
|
2964
3421
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -2970,7 +3427,7 @@ var isForLoopInit = (node) => {
|
|
|
2970
3427
|
if (!parentNode) {
|
|
2971
3428
|
return false;
|
|
2972
3429
|
}
|
|
2973
|
-
if (parentNode.type ===
|
|
3430
|
+
if (parentNode.type === AST_NODE_TYPES44.ForStatement) {
|
|
2974
3431
|
const { init } = parentNode;
|
|
2975
3432
|
if (init && init === current) {
|
|
2976
3433
|
return true;
|
|
@@ -2989,7 +3446,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
2989
3446
|
}
|
|
2990
3447
|
return false;
|
|
2991
3448
|
};
|
|
2992
|
-
var noSingleCharVariables =
|
|
3449
|
+
var noSingleCharVariables = createRule44({
|
|
2993
3450
|
name: "no-single-char-variables",
|
|
2994
3451
|
meta: {
|
|
2995
3452
|
type: "suggestion",
|
|
@@ -3018,27 +3475,27 @@ var noSingleCharVariables = createRule40({
|
|
|
3018
3475
|
});
|
|
3019
3476
|
};
|
|
3020
3477
|
const checkPattern = (pattern, declarationNode) => {
|
|
3021
|
-
if (pattern.type ===
|
|
3478
|
+
if (pattern.type === AST_NODE_TYPES44.Identifier) {
|
|
3022
3479
|
checkIdentifier(pattern, declarationNode);
|
|
3023
|
-
} else if (pattern.type ===
|
|
3480
|
+
} else if (pattern.type === AST_NODE_TYPES44.ObjectPattern) {
|
|
3024
3481
|
pattern.properties.forEach((prop) => {
|
|
3025
|
-
if (prop.type ===
|
|
3482
|
+
if (prop.type === AST_NODE_TYPES44.Property && prop.value.type === AST_NODE_TYPES44.Identifier) {
|
|
3026
3483
|
checkIdentifier(prop.value, declarationNode);
|
|
3027
|
-
} else if (prop.type ===
|
|
3484
|
+
} else if (prop.type === AST_NODE_TYPES44.RestElement && prop.argument.type === AST_NODE_TYPES44.Identifier) {
|
|
3028
3485
|
checkIdentifier(prop.argument, declarationNode);
|
|
3029
3486
|
}
|
|
3030
3487
|
});
|
|
3031
|
-
} else if (pattern.type ===
|
|
3488
|
+
} else if (pattern.type === AST_NODE_TYPES44.ArrayPattern) {
|
|
3032
3489
|
pattern.elements.forEach((element) => {
|
|
3033
|
-
if (element?.type ===
|
|
3490
|
+
if (element?.type === AST_NODE_TYPES44.Identifier) {
|
|
3034
3491
|
checkIdentifier(element, declarationNode);
|
|
3035
|
-
} else if (element?.type ===
|
|
3492
|
+
} else if (element?.type === AST_NODE_TYPES44.RestElement && element.argument.type === AST_NODE_TYPES44.Identifier) {
|
|
3036
3493
|
checkIdentifier(element.argument, declarationNode);
|
|
3037
3494
|
}
|
|
3038
3495
|
});
|
|
3039
|
-
} else if (pattern.type ===
|
|
3496
|
+
} else if (pattern.type === AST_NODE_TYPES44.AssignmentPattern && pattern.left.type === AST_NODE_TYPES44.Identifier) {
|
|
3040
3497
|
checkIdentifier(pattern.left, declarationNode);
|
|
3041
|
-
} else if (pattern.type ===
|
|
3498
|
+
} else if (pattern.type === AST_NODE_TYPES44.RestElement && pattern.argument.type === AST_NODE_TYPES44.Identifier) {
|
|
3042
3499
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3043
3500
|
}
|
|
3044
3501
|
};
|
|
@@ -3072,11 +3529,11 @@ var noSingleCharVariables = createRule40({
|
|
|
3072
3529
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3073
3530
|
|
|
3074
3531
|
// src/rules/prefer-async-await.ts
|
|
3075
|
-
import { AST_NODE_TYPES as
|
|
3076
|
-
var
|
|
3532
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45, ESLintUtils as ESLintUtils45 } from "@typescript-eslint/utils";
|
|
3533
|
+
var createRule45 = ESLintUtils45.RuleCreator(
|
|
3077
3534
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3078
3535
|
);
|
|
3079
|
-
var preferAsyncAwait =
|
|
3536
|
+
var preferAsyncAwait = createRule45({
|
|
3080
3537
|
name: "prefer-async-await",
|
|
3081
3538
|
meta: {
|
|
3082
3539
|
type: "suggestion",
|
|
@@ -3092,7 +3549,7 @@ var preferAsyncAwait = createRule41({
|
|
|
3092
3549
|
create(context) {
|
|
3093
3550
|
return {
|
|
3094
3551
|
CallExpression(node) {
|
|
3095
|
-
if (node.callee.type ===
|
|
3552
|
+
if (node.callee.type === AST_NODE_TYPES45.MemberExpression && node.callee.property.type === AST_NODE_TYPES45.Identifier && node.callee.property.name === "then") {
|
|
3096
3553
|
context.report({
|
|
3097
3554
|
node: node.callee.property,
|
|
3098
3555
|
messageId: "preferAsyncAwait"
|
|
@@ -3105,11 +3562,11 @@ var preferAsyncAwait = createRule41({
|
|
|
3105
3562
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3106
3563
|
|
|
3107
3564
|
// src/rules/prefer-destructuring-params.ts
|
|
3108
|
-
import { AST_NODE_TYPES as
|
|
3109
|
-
var
|
|
3565
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46, ESLintUtils as ESLintUtils46 } from "@typescript-eslint/utils";
|
|
3566
|
+
var createRule46 = ESLintUtils46.RuleCreator(
|
|
3110
3567
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3111
3568
|
);
|
|
3112
|
-
var preferDestructuringParams =
|
|
3569
|
+
var preferDestructuringParams = createRule46({
|
|
3113
3570
|
name: "prefer-destructuring-params",
|
|
3114
3571
|
meta: {
|
|
3115
3572
|
type: "suggestion",
|
|
@@ -3125,18 +3582,18 @@ var preferDestructuringParams = createRule42({
|
|
|
3125
3582
|
create(context) {
|
|
3126
3583
|
const isCallbackFunction2 = (node) => {
|
|
3127
3584
|
const { parent } = node;
|
|
3128
|
-
return parent?.type ===
|
|
3585
|
+
return parent?.type === AST_NODE_TYPES46.CallExpression;
|
|
3129
3586
|
};
|
|
3130
3587
|
const isDeveloperFunction = (node) => {
|
|
3131
|
-
if (node.type ===
|
|
3588
|
+
if (node.type === AST_NODE_TYPES46.FunctionDeclaration) {
|
|
3132
3589
|
return true;
|
|
3133
3590
|
}
|
|
3134
|
-
if (node.type ===
|
|
3591
|
+
if (node.type === AST_NODE_TYPES46.FunctionExpression || node.type === AST_NODE_TYPES46.ArrowFunctionExpression) {
|
|
3135
3592
|
if (isCallbackFunction2(node)) {
|
|
3136
3593
|
return false;
|
|
3137
3594
|
}
|
|
3138
3595
|
const { parent } = node;
|
|
3139
|
-
return parent?.type ===
|
|
3596
|
+
return parent?.type === AST_NODE_TYPES46.VariableDeclarator || parent?.type === AST_NODE_TYPES46.AssignmentExpression || parent?.type === AST_NODE_TYPES46.Property || parent?.type === AST_NODE_TYPES46.MethodDefinition;
|
|
3140
3597
|
}
|
|
3141
3598
|
return false;
|
|
3142
3599
|
};
|
|
@@ -3148,7 +3605,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3148
3605
|
if (!isDeveloperFunction(node)) {
|
|
3149
3606
|
return;
|
|
3150
3607
|
}
|
|
3151
|
-
if (node.type ===
|
|
3608
|
+
if (node.type === AST_NODE_TYPES46.FunctionDeclaration && node.id) {
|
|
3152
3609
|
const functionName = node.id.name;
|
|
3153
3610
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3154
3611
|
return;
|
|
@@ -3158,7 +3615,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3158
3615
|
return;
|
|
3159
3616
|
}
|
|
3160
3617
|
const hasNonDestructuredParams = node.params.some(
|
|
3161
|
-
(param) => param.type !==
|
|
3618
|
+
(param) => param.type !== AST_NODE_TYPES46.ObjectPattern && param.type !== AST_NODE_TYPES46.RestElement
|
|
3162
3619
|
);
|
|
3163
3620
|
if (hasNonDestructuredParams) {
|
|
3164
3621
|
context.report({
|
|
@@ -3177,8 +3634,8 @@ var preferDestructuringParams = createRule42({
|
|
|
3177
3634
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3178
3635
|
|
|
3179
3636
|
// src/rules/prefer-function-declaration.ts
|
|
3180
|
-
import { AST_NODE_TYPES as
|
|
3181
|
-
var
|
|
3637
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47, ESLintUtils as ESLintUtils47 } from "@typescript-eslint/utils";
|
|
3638
|
+
var createRule47 = ESLintUtils47.RuleCreator(
|
|
3182
3639
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3183
3640
|
);
|
|
3184
3641
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3187,33 +3644,33 @@ var isCallbackContext = (node) => {
|
|
|
3187
3644
|
if (!parent) {
|
|
3188
3645
|
return false;
|
|
3189
3646
|
}
|
|
3190
|
-
if (parent.type ===
|
|
3647
|
+
if (parent.type === AST_NODE_TYPES47.CallExpression && parent.arguments.includes(node)) {
|
|
3191
3648
|
return true;
|
|
3192
3649
|
}
|
|
3193
|
-
if (parent.type ===
|
|
3650
|
+
if (parent.type === AST_NODE_TYPES47.NewExpression && parent.arguments.includes(node)) {
|
|
3194
3651
|
return true;
|
|
3195
3652
|
}
|
|
3196
|
-
if (parent.type ===
|
|
3653
|
+
if (parent.type === AST_NODE_TYPES47.ReturnStatement) {
|
|
3197
3654
|
return true;
|
|
3198
3655
|
}
|
|
3199
|
-
if (parent.type ===
|
|
3656
|
+
if (parent.type === AST_NODE_TYPES47.Property) {
|
|
3200
3657
|
return true;
|
|
3201
3658
|
}
|
|
3202
|
-
if (parent.type ===
|
|
3659
|
+
if (parent.type === AST_NODE_TYPES47.ArrayExpression) {
|
|
3203
3660
|
return true;
|
|
3204
3661
|
}
|
|
3205
|
-
if (parent.type ===
|
|
3662
|
+
if (parent.type === AST_NODE_TYPES47.ConditionalExpression) {
|
|
3206
3663
|
return true;
|
|
3207
3664
|
}
|
|
3208
|
-
if (parent.type ===
|
|
3665
|
+
if (parent.type === AST_NODE_TYPES47.LogicalExpression) {
|
|
3209
3666
|
return true;
|
|
3210
3667
|
}
|
|
3211
|
-
if (parent.type ===
|
|
3668
|
+
if (parent.type === AST_NODE_TYPES47.AssignmentExpression && parent.left !== node) {
|
|
3212
3669
|
return true;
|
|
3213
3670
|
}
|
|
3214
3671
|
return false;
|
|
3215
3672
|
};
|
|
3216
|
-
var preferFunctionDeclaration =
|
|
3673
|
+
var preferFunctionDeclaration = createRule47({
|
|
3217
3674
|
name: "prefer-function-declaration",
|
|
3218
3675
|
meta: {
|
|
3219
3676
|
type: "suggestion",
|
|
@@ -3234,14 +3691,14 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3234
3691
|
}
|
|
3235
3692
|
return {
|
|
3236
3693
|
VariableDeclarator(node) {
|
|
3237
|
-
if (node.id.type !==
|
|
3694
|
+
if (node.id.type !== AST_NODE_TYPES47.Identifier) {
|
|
3238
3695
|
return;
|
|
3239
3696
|
}
|
|
3240
3697
|
const { init } = node;
|
|
3241
3698
|
if (!init) {
|
|
3242
3699
|
return;
|
|
3243
3700
|
}
|
|
3244
|
-
if (init.type ===
|
|
3701
|
+
if (init.type === AST_NODE_TYPES47.ArrowFunctionExpression) {
|
|
3245
3702
|
if (isCallbackContext(init)) {
|
|
3246
3703
|
return;
|
|
3247
3704
|
}
|
|
@@ -3251,7 +3708,7 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3251
3708
|
data: { name: node.id.name }
|
|
3252
3709
|
});
|
|
3253
3710
|
}
|
|
3254
|
-
if (init.type ===
|
|
3711
|
+
if (init.type === AST_NODE_TYPES47.FunctionExpression) {
|
|
3255
3712
|
if (isCallbackContext(init)) {
|
|
3256
3713
|
return;
|
|
3257
3714
|
}
|
|
@@ -3268,11 +3725,11 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3268
3725
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3269
3726
|
|
|
3270
3727
|
// src/rules/prefer-guard-clause.ts
|
|
3271
|
-
import { AST_NODE_TYPES as
|
|
3272
|
-
var
|
|
3728
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48, ESLintUtils as ESLintUtils48 } from "@typescript-eslint/utils";
|
|
3729
|
+
var createRule48 = ESLintUtils48.RuleCreator(
|
|
3273
3730
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3274
3731
|
);
|
|
3275
|
-
var preferGuardClause =
|
|
3732
|
+
var preferGuardClause = createRule48({
|
|
3276
3733
|
name: "prefer-guard-clause",
|
|
3277
3734
|
meta: {
|
|
3278
3735
|
type: "suggestion",
|
|
@@ -3289,8 +3746,8 @@ var preferGuardClause = createRule44({
|
|
|
3289
3746
|
return {
|
|
3290
3747
|
IfStatement(node) {
|
|
3291
3748
|
const { consequent } = node;
|
|
3292
|
-
if (consequent.type ===
|
|
3293
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3749
|
+
if (consequent.type === AST_NODE_TYPES48.BlockStatement) {
|
|
3750
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === AST_NODE_TYPES48.IfStatement);
|
|
3294
3751
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3295
3752
|
context.report({
|
|
3296
3753
|
node,
|
|
@@ -3298,7 +3755,7 @@ var preferGuardClause = createRule44({
|
|
|
3298
3755
|
});
|
|
3299
3756
|
}
|
|
3300
3757
|
}
|
|
3301
|
-
if (consequent.type ===
|
|
3758
|
+
if (consequent.type === AST_NODE_TYPES48.IfStatement) {
|
|
3302
3759
|
context.report({
|
|
3303
3760
|
node,
|
|
3304
3761
|
messageId: "preferGuardClause"
|
|
@@ -3311,11 +3768,11 @@ var preferGuardClause = createRule44({
|
|
|
3311
3768
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3312
3769
|
|
|
3313
3770
|
// src/rules/prefer-import-type.ts
|
|
3314
|
-
import { AST_NODE_TYPES as
|
|
3315
|
-
var
|
|
3771
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49, ESLintUtils as ESLintUtils49 } from "@typescript-eslint/utils";
|
|
3772
|
+
var createRule49 = ESLintUtils49.RuleCreator(
|
|
3316
3773
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3317
3774
|
);
|
|
3318
|
-
var preferImportType =
|
|
3775
|
+
var preferImportType = createRule49({
|
|
3319
3776
|
name: "prefer-import-type",
|
|
3320
3777
|
meta: {
|
|
3321
3778
|
type: "suggestion",
|
|
@@ -3334,22 +3791,22 @@ var preferImportType = createRule45({
|
|
|
3334
3791
|
let current = node;
|
|
3335
3792
|
while (current) {
|
|
3336
3793
|
switch (current.type) {
|
|
3337
|
-
case
|
|
3338
|
-
case
|
|
3339
|
-
case
|
|
3340
|
-
case
|
|
3341
|
-
case
|
|
3342
|
-
case
|
|
3343
|
-
case
|
|
3344
|
-
case
|
|
3345
|
-
case
|
|
3346
|
-
case
|
|
3347
|
-
case
|
|
3348
|
-
case
|
|
3349
|
-
case
|
|
3794
|
+
case AST_NODE_TYPES49.TSTypeReference:
|
|
3795
|
+
case AST_NODE_TYPES49.TSTypeAnnotation:
|
|
3796
|
+
case AST_NODE_TYPES49.TSTypeParameterInstantiation:
|
|
3797
|
+
case AST_NODE_TYPES49.TSInterfaceHeritage:
|
|
3798
|
+
case AST_NODE_TYPES49.TSClassImplements:
|
|
3799
|
+
case AST_NODE_TYPES49.TSTypeQuery:
|
|
3800
|
+
case AST_NODE_TYPES49.TSTypeAssertion:
|
|
3801
|
+
case AST_NODE_TYPES49.TSAsExpression:
|
|
3802
|
+
case AST_NODE_TYPES49.TSSatisfiesExpression:
|
|
3803
|
+
case AST_NODE_TYPES49.TSTypeAliasDeclaration:
|
|
3804
|
+
case AST_NODE_TYPES49.TSInterfaceDeclaration:
|
|
3805
|
+
case AST_NODE_TYPES49.TSTypeParameter:
|
|
3806
|
+
case AST_NODE_TYPES49.TSQualifiedName:
|
|
3350
3807
|
return true;
|
|
3351
|
-
case
|
|
3352
|
-
case
|
|
3808
|
+
case AST_NODE_TYPES49.MemberExpression:
|
|
3809
|
+
case AST_NODE_TYPES49.Identifier:
|
|
3353
3810
|
current = current.parent;
|
|
3354
3811
|
break;
|
|
3355
3812
|
default:
|
|
@@ -3379,27 +3836,27 @@ var preferImportType = createRule45({
|
|
|
3379
3836
|
return false;
|
|
3380
3837
|
}
|
|
3381
3838
|
switch (parent.type) {
|
|
3382
|
-
case
|
|
3383
|
-
case
|
|
3384
|
-
case
|
|
3385
|
-
case
|
|
3386
|
-
case
|
|
3387
|
-
case
|
|
3388
|
-
case
|
|
3389
|
-
case
|
|
3390
|
-
case
|
|
3391
|
-
case
|
|
3392
|
-
case
|
|
3393
|
-
case
|
|
3394
|
-
case
|
|
3395
|
-
case
|
|
3396
|
-
case
|
|
3397
|
-
case
|
|
3398
|
-
case
|
|
3399
|
-
case
|
|
3400
|
-
case
|
|
3401
|
-
case
|
|
3402
|
-
case
|
|
3839
|
+
case AST_NODE_TYPES49.CallExpression:
|
|
3840
|
+
case AST_NODE_TYPES49.NewExpression:
|
|
3841
|
+
case AST_NODE_TYPES49.JSXOpeningElement:
|
|
3842
|
+
case AST_NODE_TYPES49.JSXClosingElement:
|
|
3843
|
+
case AST_NODE_TYPES49.MemberExpression:
|
|
3844
|
+
case AST_NODE_TYPES49.VariableDeclarator:
|
|
3845
|
+
case AST_NODE_TYPES49.TaggedTemplateExpression:
|
|
3846
|
+
case AST_NODE_TYPES49.SpreadElement:
|
|
3847
|
+
case AST_NODE_TYPES49.ExportSpecifier:
|
|
3848
|
+
case AST_NODE_TYPES49.ArrayExpression:
|
|
3849
|
+
case AST_NODE_TYPES49.ObjectExpression:
|
|
3850
|
+
case AST_NODE_TYPES49.BinaryExpression:
|
|
3851
|
+
case AST_NODE_TYPES49.LogicalExpression:
|
|
3852
|
+
case AST_NODE_TYPES49.UnaryExpression:
|
|
3853
|
+
case AST_NODE_TYPES49.ReturnStatement:
|
|
3854
|
+
case AST_NODE_TYPES49.ArrowFunctionExpression:
|
|
3855
|
+
case AST_NODE_TYPES49.ConditionalExpression:
|
|
3856
|
+
case AST_NODE_TYPES49.AwaitExpression:
|
|
3857
|
+
case AST_NODE_TYPES49.YieldExpression:
|
|
3858
|
+
case AST_NODE_TYPES49.Property:
|
|
3859
|
+
case AST_NODE_TYPES49.JSXExpressionContainer:
|
|
3403
3860
|
return true;
|
|
3404
3861
|
default:
|
|
3405
3862
|
return false;
|
|
@@ -3411,7 +3868,7 @@ var preferImportType = createRule45({
|
|
|
3411
3868
|
return;
|
|
3412
3869
|
}
|
|
3413
3870
|
const hasInlineTypeSpecifier = node.specifiers.some(
|
|
3414
|
-
(specifier) => specifier.type ===
|
|
3871
|
+
(specifier) => specifier.type === AST_NODE_TYPES49.ImportSpecifier && specifier.importKind === "type"
|
|
3415
3872
|
);
|
|
3416
3873
|
if (hasInlineTypeSpecifier) {
|
|
3417
3874
|
return;
|
|
@@ -3429,13 +3886,13 @@ var preferImportType = createRule45({
|
|
|
3429
3886
|
}
|
|
3430
3887
|
const scope = context.sourceCode.getScope(node);
|
|
3431
3888
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3432
|
-
if (specifier.type ===
|
|
3889
|
+
if (specifier.type === AST_NODE_TYPES49.ImportDefaultSpecifier) {
|
|
3433
3890
|
return false;
|
|
3434
3891
|
}
|
|
3435
|
-
if (specifier.type ===
|
|
3892
|
+
if (specifier.type === AST_NODE_TYPES49.ImportNamespaceSpecifier) {
|
|
3436
3893
|
return false;
|
|
3437
3894
|
}
|
|
3438
|
-
if (specifier.type ===
|
|
3895
|
+
if (specifier.type === AST_NODE_TYPES49.ImportSpecifier) {
|
|
3439
3896
|
const localName = specifier.local.name;
|
|
3440
3897
|
return !isUsedAsValue(localName, scope);
|
|
3441
3898
|
}
|
|
@@ -3461,19 +3918,19 @@ var preferImportType = createRule45({
|
|
|
3461
3918
|
var prefer_import_type_default = preferImportType;
|
|
3462
3919
|
|
|
3463
3920
|
// src/rules/prefer-inline-literal-union.ts
|
|
3464
|
-
import { AST_NODE_TYPES as
|
|
3465
|
-
var
|
|
3921
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50, ESLintUtils as ESLintUtils50 } from "@typescript-eslint/utils";
|
|
3922
|
+
var createRule50 = ESLintUtils50.RuleCreator(
|
|
3466
3923
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3467
3924
|
);
|
|
3468
3925
|
function isLiteralUnionType(node) {
|
|
3469
|
-
if (node.type !==
|
|
3926
|
+
if (node.type !== AST_NODE_TYPES50.TSUnionType) {
|
|
3470
3927
|
return false;
|
|
3471
3928
|
}
|
|
3472
3929
|
return node.types.every(
|
|
3473
|
-
(member) => member.type ===
|
|
3930
|
+
(member) => member.type === AST_NODE_TYPES50.TSLiteralType || member.type === AST_NODE_TYPES50.TSNullKeyword || member.type === AST_NODE_TYPES50.TSUndefinedKeyword
|
|
3474
3931
|
);
|
|
3475
3932
|
}
|
|
3476
|
-
var preferInlineLiteralUnion =
|
|
3933
|
+
var preferInlineLiteralUnion = createRule50({
|
|
3477
3934
|
name: "prefer-inline-literal-union",
|
|
3478
3935
|
meta: {
|
|
3479
3936
|
type: "suggestion",
|
|
@@ -3500,10 +3957,10 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3500
3957
|
return;
|
|
3501
3958
|
}
|
|
3502
3959
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3503
|
-
if (typeAnnotation.type !==
|
|
3960
|
+
if (typeAnnotation.type !== AST_NODE_TYPES50.TSTypeReference) {
|
|
3504
3961
|
return;
|
|
3505
3962
|
}
|
|
3506
|
-
if (typeAnnotation.typeName.type !==
|
|
3963
|
+
if (typeAnnotation.typeName.type !== AST_NODE_TYPES50.Identifier) {
|
|
3507
3964
|
return;
|
|
3508
3965
|
}
|
|
3509
3966
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3527,12 +3984,12 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3527
3984
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3528
3985
|
|
|
3529
3986
|
// src/rules/prefer-inline-type-export.ts
|
|
3530
|
-
import { AST_NODE_TYPES as
|
|
3531
|
-
var
|
|
3987
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51, ESLintUtils as ESLintUtils51 } from "@typescript-eslint/utils";
|
|
3988
|
+
var createRule51 = ESLintUtils51.RuleCreator(
|
|
3532
3989
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3533
3990
|
);
|
|
3534
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3535
|
-
var preferInlineTypeExport =
|
|
3991
|
+
var isTypeDeclaration = (node) => node.type === AST_NODE_TYPES51.TSInterfaceDeclaration || node.type === AST_NODE_TYPES51.TSTypeAliasDeclaration;
|
|
3992
|
+
var preferInlineTypeExport = createRule51({
|
|
3536
3993
|
name: "prefer-inline-type-export",
|
|
3537
3994
|
meta: {
|
|
3538
3995
|
type: "suggestion",
|
|
@@ -3549,12 +4006,12 @@ var preferInlineTypeExport = createRule47({
|
|
|
3549
4006
|
create(context) {
|
|
3550
4007
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3551
4008
|
function collectDeclaration(node) {
|
|
3552
|
-
if (node.parent.type !==
|
|
4009
|
+
if (node.parent.type !== AST_NODE_TYPES51.ExportNamedDeclaration) {
|
|
3553
4010
|
typeDeclarations.set(node.id.name, node);
|
|
3554
4011
|
}
|
|
3555
4012
|
}
|
|
3556
4013
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3557
|
-
if (specifier.local.type !==
|
|
4014
|
+
if (specifier.local.type !== AST_NODE_TYPES51.Identifier) {
|
|
3558
4015
|
return;
|
|
3559
4016
|
}
|
|
3560
4017
|
const { name } = specifier.local;
|
|
@@ -3587,16 +4044,16 @@ var preferInlineTypeExport = createRule47({
|
|
|
3587
4044
|
return {
|
|
3588
4045
|
Program(node) {
|
|
3589
4046
|
node.body.forEach((statement) => {
|
|
3590
|
-
if (statement.type ===
|
|
4047
|
+
if (statement.type === AST_NODE_TYPES51.TSInterfaceDeclaration || statement.type === AST_NODE_TYPES51.TSTypeAliasDeclaration) {
|
|
3591
4048
|
collectDeclaration(statement);
|
|
3592
4049
|
}
|
|
3593
4050
|
});
|
|
3594
4051
|
node.body.forEach((statement) => {
|
|
3595
|
-
if (statement.type !==
|
|
4052
|
+
if (statement.type !== AST_NODE_TYPES51.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3596
4053
|
return;
|
|
3597
4054
|
}
|
|
3598
4055
|
statement.specifiers.forEach((specifier) => {
|
|
3599
|
-
if (specifier.local.type !==
|
|
4056
|
+
if (specifier.local.type !== AST_NODE_TYPES51.Identifier) {
|
|
3600
4057
|
return;
|
|
3601
4058
|
}
|
|
3602
4059
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3613,11 +4070,11 @@ var preferInlineTypeExport = createRule47({
|
|
|
3613
4070
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3614
4071
|
|
|
3615
4072
|
// src/rules/prefer-interface-for-component-props.ts
|
|
3616
|
-
import { AST_NODE_TYPES as
|
|
3617
|
-
var
|
|
4073
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52, ESLintUtils as ESLintUtils52 } from "@typescript-eslint/utils";
|
|
4074
|
+
var createRule52 = ESLintUtils52.RuleCreator(
|
|
3618
4075
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3619
4076
|
);
|
|
3620
|
-
var preferInterfaceForComponentProps =
|
|
4077
|
+
var preferInterfaceForComponentProps = createRule52({
|
|
3621
4078
|
name: "prefer-interface-for-component-props",
|
|
3622
4079
|
meta: {
|
|
3623
4080
|
type: "suggestion",
|
|
@@ -3637,13 +4094,13 @@ var preferInterfaceForComponentProps = createRule48({
|
|
|
3637
4094
|
}
|
|
3638
4095
|
return {
|
|
3639
4096
|
TSTypeAliasDeclaration(node) {
|
|
3640
|
-
if (node.id.type !==
|
|
4097
|
+
if (node.id.type !== AST_NODE_TYPES52.Identifier) {
|
|
3641
4098
|
return;
|
|
3642
4099
|
}
|
|
3643
4100
|
if (!node.id.name.endsWith("Props")) {
|
|
3644
4101
|
return;
|
|
3645
4102
|
}
|
|
3646
|
-
if (node.typeAnnotation.type !==
|
|
4103
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES52.TSTypeLiteral) {
|
|
3647
4104
|
return;
|
|
3648
4105
|
}
|
|
3649
4106
|
const { name } = node.id;
|
|
@@ -3670,11 +4127,11 @@ var preferInterfaceForComponentProps = createRule48({
|
|
|
3670
4127
|
var prefer_interface_for_component_props_default = preferInterfaceForComponentProps;
|
|
3671
4128
|
|
|
3672
4129
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3673
|
-
import { AST_NODE_TYPES as
|
|
3674
|
-
var
|
|
4130
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES53, ESLintUtils as ESLintUtils53 } from "@typescript-eslint/utils";
|
|
4131
|
+
var createRule53 = ESLintUtils53.RuleCreator(
|
|
3675
4132
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3676
4133
|
);
|
|
3677
|
-
var preferInterfaceOverInlineTypes =
|
|
4134
|
+
var preferInterfaceOverInlineTypes = createRule53({
|
|
3678
4135
|
name: "prefer-interface-over-inline-types",
|
|
3679
4136
|
meta: {
|
|
3680
4137
|
type: "suggestion",
|
|
@@ -3690,54 +4147,54 @@ var preferInterfaceOverInlineTypes = createRule49({
|
|
|
3690
4147
|
defaultOptions: [],
|
|
3691
4148
|
create(context) {
|
|
3692
4149
|
function hasJSXInConditional(node) {
|
|
3693
|
-
return node.consequent.type ===
|
|
4150
|
+
return node.consequent.type === AST_NODE_TYPES53.JSXElement || node.consequent.type === AST_NODE_TYPES53.JSXFragment || node.alternate.type === AST_NODE_TYPES53.JSXElement || node.alternate.type === AST_NODE_TYPES53.JSXFragment;
|
|
3694
4151
|
}
|
|
3695
4152
|
function hasJSXInLogical(node) {
|
|
3696
|
-
return node.right.type ===
|
|
4153
|
+
return node.right.type === AST_NODE_TYPES53.JSXElement || node.right.type === AST_NODE_TYPES53.JSXFragment;
|
|
3697
4154
|
}
|
|
3698
4155
|
function hasJSXReturn(block) {
|
|
3699
4156
|
return block.body.some((stmt) => {
|
|
3700
|
-
if (stmt.type ===
|
|
3701
|
-
return stmt.argument.type ===
|
|
4157
|
+
if (stmt.type === AST_NODE_TYPES53.ReturnStatement && stmt.argument) {
|
|
4158
|
+
return stmt.argument.type === AST_NODE_TYPES53.JSXElement || stmt.argument.type === AST_NODE_TYPES53.JSXFragment || stmt.argument.type === AST_NODE_TYPES53.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === AST_NODE_TYPES53.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
3702
4159
|
}
|
|
3703
4160
|
return false;
|
|
3704
4161
|
});
|
|
3705
4162
|
}
|
|
3706
4163
|
function isReactComponent2(node) {
|
|
3707
|
-
if (node.type ===
|
|
3708
|
-
if (node.body.type ===
|
|
4164
|
+
if (node.type === AST_NODE_TYPES53.ArrowFunctionExpression) {
|
|
4165
|
+
if (node.body.type === AST_NODE_TYPES53.JSXElement || node.body.type === AST_NODE_TYPES53.JSXFragment) {
|
|
3709
4166
|
return true;
|
|
3710
4167
|
}
|
|
3711
|
-
if (node.body.type ===
|
|
4168
|
+
if (node.body.type === AST_NODE_TYPES53.BlockStatement) {
|
|
3712
4169
|
return hasJSXReturn(node.body);
|
|
3713
4170
|
}
|
|
3714
|
-
} else if (node.type ===
|
|
3715
|
-
if (node.body && node.body.type ===
|
|
4171
|
+
} else if (node.type === AST_NODE_TYPES53.FunctionExpression || node.type === AST_NODE_TYPES53.FunctionDeclaration) {
|
|
4172
|
+
if (node.body && node.body.type === AST_NODE_TYPES53.BlockStatement) {
|
|
3716
4173
|
return hasJSXReturn(node.body);
|
|
3717
4174
|
}
|
|
3718
4175
|
}
|
|
3719
4176
|
return false;
|
|
3720
4177
|
}
|
|
3721
4178
|
function isInlineTypeAnnotation(node) {
|
|
3722
|
-
if (node.type ===
|
|
4179
|
+
if (node.type === AST_NODE_TYPES53.TSTypeLiteral) {
|
|
3723
4180
|
return true;
|
|
3724
4181
|
}
|
|
3725
|
-
if (node.type ===
|
|
3726
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
4182
|
+
if (node.type === AST_NODE_TYPES53.TSTypeReference && node.typeArguments) {
|
|
4183
|
+
return node.typeArguments.params.some((param) => param.type === AST_NODE_TYPES53.TSTypeLiteral);
|
|
3727
4184
|
}
|
|
3728
|
-
if (node.type ===
|
|
4185
|
+
if (node.type === AST_NODE_TYPES53.TSUnionType) {
|
|
3729
4186
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3730
4187
|
}
|
|
3731
4188
|
return false;
|
|
3732
4189
|
}
|
|
3733
4190
|
function hasInlineObjectType(node) {
|
|
3734
|
-
if (node.type ===
|
|
4191
|
+
if (node.type === AST_NODE_TYPES53.TSTypeLiteral) {
|
|
3735
4192
|
return true;
|
|
3736
4193
|
}
|
|
3737
|
-
if (node.type ===
|
|
3738
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
4194
|
+
if (node.type === AST_NODE_TYPES53.TSTypeReference && node.typeArguments) {
|
|
4195
|
+
return node.typeArguments.params.some((param) => param.type === AST_NODE_TYPES53.TSTypeLiteral);
|
|
3739
4196
|
}
|
|
3740
|
-
if (node.type ===
|
|
4197
|
+
if (node.type === AST_NODE_TYPES53.TSUnionType) {
|
|
3741
4198
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3742
4199
|
}
|
|
3743
4200
|
return false;
|
|
@@ -3750,7 +4207,7 @@ var preferInterfaceOverInlineTypes = createRule49({
|
|
|
3750
4207
|
return;
|
|
3751
4208
|
}
|
|
3752
4209
|
const param = node.params[0];
|
|
3753
|
-
if (param.type ===
|
|
4210
|
+
if (param.type === AST_NODE_TYPES53.Identifier && param.typeAnnotation) {
|
|
3754
4211
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3755
4212
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3756
4213
|
context.report({
|
|
@@ -3770,11 +4227,11 @@ var preferInterfaceOverInlineTypes = createRule49({
|
|
|
3770
4227
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3771
4228
|
|
|
3772
4229
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3773
|
-
import { AST_NODE_TYPES as
|
|
3774
|
-
var
|
|
4230
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES54, ESLintUtils as ESLintUtils54 } from "@typescript-eslint/utils";
|
|
4231
|
+
var createRule54 = ESLintUtils54.RuleCreator(
|
|
3775
4232
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3776
4233
|
);
|
|
3777
|
-
var preferJSXTemplateLiterals =
|
|
4234
|
+
var preferJSXTemplateLiterals = createRule54({
|
|
3778
4235
|
name: "prefer-jsx-template-literals",
|
|
3779
4236
|
meta: {
|
|
3780
4237
|
type: "suggestion",
|
|
@@ -3843,9 +4300,9 @@ var preferJSXTemplateLiterals = createRule50({
|
|
|
3843
4300
|
if (!child || !nextChild) {
|
|
3844
4301
|
return;
|
|
3845
4302
|
}
|
|
3846
|
-
if (child.type ===
|
|
4303
|
+
if (child.type === AST_NODE_TYPES54.JSXText && nextChild.type === AST_NODE_TYPES54.JSXExpressionContainer) {
|
|
3847
4304
|
handleTextBeforeExpression(child, nextChild);
|
|
3848
|
-
} else if (child.type ===
|
|
4305
|
+
} else if (child.type === AST_NODE_TYPES54.JSXExpressionContainer && nextChild.type === AST_NODE_TYPES54.JSXText) {
|
|
3849
4306
|
handleExpressionBeforeText(child, nextChild);
|
|
3850
4307
|
}
|
|
3851
4308
|
}
|
|
@@ -3858,32 +4315,32 @@ var preferJSXTemplateLiterals = createRule50({
|
|
|
3858
4315
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3859
4316
|
|
|
3860
4317
|
// src/rules/prefer-named-param-types.ts
|
|
3861
|
-
import { AST_NODE_TYPES as
|
|
3862
|
-
var
|
|
4318
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES55, ESLintUtils as ESLintUtils55 } from "@typescript-eslint/utils";
|
|
4319
|
+
var createRule55 = ESLintUtils55.RuleCreator(
|
|
3863
4320
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3864
4321
|
);
|
|
3865
4322
|
var returnsJsx2 = (node) => {
|
|
3866
|
-
if (node.type ===
|
|
4323
|
+
if (node.type === AST_NODE_TYPES55.JSXElement || node.type === AST_NODE_TYPES55.JSXFragment) {
|
|
3867
4324
|
return true;
|
|
3868
4325
|
}
|
|
3869
|
-
if (node.type ===
|
|
4326
|
+
if (node.type === AST_NODE_TYPES55.ConditionalExpression) {
|
|
3870
4327
|
return returnsJsx2(node.consequent) || returnsJsx2(node.alternate);
|
|
3871
4328
|
}
|
|
3872
|
-
if (node.type ===
|
|
4329
|
+
if (node.type === AST_NODE_TYPES55.LogicalExpression) {
|
|
3873
4330
|
return returnsJsx2(node.left) || returnsJsx2(node.right);
|
|
3874
4331
|
}
|
|
3875
4332
|
return false;
|
|
3876
4333
|
};
|
|
3877
4334
|
var bodyReturnsJsx2 = (body) => {
|
|
3878
|
-
if (body.type !==
|
|
4335
|
+
if (body.type !== AST_NODE_TYPES55.BlockStatement) {
|
|
3879
4336
|
return returnsJsx2(body);
|
|
3880
4337
|
}
|
|
3881
4338
|
return body.body.some(
|
|
3882
|
-
(stmt) => stmt.type ===
|
|
4339
|
+
(stmt) => stmt.type === AST_NODE_TYPES55.ReturnStatement && stmt.argument !== null && returnsJsx2(stmt.argument)
|
|
3883
4340
|
);
|
|
3884
4341
|
};
|
|
3885
4342
|
var isReactComponentFunction = (node) => bodyReturnsJsx2(node.body);
|
|
3886
|
-
var preferNamedParamTypes =
|
|
4343
|
+
var preferNamedParamTypes = createRule55({
|
|
3887
4344
|
name: "prefer-named-param-types",
|
|
3888
4345
|
meta: {
|
|
3889
4346
|
type: "suggestion",
|
|
@@ -3898,16 +4355,16 @@ var preferNamedParamTypes = createRule51({
|
|
|
3898
4355
|
defaultOptions: [],
|
|
3899
4356
|
create(context) {
|
|
3900
4357
|
function hasInlineObjectType(param) {
|
|
3901
|
-
if (param.type ===
|
|
4358
|
+
if (param.type === AST_NODE_TYPES55.AssignmentPattern) {
|
|
3902
4359
|
return hasInlineObjectType(param.left);
|
|
3903
4360
|
}
|
|
3904
|
-
if (param.type ===
|
|
3905
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
4361
|
+
if (param.type === AST_NODE_TYPES55.ObjectPattern) {
|
|
4362
|
+
if (param.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES55.TSTypeLiteral) {
|
|
3906
4363
|
return true;
|
|
3907
4364
|
}
|
|
3908
4365
|
}
|
|
3909
|
-
if (param.type ===
|
|
3910
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
4366
|
+
if (param.type === AST_NODE_TYPES55.Identifier) {
|
|
4367
|
+
if (param.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES55.TSTypeLiteral) {
|
|
3911
4368
|
return true;
|
|
3912
4369
|
}
|
|
3913
4370
|
}
|
|
@@ -3920,7 +4377,7 @@ var preferNamedParamTypes = createRule51({
|
|
|
3920
4377
|
} else if ("value" in node && node.value) {
|
|
3921
4378
|
params = node.value.params;
|
|
3922
4379
|
}
|
|
3923
|
-
if ((node.type ===
|
|
4380
|
+
if ((node.type === AST_NODE_TYPES55.FunctionDeclaration || node.type === AST_NODE_TYPES55.FunctionExpression || node.type === AST_NODE_TYPES55.ArrowFunctionExpression) && params.length === 1 && params[0].type === AST_NODE_TYPES55.Identifier && isReactComponentFunction(node)) {
|
|
3924
4381
|
return;
|
|
3925
4382
|
}
|
|
3926
4383
|
params.forEach((param) => {
|
|
@@ -3944,11 +4401,11 @@ var preferNamedParamTypes = createRule51({
|
|
|
3944
4401
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3945
4402
|
|
|
3946
4403
|
// src/rules/prefer-props-with-children.ts
|
|
3947
|
-
import { AST_NODE_TYPES as
|
|
3948
|
-
var
|
|
4404
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES56, ESLintUtils as ESLintUtils56 } from "@typescript-eslint/utils";
|
|
4405
|
+
var createRule56 = ESLintUtils56.RuleCreator(
|
|
3949
4406
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3950
4407
|
);
|
|
3951
|
-
var preferPropsWithChildren =
|
|
4408
|
+
var preferPropsWithChildren = createRule56({
|
|
3952
4409
|
name: "prefer-props-with-children",
|
|
3953
4410
|
meta: {
|
|
3954
4411
|
type: "suggestion",
|
|
@@ -3966,24 +4423,24 @@ var preferPropsWithChildren = createRule52({
|
|
|
3966
4423
|
if (!typeNode) {
|
|
3967
4424
|
return false;
|
|
3968
4425
|
}
|
|
3969
|
-
if (typeNode.type !==
|
|
4426
|
+
if (typeNode.type !== AST_NODE_TYPES56.TSTypeReference) {
|
|
3970
4427
|
return false;
|
|
3971
4428
|
}
|
|
3972
4429
|
const { typeName } = typeNode;
|
|
3973
|
-
if (typeName.type ===
|
|
4430
|
+
if (typeName.type === AST_NODE_TYPES56.Identifier) {
|
|
3974
4431
|
return typeName.name === "ReactNode";
|
|
3975
4432
|
}
|
|
3976
|
-
if (typeName.type ===
|
|
4433
|
+
if (typeName.type === AST_NODE_TYPES56.TSQualifiedName && typeName.left.type === AST_NODE_TYPES56.Identifier && typeName.left.name === "React" && typeName.right.type === AST_NODE_TYPES56.Identifier && typeName.right.name === "ReactNode") {
|
|
3977
4434
|
return true;
|
|
3978
4435
|
}
|
|
3979
4436
|
return false;
|
|
3980
4437
|
}
|
|
3981
4438
|
function findChildrenReactNode(members) {
|
|
3982
4439
|
for (const member of members) {
|
|
3983
|
-
if (member.type !==
|
|
4440
|
+
if (member.type !== AST_NODE_TYPES56.TSPropertySignature) {
|
|
3984
4441
|
continue;
|
|
3985
4442
|
}
|
|
3986
|
-
if (member.key.type !==
|
|
4443
|
+
if (member.key.type !== AST_NODE_TYPES56.Identifier) {
|
|
3987
4444
|
continue;
|
|
3988
4445
|
}
|
|
3989
4446
|
if (member.key.name !== "children") {
|
|
@@ -4023,11 +4480,11 @@ var preferPropsWithChildren = createRule52({
|
|
|
4023
4480
|
var prefer_props_with_children_default = preferPropsWithChildren;
|
|
4024
4481
|
|
|
4025
4482
|
// src/rules/prefer-react-import-types.ts
|
|
4026
|
-
import { AST_NODE_TYPES as
|
|
4027
|
-
var
|
|
4483
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES57, ESLintUtils as ESLintUtils57 } from "@typescript-eslint/utils";
|
|
4484
|
+
var createRule57 = ESLintUtils57.RuleCreator(
|
|
4028
4485
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4029
4486
|
);
|
|
4030
|
-
var preferReactImportTypes =
|
|
4487
|
+
var preferReactImportTypes = createRule57({
|
|
4031
4488
|
name: "prefer-react-import-types",
|
|
4032
4489
|
meta: {
|
|
4033
4490
|
type: "suggestion",
|
|
@@ -4103,7 +4560,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4103
4560
|
]);
|
|
4104
4561
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
4105
4562
|
function checkMemberExpression(node) {
|
|
4106
|
-
if (node.object.type ===
|
|
4563
|
+
if (node.object.type === AST_NODE_TYPES57.Identifier && node.object.name === "React" && node.property.type === AST_NODE_TYPES57.Identifier && allReactExports.has(node.property.name)) {
|
|
4107
4564
|
const typeName = node.property.name;
|
|
4108
4565
|
const isType = reactTypes.has(typeName);
|
|
4109
4566
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4120,7 +4577,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4120
4577
|
return {
|
|
4121
4578
|
MemberExpression: checkMemberExpression,
|
|
4122
4579
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
4123
|
-
if (node.left.type ===
|
|
4580
|
+
if (node.left.type === AST_NODE_TYPES57.Identifier && node.left.name === "React" && node.right.type === AST_NODE_TYPES57.Identifier && allReactExports.has(node.right.name)) {
|
|
4124
4581
|
const typeName = node.right.name;
|
|
4125
4582
|
const isType = reactTypes.has(typeName);
|
|
4126
4583
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4140,11 +4597,11 @@ var preferReactImportTypes = createRule53({
|
|
|
4140
4597
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
4141
4598
|
|
|
4142
4599
|
// src/rules/react-props-destructure.ts
|
|
4143
|
-
import { AST_NODE_TYPES as
|
|
4144
|
-
var
|
|
4600
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES58, ESLintUtils as ESLintUtils58 } from "@typescript-eslint/utils";
|
|
4601
|
+
var createRule58 = ESLintUtils58.RuleCreator(
|
|
4145
4602
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4146
4603
|
);
|
|
4147
|
-
var reactPropsDestructure =
|
|
4604
|
+
var reactPropsDestructure = createRule58({
|
|
4148
4605
|
name: "react-props-destructure",
|
|
4149
4606
|
meta: {
|
|
4150
4607
|
type: "suggestion",
|
|
@@ -4160,29 +4617,29 @@ var reactPropsDestructure = createRule54({
|
|
|
4160
4617
|
defaultOptions: [],
|
|
4161
4618
|
create(context) {
|
|
4162
4619
|
function hasJSXInConditional(node) {
|
|
4163
|
-
return node.consequent.type ===
|
|
4620
|
+
return node.consequent.type === AST_NODE_TYPES58.JSXElement || node.consequent.type === AST_NODE_TYPES58.JSXFragment || node.alternate.type === AST_NODE_TYPES58.JSXElement || node.alternate.type === AST_NODE_TYPES58.JSXFragment;
|
|
4164
4621
|
}
|
|
4165
4622
|
function hasJSXInLogical(node) {
|
|
4166
|
-
return node.right.type ===
|
|
4623
|
+
return node.right.type === AST_NODE_TYPES58.JSXElement || node.right.type === AST_NODE_TYPES58.JSXFragment;
|
|
4167
4624
|
}
|
|
4168
4625
|
function hasJSXReturn(block) {
|
|
4169
4626
|
return block.body.some((stmt) => {
|
|
4170
|
-
if (stmt.type ===
|
|
4171
|
-
return stmt.argument.type ===
|
|
4627
|
+
if (stmt.type === AST_NODE_TYPES58.ReturnStatement && stmt.argument) {
|
|
4628
|
+
return stmt.argument.type === AST_NODE_TYPES58.JSXElement || stmt.argument.type === AST_NODE_TYPES58.JSXFragment || stmt.argument.type === AST_NODE_TYPES58.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === AST_NODE_TYPES58.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
4172
4629
|
}
|
|
4173
4630
|
return false;
|
|
4174
4631
|
});
|
|
4175
4632
|
}
|
|
4176
4633
|
function isReactComponent2(node) {
|
|
4177
|
-
if (node.type ===
|
|
4178
|
-
if (node.body.type ===
|
|
4634
|
+
if (node.type === AST_NODE_TYPES58.ArrowFunctionExpression) {
|
|
4635
|
+
if (node.body.type === AST_NODE_TYPES58.JSXElement || node.body.type === AST_NODE_TYPES58.JSXFragment) {
|
|
4179
4636
|
return true;
|
|
4180
4637
|
}
|
|
4181
|
-
if (node.body.type ===
|
|
4638
|
+
if (node.body.type === AST_NODE_TYPES58.BlockStatement) {
|
|
4182
4639
|
return hasJSXReturn(node.body);
|
|
4183
4640
|
}
|
|
4184
|
-
} else if (node.type ===
|
|
4185
|
-
if (node.body && node.body.type ===
|
|
4641
|
+
} else if (node.type === AST_NODE_TYPES58.FunctionExpression || node.type === AST_NODE_TYPES58.FunctionDeclaration) {
|
|
4642
|
+
if (node.body && node.body.type === AST_NODE_TYPES58.BlockStatement) {
|
|
4186
4643
|
return hasJSXReturn(node.body);
|
|
4187
4644
|
}
|
|
4188
4645
|
}
|
|
@@ -4196,9 +4653,9 @@ var reactPropsDestructure = createRule54({
|
|
|
4196
4653
|
return;
|
|
4197
4654
|
}
|
|
4198
4655
|
const param = node.params[0];
|
|
4199
|
-
if (param.type ===
|
|
4200
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4201
|
-
if (prop.key.type ===
|
|
4656
|
+
if (param.type === AST_NODE_TYPES58.ObjectPattern) {
|
|
4657
|
+
const properties = param.properties.filter((prop) => prop.type === AST_NODE_TYPES58.Property).map((prop) => {
|
|
4658
|
+
if (prop.key.type === AST_NODE_TYPES58.Identifier) {
|
|
4202
4659
|
return prop.key.name;
|
|
4203
4660
|
}
|
|
4204
4661
|
return null;
|
|
@@ -4225,57 +4682,57 @@ var reactPropsDestructure = createRule54({
|
|
|
4225
4682
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4226
4683
|
|
|
4227
4684
|
// src/rules/require-explicit-return-type.ts
|
|
4228
|
-
import { AST_NODE_TYPES as
|
|
4229
|
-
var
|
|
4685
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES59, ESLintUtils as ESLintUtils59 } from "@typescript-eslint/utils";
|
|
4686
|
+
var createRule59 = ESLintUtils59.RuleCreator(
|
|
4230
4687
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4231
4688
|
);
|
|
4232
4689
|
var isReactComponent = (node) => {
|
|
4233
|
-
if (node.type ===
|
|
4690
|
+
if (node.type === AST_NODE_TYPES59.ArrowFunctionExpression) {
|
|
4234
4691
|
const { parent } = node;
|
|
4235
|
-
if (parent?.type ===
|
|
4692
|
+
if (parent?.type === AST_NODE_TYPES59.VariableDeclarator) {
|
|
4236
4693
|
const { id } = parent;
|
|
4237
|
-
if (id.type ===
|
|
4694
|
+
if (id.type === AST_NODE_TYPES59.Identifier) {
|
|
4238
4695
|
return /^[A-Z]/.test(id.name);
|
|
4239
4696
|
}
|
|
4240
4697
|
}
|
|
4241
4698
|
}
|
|
4242
|
-
if (node.type ===
|
|
4699
|
+
if (node.type === AST_NODE_TYPES59.FunctionDeclaration && node.id) {
|
|
4243
4700
|
return /^[A-Z]/.test(node.id.name);
|
|
4244
4701
|
}
|
|
4245
4702
|
return false;
|
|
4246
4703
|
};
|
|
4247
4704
|
var isCallbackFunction = (node) => {
|
|
4248
|
-
if (node.type ===
|
|
4705
|
+
if (node.type === AST_NODE_TYPES59.FunctionDeclaration) {
|
|
4249
4706
|
return false;
|
|
4250
4707
|
}
|
|
4251
4708
|
const { parent } = node;
|
|
4252
4709
|
if (!parent) {
|
|
4253
4710
|
return false;
|
|
4254
4711
|
}
|
|
4255
|
-
if (parent.type ===
|
|
4712
|
+
if (parent.type === AST_NODE_TYPES59.CallExpression && parent.arguments.includes(node)) {
|
|
4256
4713
|
return true;
|
|
4257
4714
|
}
|
|
4258
|
-
if (parent.type ===
|
|
4715
|
+
if (parent.type === AST_NODE_TYPES59.Property) {
|
|
4259
4716
|
return true;
|
|
4260
4717
|
}
|
|
4261
|
-
if (parent.type ===
|
|
4718
|
+
if (parent.type === AST_NODE_TYPES59.ArrayExpression) {
|
|
4262
4719
|
return true;
|
|
4263
4720
|
}
|
|
4264
4721
|
return false;
|
|
4265
4722
|
};
|
|
4266
4723
|
var getFunctionName = (node) => {
|
|
4267
|
-
if (node.type ===
|
|
4724
|
+
if (node.type === AST_NODE_TYPES59.FunctionDeclaration && node.id) {
|
|
4268
4725
|
return node.id.name;
|
|
4269
4726
|
}
|
|
4270
|
-
if (node.type ===
|
|
4727
|
+
if (node.type === AST_NODE_TYPES59.FunctionExpression && node.id) {
|
|
4271
4728
|
return node.id.name;
|
|
4272
4729
|
}
|
|
4273
|
-
if ((node.type ===
|
|
4730
|
+
if ((node.type === AST_NODE_TYPES59.ArrowFunctionExpression || node.type === AST_NODE_TYPES59.FunctionExpression) && node.parent?.type === AST_NODE_TYPES59.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES59.Identifier) {
|
|
4274
4731
|
return node.parent.id.name;
|
|
4275
4732
|
}
|
|
4276
4733
|
return null;
|
|
4277
4734
|
};
|
|
4278
|
-
var requireExplicitReturnType =
|
|
4735
|
+
var requireExplicitReturnType = createRule59({
|
|
4279
4736
|
name: "require-explicit-return-type",
|
|
4280
4737
|
meta: {
|
|
4281
4738
|
type: "suggestion",
|
|
@@ -4324,8 +4781,8 @@ var requireExplicitReturnType = createRule55({
|
|
|
4324
4781
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4325
4782
|
|
|
4326
4783
|
// src/rules/sort-exports.ts
|
|
4327
|
-
import { AST_NODE_TYPES as
|
|
4328
|
-
var
|
|
4784
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES60, ESLintUtils as ESLintUtils60 } from "@typescript-eslint/utils";
|
|
4785
|
+
var createRule60 = ESLintUtils60.RuleCreator(
|
|
4329
4786
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4330
4787
|
);
|
|
4331
4788
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4339,7 +4796,7 @@ function getExportGroup(node) {
|
|
|
4339
4796
|
}
|
|
4340
4797
|
return 1;
|
|
4341
4798
|
}
|
|
4342
|
-
var sortExports =
|
|
4799
|
+
var sortExports = createRule60({
|
|
4343
4800
|
name: "sort-exports",
|
|
4344
4801
|
meta: {
|
|
4345
4802
|
type: "suggestion",
|
|
@@ -4379,7 +4836,7 @@ var sortExports = createRule56({
|
|
|
4379
4836
|
Program(node) {
|
|
4380
4837
|
const exportGroups = [];
|
|
4381
4838
|
node.body.forEach((statement) => {
|
|
4382
|
-
if (statement.type !==
|
|
4839
|
+
if (statement.type !== AST_NODE_TYPES60.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4383
4840
|
if (exportGroups.length > 0) {
|
|
4384
4841
|
checkOrder(exportGroups);
|
|
4385
4842
|
exportGroups.length = 0;
|
|
@@ -4398,8 +4855,8 @@ var sortExports = createRule56({
|
|
|
4398
4855
|
var sort_exports_default = sortExports;
|
|
4399
4856
|
|
|
4400
4857
|
// src/rules/sort-imports.ts
|
|
4401
|
-
import { AST_NODE_TYPES as
|
|
4402
|
-
var
|
|
4858
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES61, ESLintUtils as ESLintUtils61 } from "@typescript-eslint/utils";
|
|
4859
|
+
var createRule61 = ESLintUtils61.RuleCreator(
|
|
4403
4860
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4404
4861
|
);
|
|
4405
4862
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4466,7 +4923,7 @@ function getImportGroup(node) {
|
|
|
4466
4923
|
function isTypeOnlyImport(node) {
|
|
4467
4924
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4468
4925
|
}
|
|
4469
|
-
var sortImports =
|
|
4926
|
+
var sortImports = createRule61({
|
|
4470
4927
|
name: "sort-imports",
|
|
4471
4928
|
meta: {
|
|
4472
4929
|
type: "suggestion",
|
|
@@ -4510,7 +4967,7 @@ var sortImports = createRule57({
|
|
|
4510
4967
|
Program(node) {
|
|
4511
4968
|
const importGroups = [];
|
|
4512
4969
|
node.body.forEach((statement) => {
|
|
4513
|
-
if (statement.type !==
|
|
4970
|
+
if (statement.type !== AST_NODE_TYPES61.ImportDeclaration) {
|
|
4514
4971
|
if (importGroups.length > 0) {
|
|
4515
4972
|
checkOrder(importGroups);
|
|
4516
4973
|
importGroups.length = 0;
|
|
@@ -4532,13 +4989,13 @@ var sortImports = createRule57({
|
|
|
4532
4989
|
var sort_imports_default = sortImports;
|
|
4533
4990
|
|
|
4534
4991
|
// src/rules/sort-type-alphabetically.ts
|
|
4535
|
-
import { AST_NODE_TYPES as
|
|
4536
|
-
var
|
|
4992
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES62, ESLintUtils as ESLintUtils62 } from "@typescript-eslint/utils";
|
|
4993
|
+
var createRule62 = ESLintUtils62.RuleCreator(
|
|
4537
4994
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4538
4995
|
);
|
|
4539
4996
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4540
4997
|
const properties = members.filter(
|
|
4541
|
-
(member) => member.type ===
|
|
4998
|
+
(member) => member.type === AST_NODE_TYPES62.TSPropertySignature && member.key.type === AST_NODE_TYPES62.Identifier
|
|
4542
4999
|
);
|
|
4543
5000
|
if (properties.length < 2) {
|
|
4544
5001
|
return true;
|
|
@@ -4549,7 +5006,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4549
5006
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4550
5007
|
return isRequiredSorted && isOptionalSorted;
|
|
4551
5008
|
}
|
|
4552
|
-
var sortTypeAlphabetically =
|
|
5009
|
+
var sortTypeAlphabetically = createRule62({
|
|
4553
5010
|
name: "sort-type-alphabetically",
|
|
4554
5011
|
meta: {
|
|
4555
5012
|
type: "suggestion",
|
|
@@ -4567,7 +5024,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4567
5024
|
function fixMembers(fixer, members) {
|
|
4568
5025
|
const { sourceCode } = context;
|
|
4569
5026
|
const properties = members.filter(
|
|
4570
|
-
(member) => member.type ===
|
|
5027
|
+
(member) => member.type === AST_NODE_TYPES62.TSPropertySignature && member.key.type === AST_NODE_TYPES62.Identifier
|
|
4571
5028
|
);
|
|
4572
5029
|
const required = properties.filter((prop) => !prop.optional);
|
|
4573
5030
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4604,7 +5061,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4604
5061
|
}
|
|
4605
5062
|
},
|
|
4606
5063
|
TSTypeAliasDeclaration(node) {
|
|
4607
|
-
if (node.typeAnnotation.type !==
|
|
5064
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES62.TSTypeLiteral) {
|
|
4608
5065
|
return;
|
|
4609
5066
|
}
|
|
4610
5067
|
const { members } = node.typeAnnotation;
|
|
@@ -4624,13 +5081,13 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4624
5081
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4625
5082
|
|
|
4626
5083
|
// src/rules/sort-type-required-first.ts
|
|
4627
|
-
import { AST_NODE_TYPES as
|
|
4628
|
-
var
|
|
5084
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES63, ESLintUtils as ESLintUtils63 } from "@typescript-eslint/utils";
|
|
5085
|
+
var createRule63 = ESLintUtils63.RuleCreator(
|
|
4629
5086
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4630
5087
|
);
|
|
4631
5088
|
function isRequiredBeforeOptional(members) {
|
|
4632
5089
|
const properties = members.filter(
|
|
4633
|
-
(member) => member.type ===
|
|
5090
|
+
(member) => member.type === AST_NODE_TYPES63.TSPropertySignature && member.key.type === AST_NODE_TYPES63.Identifier
|
|
4634
5091
|
);
|
|
4635
5092
|
if (properties.length < 2) {
|
|
4636
5093
|
return true;
|
|
@@ -4641,7 +5098,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4641
5098
|
}
|
|
4642
5099
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4643
5100
|
}
|
|
4644
|
-
var sortTypeRequiredFirst =
|
|
5101
|
+
var sortTypeRequiredFirst = createRule63({
|
|
4645
5102
|
name: "sort-type-required-first",
|
|
4646
5103
|
meta: {
|
|
4647
5104
|
type: "suggestion",
|
|
@@ -4659,7 +5116,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4659
5116
|
function fixMembers(fixer, members) {
|
|
4660
5117
|
const { sourceCode } = context;
|
|
4661
5118
|
const properties = members.filter(
|
|
4662
|
-
(member) => member.type ===
|
|
5119
|
+
(member) => member.type === AST_NODE_TYPES63.TSPropertySignature && member.key.type === AST_NODE_TYPES63.Identifier
|
|
4663
5120
|
);
|
|
4664
5121
|
const required = properties.filter((prop) => !prop.optional);
|
|
4665
5122
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4680,7 +5137,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4680
5137
|
}
|
|
4681
5138
|
},
|
|
4682
5139
|
TSTypeAliasDeclaration(node) {
|
|
4683
|
-
if (node.typeAnnotation.type !==
|
|
5140
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES63.TSTypeLiteral) {
|
|
4684
5141
|
return;
|
|
4685
5142
|
}
|
|
4686
5143
|
const { members } = node.typeAnnotation;
|
|
@@ -4712,14 +5169,18 @@ var rules = {
|
|
|
4712
5169
|
"enforce-property-case": enforce_property_case_default,
|
|
4713
5170
|
"enforce-props-suffix": enforce_props_suffix_default,
|
|
4714
5171
|
"enforce-readonly-component-props": enforce_readonly_component_props_default,
|
|
5172
|
+
"enforce-render-naming": enforce_render_naming_default,
|
|
4715
5173
|
"enforce-service-naming": enforce_service_naming_default,
|
|
4716
5174
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4717
5175
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4718
5176
|
"index-export-only": index_export_only_default,
|
|
4719
5177
|
"jsx-newline-between-elements": jsx_newline_between_elements_default,
|
|
5178
|
+
"jsx-no-data-array": jsx_no_data_array_default,
|
|
5179
|
+
"jsx-no-data-object": jsx_no_data_object_default,
|
|
4720
5180
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
4721
5181
|
"jsx-no-newline-single-line-elements": jsx_no_newline_single_line_elements_default,
|
|
4722
5182
|
"jsx-no-non-component-function": jsx_no_non_component_function_default,
|
|
5183
|
+
"jsx-no-sub-interface": jsx_no_sub_interface_default,
|
|
4723
5184
|
"jsx-no-ternary-null": jsx_no_ternary_null_default,
|
|
4724
5185
|
"jsx-no-variable-in-callback": jsx_no_variable_in_callback_default,
|
|
4725
5186
|
"jsx-require-suspense": jsx_require_suspense_default,
|
|
@@ -4856,10 +5317,14 @@ var baseRecommendedRules = {
|
|
|
4856
5317
|
var jsxRules = {
|
|
4857
5318
|
"nextfriday/enforce-props-suffix": "warn",
|
|
4858
5319
|
"nextfriday/enforce-readonly-component-props": "warn",
|
|
5320
|
+
"nextfriday/enforce-render-naming": "warn",
|
|
4859
5321
|
"nextfriday/jsx-newline-between-elements": "warn",
|
|
5322
|
+
"nextfriday/jsx-no-data-array": "warn",
|
|
5323
|
+
"nextfriday/jsx-no-data-object": "warn",
|
|
4860
5324
|
"nextfriday/jsx-no-inline-object-prop": "warn",
|
|
4861
5325
|
"nextfriday/jsx-no-newline-single-line-elements": "warn",
|
|
4862
5326
|
"nextfriday/jsx-no-non-component-function": "warn",
|
|
5327
|
+
"nextfriday/jsx-no-sub-interface": "warn",
|
|
4863
5328
|
"nextfriday/jsx-no-ternary-null": "warn",
|
|
4864
5329
|
"nextfriday/jsx-no-variable-in-callback": "warn",
|
|
4865
5330
|
"nextfriday/jsx-require-suspense": "warn",
|
|
@@ -4877,10 +5342,14 @@ var jsxRules = {
|
|
|
4877
5342
|
var jsxRecommendedRules = {
|
|
4878
5343
|
"nextfriday/enforce-props-suffix": "error",
|
|
4879
5344
|
"nextfriday/enforce-readonly-component-props": "error",
|
|
5345
|
+
"nextfriday/enforce-render-naming": "error",
|
|
4880
5346
|
"nextfriday/jsx-newline-between-elements": "error",
|
|
5347
|
+
"nextfriday/jsx-no-data-array": "error",
|
|
5348
|
+
"nextfriday/jsx-no-data-object": "error",
|
|
4881
5349
|
"nextfriday/jsx-no-inline-object-prop": "error",
|
|
4882
5350
|
"nextfriday/jsx-no-newline-single-line-elements": "error",
|
|
4883
5351
|
"nextfriday/jsx-no-non-component-function": "error",
|
|
5352
|
+
"nextfriday/jsx-no-sub-interface": "error",
|
|
4884
5353
|
"nextfriday/jsx-no-ternary-null": "error",
|
|
4885
5354
|
"nextfriday/jsx-no-variable-in-callback": "error",
|
|
4886
5355
|
"nextfriday/jsx-require-suspense": "error",
|