eslint-plugin-nextfriday 4.3.2 → 4.4.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 +10 -0
- package/README.md +7 -9
- package/docs/rules/PREFER_PROPS_WITH_CHILDREN.md +17 -35
- package/lib/index.cjs +56 -117
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -42
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.ts +0 -42
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +56 -117
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/docs/rules/PREFER_INLINE_TYPE_EXPORT.md +0 -64
package/lib/index.cjs
CHANGED
|
@@ -32,10 +32,10 @@ let emoji_regex = require("emoji-regex");
|
|
|
32
32
|
emoji_regex = __toESM(emoji_regex, 1);
|
|
33
33
|
//#region package.json
|
|
34
34
|
var name = "eslint-plugin-nextfriday";
|
|
35
|
-
var version = "4.
|
|
35
|
+
var version = "4.4.0";
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/rules/boolean-naming-prefix.ts
|
|
38
|
-
const createRule$
|
|
38
|
+
const createRule$31 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
39
39
|
const BOOLEAN_PREFIXES = [
|
|
40
40
|
"is",
|
|
41
41
|
"has",
|
|
@@ -84,7 +84,7 @@ const hasBooleanTypeAnnotation = (node) => {
|
|
|
84
84
|
}
|
|
85
85
|
return false;
|
|
86
86
|
};
|
|
87
|
-
const booleanNamingPrefix = createRule$
|
|
87
|
+
const booleanNamingPrefix = createRule$31({
|
|
88
88
|
name: "boolean-naming-prefix",
|
|
89
89
|
meta: {
|
|
90
90
|
type: "suggestion",
|
|
@@ -145,7 +145,7 @@ const booleanNamingPrefix = createRule$32({
|
|
|
145
145
|
});
|
|
146
146
|
//#endregion
|
|
147
147
|
//#region src/rules/enforce-camel-case.ts
|
|
148
|
-
const createRule$
|
|
148
|
+
const createRule$30 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
149
149
|
const SNAKE_CASE_REGEX$2 = /^[a-z]+_[a-z0-9_]*$/;
|
|
150
150
|
const PASCAL_CASE_REGEX = /^[A-Z][a-zA-Z0-9]*$/;
|
|
151
151
|
const REACT_WRAPPERS = [
|
|
@@ -189,7 +189,7 @@ const isStaticValue$1 = (init) => {
|
|
|
189
189
|
if (init.type === _typescript_eslint_utils.AST_NODE_TYPES.TSAsExpression && init.typeAnnotation.type === _typescript_eslint_utils.AST_NODE_TYPES.TSTypeReference && init.typeAnnotation.typeName.type === _typescript_eslint_utils.AST_NODE_TYPES.Identifier && init.typeAnnotation.typeName.name === "const") return true;
|
|
190
190
|
return false;
|
|
191
191
|
};
|
|
192
|
-
const enforceCamelCase = createRule$
|
|
192
|
+
const enforceCamelCase = createRule$30({
|
|
193
193
|
name: "enforce-camel-case",
|
|
194
194
|
meta: {
|
|
195
195
|
type: "suggestion",
|
|
@@ -250,7 +250,7 @@ const isConfigFile = (filename) => {
|
|
|
250
250
|
};
|
|
251
251
|
//#endregion
|
|
252
252
|
//#region src/rules/enforce-constant-case.ts
|
|
253
|
-
const createRule$
|
|
253
|
+
const createRule$29 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
254
254
|
const SCREAMING_SNAKE_CASE_REGEX$2 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
255
255
|
const SNAKE_CASE_REGEX$1 = /^[a-z]+_[a-z0-9_]*$/;
|
|
256
256
|
const toScreamingSnakeCase = (str) => str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toUpperCase();
|
|
@@ -268,7 +268,7 @@ const isGlobalScope$1 = (node) => {
|
|
|
268
268
|
if (parent.type === _typescript_eslint_utils.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === _typescript_eslint_utils.AST_NODE_TYPES.Program) return true;
|
|
269
269
|
return false;
|
|
270
270
|
};
|
|
271
|
-
const enforceConstantCase = createRule$
|
|
271
|
+
const enforceConstantCase = createRule$29({
|
|
272
272
|
name: "enforce-constant-case",
|
|
273
273
|
meta: {
|
|
274
274
|
type: "suggestion",
|
|
@@ -392,7 +392,7 @@ const enforceHookNaming = _typescript_eslint_utils.ESLintUtils.RuleCreator((name
|
|
|
392
392
|
});
|
|
393
393
|
//#endregion
|
|
394
394
|
//#region src/rules/enforce-property-case.ts
|
|
395
|
-
const createRule$
|
|
395
|
+
const createRule$28 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
396
396
|
const SNAKE_CASE_REGEX = /^[a-z]+_[a-z0-9_]*$/;
|
|
397
397
|
const SCREAMING_SNAKE_CASE_REGEX$1 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
398
398
|
const isInsideAsConst = (node) => {
|
|
@@ -404,7 +404,7 @@ const isInsideAsConst = (node) => {
|
|
|
404
404
|
}
|
|
405
405
|
return false;
|
|
406
406
|
};
|
|
407
|
-
const enforcePropertyCase = createRule$
|
|
407
|
+
const enforcePropertyCase = createRule$28({
|
|
408
408
|
name: "enforce-property-case",
|
|
409
409
|
meta: {
|
|
410
410
|
type: "suggestion",
|
|
@@ -537,7 +537,7 @@ const enforceReadonlyComponentProps = _typescript_eslint_utils.ESLintUtils.RuleC
|
|
|
537
537
|
});
|
|
538
538
|
//#endregion
|
|
539
539
|
//#region src/rules/enforce-render-naming.ts
|
|
540
|
-
const createRule$
|
|
540
|
+
const createRule$27 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
541
541
|
const ARRAY_RETURNING_METHODS = new Set([
|
|
542
542
|
"map",
|
|
543
543
|
"flatMap",
|
|
@@ -586,7 +586,7 @@ function isComponentFunction(node) {
|
|
|
586
586
|
if (parent?.type === _typescript_eslint_utils.AST_NODE_TYPES.VariableDeclarator && parent.id.type === _typescript_eslint_utils.AST_NODE_TYPES.Identifier && isPascalCase$1(parent.id.name)) return true;
|
|
587
587
|
return false;
|
|
588
588
|
}
|
|
589
|
-
const enforceRenderNaming = createRule$
|
|
589
|
+
const enforceRenderNaming = createRule$27({
|
|
590
590
|
name: "enforce-render-naming",
|
|
591
591
|
meta: {
|
|
592
592
|
type: "problem",
|
|
@@ -638,7 +638,7 @@ const enforceRenderNaming = createRule$28({
|
|
|
638
638
|
});
|
|
639
639
|
//#endregion
|
|
640
640
|
//#region src/rules/enforce-service-naming.ts
|
|
641
|
-
const createRule$
|
|
641
|
+
const createRule$26 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
642
642
|
const BANNED_PREFIXES = {
|
|
643
643
|
delete: ["remove", "archive"],
|
|
644
644
|
do: ["submit", "process"],
|
|
@@ -649,7 +649,7 @@ const BANNED_PREFIXES = {
|
|
|
649
649
|
"patch"
|
|
650
650
|
]
|
|
651
651
|
};
|
|
652
|
-
const enforceServiceNaming = createRule$
|
|
652
|
+
const enforceServiceNaming = createRule$26({
|
|
653
653
|
name: "enforce-service-naming",
|
|
654
654
|
meta: {
|
|
655
655
|
type: "suggestion",
|
|
@@ -687,7 +687,7 @@ const enforceServiceNaming = createRule$27({
|
|
|
687
687
|
});
|
|
688
688
|
//#endregion
|
|
689
689
|
//#region src/rules/enforce-test-filename.ts
|
|
690
|
-
const createRule$
|
|
690
|
+
const createRule$25 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
691
691
|
const TEST_GLOBALS = new Set([
|
|
692
692
|
"describe",
|
|
693
693
|
"it",
|
|
@@ -697,7 +697,7 @@ const TEST_GLOBALS = new Set([
|
|
|
697
697
|
"afterEach",
|
|
698
698
|
"afterAll"
|
|
699
699
|
]);
|
|
700
|
-
const enforceTestFilename = createRule$
|
|
700
|
+
const enforceTestFilename = createRule$25({
|
|
701
701
|
name: "enforce-test-filename",
|
|
702
702
|
meta: {
|
|
703
703
|
type: "suggestion",
|
|
@@ -777,7 +777,7 @@ const enforceSortedDestructuring = _typescript_eslint_utils.ESLintUtils.RuleCrea
|
|
|
777
777
|
});
|
|
778
778
|
//#endregion
|
|
779
779
|
//#region src/rules/enforce-type-declaration-order.ts
|
|
780
|
-
const createRule$
|
|
780
|
+
const createRule$24 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
781
781
|
function getTypeDeclarationName(node) {
|
|
782
782
|
if (node.type === _typescript_eslint_utils.AST_NODE_TYPES.TSInterfaceDeclaration && node.id.type === _typescript_eslint_utils.AST_NODE_TYPES.Identifier) return {
|
|
783
783
|
name: node.id.name,
|
|
@@ -789,7 +789,7 @@ function getTypeDeclarationName(node) {
|
|
|
789
789
|
};
|
|
790
790
|
return null;
|
|
791
791
|
}
|
|
792
|
-
const enforceTypeDeclarationOrder = createRule$
|
|
792
|
+
const enforceTypeDeclarationOrder = createRule$24({
|
|
793
793
|
name: "enforce-type-declaration-order",
|
|
794
794
|
meta: {
|
|
795
795
|
type: "suggestion",
|
|
@@ -844,7 +844,7 @@ const enforceTypeDeclarationOrder = createRule$25({
|
|
|
844
844
|
});
|
|
845
845
|
//#endregion
|
|
846
846
|
//#region src/rules/index-export-only.ts
|
|
847
|
-
const createRule$
|
|
847
|
+
const createRule$23 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
848
848
|
const isIndexFile = (filename) => getBaseName(filename) === "index";
|
|
849
849
|
const isAllowedExportNamed = (node) => {
|
|
850
850
|
if (!node.declaration) return true;
|
|
@@ -863,7 +863,7 @@ const isAllowedTopLevel = (node) => {
|
|
|
863
863
|
default: return false;
|
|
864
864
|
}
|
|
865
865
|
};
|
|
866
|
-
const indexExportOnly = createRule$
|
|
866
|
+
const indexExportOnly = createRule$23({
|
|
867
867
|
name: "index-export-only",
|
|
868
868
|
meta: {
|
|
869
869
|
type: "suggestion",
|
|
@@ -937,7 +937,7 @@ const jsxNewlineBetweenElements = _typescript_eslint_utils.ESLintUtils.RuleCreat
|
|
|
937
937
|
});
|
|
938
938
|
//#endregion
|
|
939
939
|
//#region src/rules/jsx-no-data-array.ts
|
|
940
|
-
const createRule$
|
|
940
|
+
const createRule$22 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
941
941
|
function isObjectLikeElement(node) {
|
|
942
942
|
if (!node) return false;
|
|
943
943
|
if (node.type === _typescript_eslint_utils.AST_NODE_TYPES.ObjectExpression) return true;
|
|
@@ -950,7 +950,7 @@ function getArrayInitializer(init) {
|
|
|
950
950
|
if (init.type === _typescript_eslint_utils.AST_NODE_TYPES.TSAsExpression || init.type === _typescript_eslint_utils.AST_NODE_TYPES.TSSatisfiesExpression) return getArrayInitializer(init.expression);
|
|
951
951
|
return null;
|
|
952
952
|
}
|
|
953
|
-
const jsxNoDataArray = createRule$
|
|
953
|
+
const jsxNoDataArray = createRule$22({
|
|
954
954
|
name: "jsx-no-data-array",
|
|
955
955
|
meta: {
|
|
956
956
|
type: "problem",
|
|
@@ -991,7 +991,7 @@ const jsxNoDataArray = createRule$23({
|
|
|
991
991
|
});
|
|
992
992
|
//#endregion
|
|
993
993
|
//#region src/rules/jsx-no-data-object.ts
|
|
994
|
-
const createRule$
|
|
994
|
+
const createRule$21 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
995
995
|
function unwrapAssertion(node) {
|
|
996
996
|
if (!node) return null;
|
|
997
997
|
if (node.type === _typescript_eslint_utils.AST_NODE_TYPES.TSAsExpression || node.type === _typescript_eslint_utils.AST_NODE_TYPES.TSSatisfiesExpression) return unwrapAssertion(node.expression);
|
|
@@ -1021,7 +1021,7 @@ function getObjectInitializer(init) {
|
|
|
1021
1021
|
if (unwrapped.type === _typescript_eslint_utils.AST_NODE_TYPES.ObjectExpression) return unwrapped;
|
|
1022
1022
|
return null;
|
|
1023
1023
|
}
|
|
1024
|
-
const jsxNoDataObject = createRule$
|
|
1024
|
+
const jsxNoDataObject = createRule$21({
|
|
1025
1025
|
name: "jsx-no-data-object",
|
|
1026
1026
|
meta: {
|
|
1027
1027
|
type: "problem",
|
|
@@ -1074,14 +1074,14 @@ const jsxNoInlineObjectProp = _typescript_eslint_utils.ESLintUtils.RuleCreator((
|
|
|
1074
1074
|
});
|
|
1075
1075
|
//#endregion
|
|
1076
1076
|
//#region src/rules/jsx-no-newline-single-line-elements.ts
|
|
1077
|
-
const createRule$
|
|
1077
|
+
const createRule$20 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
1078
1078
|
function isJSXElementOrFragment(node) {
|
|
1079
1079
|
return node.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXElement || node.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXFragment;
|
|
1080
1080
|
}
|
|
1081
1081
|
function isSingleLine(node) {
|
|
1082
1082
|
return node.loc.start.line === node.loc.end.line;
|
|
1083
1083
|
}
|
|
1084
|
-
const jsxNoNewlineSingleLineElements = createRule$
|
|
1084
|
+
const jsxNoNewlineSingleLineElements = createRule$20({
|
|
1085
1085
|
name: "jsx-no-newline-single-line-elements",
|
|
1086
1086
|
meta: {
|
|
1087
1087
|
type: "layout",
|
|
@@ -1180,7 +1180,7 @@ const jsxNoNonComponentFunction = _typescript_eslint_utils.ESLintUtils.RuleCreat
|
|
|
1180
1180
|
});
|
|
1181
1181
|
//#endregion
|
|
1182
1182
|
//#region src/rules/jsx-no-sub-interface.ts
|
|
1183
|
-
const createRule$
|
|
1183
|
+
const createRule$19 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
1184
1184
|
const PROPS_WRAPPER_NAMES = new Set([
|
|
1185
1185
|
"Readonly",
|
|
1186
1186
|
"Required",
|
|
@@ -1212,7 +1212,7 @@ function getDeclarationFromExportWrapper(node) {
|
|
|
1212
1212
|
if (node.type === _typescript_eslint_utils.AST_NODE_TYPES.ExportDefaultDeclaration) return node.declaration;
|
|
1213
1213
|
return node;
|
|
1214
1214
|
}
|
|
1215
|
-
const jsxNoSubInterface = createRule$
|
|
1215
|
+
const jsxNoSubInterface = createRule$19({
|
|
1216
1216
|
name: "jsx-no-sub-interface",
|
|
1217
1217
|
meta: {
|
|
1218
1218
|
type: "problem",
|
|
@@ -1279,13 +1279,13 @@ const jsxNoSubInterface = createRule$20({
|
|
|
1279
1279
|
});
|
|
1280
1280
|
//#endregion
|
|
1281
1281
|
//#region src/rules/jsx-no-ternary-null.ts
|
|
1282
|
-
const createRule$
|
|
1282
|
+
const createRule$18 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
1283
1283
|
function isNullOrUndefined(node) {
|
|
1284
1284
|
if (node.type === _typescript_eslint_utils.AST_NODE_TYPES.Literal && node.value === null) return true;
|
|
1285
1285
|
if (node.type === _typescript_eslint_utils.AST_NODE_TYPES.Identifier && node.name === "undefined") return true;
|
|
1286
1286
|
return false;
|
|
1287
1287
|
}
|
|
1288
|
-
const jsxNoTernaryNull = createRule$
|
|
1288
|
+
const jsxNoTernaryNull = createRule$18({
|
|
1289
1289
|
name: "jsx-no-ternary-null",
|
|
1290
1290
|
meta: {
|
|
1291
1291
|
type: "suggestion",
|
|
@@ -1452,7 +1452,7 @@ const jsxSimpleProps = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) =
|
|
|
1452
1452
|
});
|
|
1453
1453
|
//#endregion
|
|
1454
1454
|
//#region src/rules/jsx-sort-props.ts
|
|
1455
|
-
const createRule$
|
|
1455
|
+
const createRule$17 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
1456
1456
|
const TYPE_GROUP = {
|
|
1457
1457
|
STRING: 1,
|
|
1458
1458
|
HYPHENATED_STRING: 2,
|
|
@@ -1535,7 +1535,7 @@ function getSegments(attributes) {
|
|
|
1535
1535
|
if (current.length > 0) result.push(current);
|
|
1536
1536
|
return result;
|
|
1537
1537
|
}
|
|
1538
|
-
const jsxSortProps = createRule$
|
|
1538
|
+
const jsxSortProps = createRule$17({
|
|
1539
1539
|
name: "jsx-sort-props",
|
|
1540
1540
|
meta: {
|
|
1541
1541
|
type: "suggestion",
|
|
@@ -1590,7 +1590,7 @@ const jsxSpreadPropsLast = _typescript_eslint_utils.ESLintUtils.RuleCreator((nam
|
|
|
1590
1590
|
});
|
|
1591
1591
|
//#endregion
|
|
1592
1592
|
//#region src/rules/newline-after-multiline-block.ts
|
|
1593
|
-
const createRule$
|
|
1593
|
+
const createRule$16 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
1594
1594
|
function isImportDeclaration(node) {
|
|
1595
1595
|
return node.type === _typescript_eslint_utils.AST_NODE_TYPES.ImportDeclaration;
|
|
1596
1596
|
}
|
|
@@ -1615,7 +1615,7 @@ function checkStatements(statements, context) {
|
|
|
1615
1615
|
});
|
|
1616
1616
|
});
|
|
1617
1617
|
}
|
|
1618
|
-
const newlineAfterMultilineBlock = createRule$
|
|
1618
|
+
const newlineAfterMultilineBlock = createRule$16({
|
|
1619
1619
|
name: "newline-after-multiline-block",
|
|
1620
1620
|
meta: {
|
|
1621
1621
|
type: "layout",
|
|
@@ -1801,12 +1801,12 @@ const noEnvFallback = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) =>
|
|
|
1801
1801
|
});
|
|
1802
1802
|
//#endregion
|
|
1803
1803
|
//#region src/rules/no-ghost-wrapper.ts
|
|
1804
|
-
const createRule$
|
|
1804
|
+
const createRule$15 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
1805
1805
|
const GHOST_TAGS = new Set(["div", "span"]);
|
|
1806
1806
|
function isKeyAttribute(attribute) {
|
|
1807
1807
|
return attribute.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXAttribute && attribute.name.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "key";
|
|
1808
1808
|
}
|
|
1809
|
-
const noGhostWrapper = createRule$
|
|
1809
|
+
const noGhostWrapper = createRule$15({
|
|
1810
1810
|
name: "no-ghost-wrapper",
|
|
1811
1811
|
meta: {
|
|
1812
1812
|
type: "problem",
|
|
@@ -1978,7 +1978,7 @@ const noInlineDefaultExport = _typescript_eslint_utils.ESLintUtils.RuleCreator((
|
|
|
1978
1978
|
});
|
|
1979
1979
|
//#endregion
|
|
1980
1980
|
//#region src/rules/no-inline-nested-object.ts
|
|
1981
|
-
const createRule$
|
|
1981
|
+
const createRule$14 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
1982
1982
|
function isObjectOrArray(node) {
|
|
1983
1983
|
return node.type === _typescript_eslint_utils.AST_NODE_TYPES.ObjectExpression || node.type === _typescript_eslint_utils.AST_NODE_TYPES.ArrayExpression || node.type === _typescript_eslint_utils.AST_NODE_TYPES.TSAsExpression;
|
|
1984
1984
|
}
|
|
@@ -2000,7 +2000,7 @@ function containsNestedStructure(node) {
|
|
|
2000
2000
|
return isNestedStructure(el);
|
|
2001
2001
|
});
|
|
2002
2002
|
}
|
|
2003
|
-
const noInlineNestedObject = createRule$
|
|
2003
|
+
const noInlineNestedObject = createRule$14({
|
|
2004
2004
|
name: "no-inline-nested-object",
|
|
2005
2005
|
meta: {
|
|
2006
2006
|
type: "layout",
|
|
@@ -2042,13 +2042,13 @@ const noInlineNestedObject = createRule$15({
|
|
|
2042
2042
|
});
|
|
2043
2043
|
//#endregion
|
|
2044
2044
|
//#region src/rules/no-inline-return-properties.ts
|
|
2045
|
-
const createRule$
|
|
2045
|
+
const createRule$13 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
2046
2046
|
const isShorthandProperty = (property) => {
|
|
2047
2047
|
if (property.type === _typescript_eslint_utils.AST_NODE_TYPES.SpreadElement) return true;
|
|
2048
2048
|
if (property.type !== _typescript_eslint_utils.AST_NODE_TYPES.Property) return false;
|
|
2049
2049
|
return property.shorthand;
|
|
2050
2050
|
};
|
|
2051
|
-
const noInlineReturnProperties = createRule$
|
|
2051
|
+
const noInlineReturnProperties = createRule$13({
|
|
2052
2052
|
name: "no-inline-return-properties",
|
|
2053
2053
|
meta: {
|
|
2054
2054
|
type: "suggestion",
|
|
@@ -2077,9 +2077,9 @@ const noInlineReturnProperties = createRule$14({
|
|
|
2077
2077
|
});
|
|
2078
2078
|
//#endregion
|
|
2079
2079
|
//#region src/rules/no-inline-type-import.ts
|
|
2080
|
-
const createRule$
|
|
2080
|
+
const createRule$12 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
2081
2081
|
const isInlineTypeSpecifier = (specifier) => specifier.type === _typescript_eslint_utils.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type";
|
|
2082
|
-
const noInlineTypeImport = createRule$
|
|
2082
|
+
const noInlineTypeImport = createRule$12({
|
|
2083
2083
|
name: "no-inline-type-import",
|
|
2084
2084
|
meta: {
|
|
2085
2085
|
type: "suggestion",
|
|
@@ -2121,7 +2121,7 @@ const noInlineTypeImport = createRule$13({
|
|
|
2121
2121
|
});
|
|
2122
2122
|
//#endregion
|
|
2123
2123
|
//#region src/rules/no-lazy-identifiers.ts
|
|
2124
|
-
const createRule$
|
|
2124
|
+
const createRule$11 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
2125
2125
|
const KEYBOARD_ROWS = [
|
|
2126
2126
|
"qwertyuiop",
|
|
2127
2127
|
"asdfghjkl",
|
|
@@ -2152,7 +2152,7 @@ const isLazyIdentifier = (name) => {
|
|
|
2152
2152
|
if (hasKeyboardSequence(name)) return true;
|
|
2153
2153
|
return false;
|
|
2154
2154
|
};
|
|
2155
|
-
const noLazyIdentifiers = createRule$
|
|
2155
|
+
const noLazyIdentifiers = createRule$11({
|
|
2156
2156
|
name: "no-lazy-identifiers",
|
|
2157
2157
|
meta: {
|
|
2158
2158
|
type: "problem",
|
|
@@ -2271,7 +2271,7 @@ const noLogicInParams = _typescript_eslint_utils.ESLintUtils.RuleCreator((name)
|
|
|
2271
2271
|
});
|
|
2272
2272
|
//#endregion
|
|
2273
2273
|
//#region src/rules/no-misleading-constant-case.ts
|
|
2274
|
-
const createRule$
|
|
2274
|
+
const createRule$10 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
2275
2275
|
const SCREAMING_SNAKE_CASE_REGEX = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2276
2276
|
const isAsConstAssertion = (node) => node.type === _typescript_eslint_utils.AST_NODE_TYPES.TSAsExpression && node.typeAnnotation.type === _typescript_eslint_utils.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === _typescript_eslint_utils.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
2277
2277
|
const isStaticValue = (init) => {
|
|
@@ -2289,7 +2289,7 @@ const isGlobalScope = (node) => {
|
|
|
2289
2289
|
if (parent.type === _typescript_eslint_utils.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === _typescript_eslint_utils.AST_NODE_TYPES.Program) return true;
|
|
2290
2290
|
return false;
|
|
2291
2291
|
};
|
|
2292
|
-
const noMisleadingConstantCase = createRule$
|
|
2292
|
+
const noMisleadingConstantCase = createRule$10({
|
|
2293
2293
|
name: "no-misleading-constant-case",
|
|
2294
2294
|
meta: {
|
|
2295
2295
|
type: "suggestion",
|
|
@@ -2403,7 +2403,7 @@ const noNestedTernary = _typescript_eslint_utils.ESLintUtils.RuleCreator((name)
|
|
|
2403
2403
|
});
|
|
2404
2404
|
//#endregion
|
|
2405
2405
|
//#region src/rules/no-redundant-fragment.ts
|
|
2406
|
-
const createRule$
|
|
2406
|
+
const createRule$9 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
2407
2407
|
function isFragmentName(name) {
|
|
2408
2408
|
if (name.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXIdentifier && name.name === "Fragment") return true;
|
|
2409
2409
|
if (name.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXMemberExpression && name.object.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXIdentifier && name.object.name === "React" && name.property.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXIdentifier && name.property.name === "Fragment") return true;
|
|
@@ -2418,7 +2418,7 @@ function countMeaningfulChildren(children) {
|
|
|
2418
2418
|
return true;
|
|
2419
2419
|
}).length;
|
|
2420
2420
|
}
|
|
2421
|
-
const noRedundantFragment = createRule$
|
|
2421
|
+
const noRedundantFragment = createRule$9({
|
|
2422
2422
|
name: "no-redundant-fragment",
|
|
2423
2423
|
meta: {
|
|
2424
2424
|
type: "problem",
|
|
@@ -2488,7 +2488,7 @@ const noRelativeImports = _typescript_eslint_utils.ESLintUtils.RuleCreator((name
|
|
|
2488
2488
|
});
|
|
2489
2489
|
//#endregion
|
|
2490
2490
|
//#region src/rules/no-single-char-variables.ts
|
|
2491
|
-
const createRule$
|
|
2491
|
+
const createRule$8 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
2492
2492
|
const ALLOWED_IN_FOR_LOOPS = new Set([
|
|
2493
2493
|
"i",
|
|
2494
2494
|
"j",
|
|
@@ -2514,7 +2514,7 @@ const isAllowedInContext = (name, node) => {
|
|
|
2514
2514
|
if (ALLOWED_IN_FOR_LOOPS.has(name) && isForLoopInit(node)) return true;
|
|
2515
2515
|
return false;
|
|
2516
2516
|
};
|
|
2517
|
-
const noSingleCharVariables = createRule$
|
|
2517
|
+
const noSingleCharVariables = createRule$8({
|
|
2518
2518
|
name: "no-single-char-variables",
|
|
2519
2519
|
meta: {
|
|
2520
2520
|
type: "suggestion",
|
|
@@ -2636,7 +2636,7 @@ const preferDestructuringParams = _typescript_eslint_utils.ESLintUtils.RuleCreat
|
|
|
2636
2636
|
});
|
|
2637
2637
|
//#endregion
|
|
2638
2638
|
//#region src/rules/prefer-function-declaration.ts
|
|
2639
|
-
const createRule$
|
|
2639
|
+
const createRule$7 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
2640
2640
|
const isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
2641
2641
|
const isCallbackContext = (node) => {
|
|
2642
2642
|
const { parent } = node;
|
|
@@ -2651,7 +2651,7 @@ const isCallbackContext = (node) => {
|
|
|
2651
2651
|
if (parent.type === _typescript_eslint_utils.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) return true;
|
|
2652
2652
|
return false;
|
|
2653
2653
|
};
|
|
2654
|
-
const preferFunctionDeclaration = createRule$
|
|
2654
|
+
const preferFunctionDeclaration = createRule$7({
|
|
2655
2655
|
name: "prefer-function-declaration",
|
|
2656
2656
|
meta: {
|
|
2657
2657
|
type: "suggestion",
|
|
@@ -2766,6 +2766,7 @@ const preferImportType = _typescript_eslint_utils.ESLintUtils.RuleCreator((name)
|
|
|
2766
2766
|
switch (parent.type) {
|
|
2767
2767
|
case _typescript_eslint_utils.AST_NODE_TYPES.CallExpression:
|
|
2768
2768
|
case _typescript_eslint_utils.AST_NODE_TYPES.NewExpression:
|
|
2769
|
+
case _typescript_eslint_utils.AST_NODE_TYPES.JSXMemberExpression:
|
|
2769
2770
|
case _typescript_eslint_utils.AST_NODE_TYPES.JSXOpeningElement:
|
|
2770
2771
|
case _typescript_eslint_utils.AST_NODE_TYPES.JSXClosingElement:
|
|
2771
2772
|
case _typescript_eslint_utils.AST_NODE_TYPES.MemberExpression:
|
|
@@ -2819,12 +2820,12 @@ const preferImportType = _typescript_eslint_utils.ESLintUtils.RuleCreator((name)
|
|
|
2819
2820
|
});
|
|
2820
2821
|
//#endregion
|
|
2821
2822
|
//#region src/rules/prefer-inline-literal-union.ts
|
|
2822
|
-
const createRule$
|
|
2823
|
+
const createRule$6 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
2823
2824
|
function isLiteralUnionType(node) {
|
|
2824
2825
|
if (node.type !== _typescript_eslint_utils.AST_NODE_TYPES.TSUnionType) return false;
|
|
2825
2826
|
return node.types.every((member) => member.type === _typescript_eslint_utils.AST_NODE_TYPES.TSLiteralType || member.type === _typescript_eslint_utils.AST_NODE_TYPES.TSNullKeyword || member.type === _typescript_eslint_utils.AST_NODE_TYPES.TSUndefinedKeyword);
|
|
2826
2827
|
}
|
|
2827
|
-
const preferInlineLiteralUnion = createRule$
|
|
2828
|
+
const preferInlineLiteralUnion = createRule$6({
|
|
2828
2829
|
name: "prefer-inline-literal-union",
|
|
2829
2830
|
meta: {
|
|
2830
2831
|
type: "suggestion",
|
|
@@ -2862,65 +2863,6 @@ const preferInlineLiteralUnion = createRule$7({
|
|
|
2862
2863
|
}
|
|
2863
2864
|
});
|
|
2864
2865
|
//#endregion
|
|
2865
|
-
//#region src/rules/prefer-inline-type-export.ts
|
|
2866
|
-
const createRule$6 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
2867
|
-
const isTypeDeclaration = (node) => node.type === _typescript_eslint_utils.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === _typescript_eslint_utils.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
2868
|
-
const preferInlineTypeExport = createRule$6({
|
|
2869
|
-
name: "prefer-inline-type-export",
|
|
2870
|
-
meta: {
|
|
2871
|
-
type: "suggestion",
|
|
2872
|
-
docs: { description: "Require type and interface declarations to be exported inline rather than via a separate export statement" },
|
|
2873
|
-
fixable: "code",
|
|
2874
|
-
messages: { preferInlineExport: "Export '{{name}}' inline at its declaration instead of using a separate export statement." },
|
|
2875
|
-
schema: []
|
|
2876
|
-
},
|
|
2877
|
-
defaultOptions: [],
|
|
2878
|
-
create(context) {
|
|
2879
|
-
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
2880
|
-
function collectDeclaration(node) {
|
|
2881
|
-
if (node.parent.type !== _typescript_eslint_utils.AST_NODE_TYPES.ExportNamedDeclaration) typeDeclarations.set(node.id.name, node);
|
|
2882
|
-
}
|
|
2883
|
-
function reportSpecifier(specifier, statement, declarationNode) {
|
|
2884
|
-
if (specifier.local.type !== _typescript_eslint_utils.AST_NODE_TYPES.Identifier) return;
|
|
2885
|
-
const { name } = specifier.local;
|
|
2886
|
-
context.report({
|
|
2887
|
-
node: specifier,
|
|
2888
|
-
messageId: "preferInlineExport",
|
|
2889
|
-
data: { name },
|
|
2890
|
-
fix(fixer) {
|
|
2891
|
-
const { sourceCode } = context;
|
|
2892
|
-
const declarationToken = sourceCode.getFirstToken(declarationNode);
|
|
2893
|
-
if (!declarationToken) return null;
|
|
2894
|
-
if (statement.specifiers.length === 1) {
|
|
2895
|
-
const nextToken = sourceCode.getTokenAfter(statement);
|
|
2896
|
-
const end = nextToken ? nextToken.range[0] : statement.range[1];
|
|
2897
|
-
return [fixer.insertTextBefore(declarationToken, "export "), fixer.removeRange([statement.range[0], end])];
|
|
2898
|
-
}
|
|
2899
|
-
const tokenBefore = sourceCode.getTokenBefore(specifier);
|
|
2900
|
-
const tokenAfter = sourceCode.getTokenAfter(specifier);
|
|
2901
|
-
if (!tokenBefore || !tokenAfter) return null;
|
|
2902
|
-
const removalRange = statement.specifiers.at(-1) === specifier && tokenBefore.value === "," ? [tokenBefore.range[0], specifier.range[1]] : [specifier.range[0], tokenAfter.range[1]];
|
|
2903
|
-
return [fixer.insertTextBefore(declarationToken, "export "), fixer.removeRange(removalRange)];
|
|
2904
|
-
}
|
|
2905
|
-
});
|
|
2906
|
-
}
|
|
2907
|
-
return { Program(node) {
|
|
2908
|
-
node.body.forEach((statement) => {
|
|
2909
|
-
if (statement.type === _typescript_eslint_utils.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === _typescript_eslint_utils.AST_NODE_TYPES.TSTypeAliasDeclaration) collectDeclaration(statement);
|
|
2910
|
-
});
|
|
2911
|
-
node.body.forEach((statement) => {
|
|
2912
|
-
if (statement.type !== _typescript_eslint_utils.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) return;
|
|
2913
|
-
statement.specifiers.forEach((specifier) => {
|
|
2914
|
-
if (specifier.local.type !== _typescript_eslint_utils.AST_NODE_TYPES.Identifier) return;
|
|
2915
|
-
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
2916
|
-
if (!declarationNode || !isTypeDeclaration(declarationNode)) return;
|
|
2917
|
-
reportSpecifier(specifier, statement, declarationNode);
|
|
2918
|
-
});
|
|
2919
|
-
});
|
|
2920
|
-
} };
|
|
2921
|
-
}
|
|
2922
|
-
});
|
|
2923
|
-
//#endregion
|
|
2924
2866
|
//#region src/rules/prefer-interface-for-component-props.ts
|
|
2925
2867
|
const preferInterfaceForComponentProps = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`)({
|
|
2926
2868
|
name: "prefer-interface-for-component-props",
|
|
@@ -3141,7 +3083,7 @@ const preferPropsWithChildren = _typescript_eslint_utils.ESLintUtils.RuleCreator
|
|
|
3141
3083
|
type: "suggestion",
|
|
3142
3084
|
docs: { description: "Prefer PropsWithChildren<T> over manually declaring children: ReactNode in component props" },
|
|
3143
3085
|
schema: [],
|
|
3144
|
-
messages: { usePropsWithChildren: "Use 'PropsWithChildren<T>' instead of manually declaring 'children
|
|
3086
|
+
messages: { usePropsWithChildren: "Use 'PropsWithChildren<T>' instead of manually declaring 'children?: ReactNode'." }
|
|
3145
3087
|
},
|
|
3146
3088
|
defaultOptions: [],
|
|
3147
3089
|
create(context) {
|
|
@@ -3160,7 +3102,7 @@ const preferPropsWithChildren = _typescript_eslint_utils.ESLintUtils.RuleCreator
|
|
|
3160
3102
|
if (member.key.type !== _typescript_eslint_utils.AST_NODE_TYPES.Identifier) continue;
|
|
3161
3103
|
if (member.key.name !== "children") continue;
|
|
3162
3104
|
if (!member.typeAnnotation) continue;
|
|
3163
|
-
if (isReactNodeType(member.typeAnnotation.typeAnnotation)) return member;
|
|
3105
|
+
if (member.optional && isReactNodeType(member.typeAnnotation.typeAnnotation)) return member;
|
|
3164
3106
|
}
|
|
3165
3107
|
}
|
|
3166
3108
|
return {
|
|
@@ -3777,7 +3719,6 @@ const rules = {
|
|
|
3777
3719
|
"prefer-guard-clause": preferGuardClause,
|
|
3778
3720
|
"prefer-import-type": preferImportType,
|
|
3779
3721
|
"prefer-inline-literal-union": preferInlineLiteralUnion,
|
|
3780
|
-
"prefer-inline-type-export": preferInlineTypeExport,
|
|
3781
3722
|
"prefer-interface-for-component-props": preferInterfaceForComponentProps,
|
|
3782
3723
|
"prefer-interface-over-inline-types": preferInterfaceOverInlineTypes,
|
|
3783
3724
|
"prefer-jsx-template-literals": preferJSXTemplateLiterals,
|
|
@@ -3832,7 +3773,6 @@ const baseRules = {
|
|
|
3832
3773
|
"nextfriday/prefer-guard-clause": "warn",
|
|
3833
3774
|
"nextfriday/prefer-import-type": "warn",
|
|
3834
3775
|
"nextfriday/prefer-inline-literal-union": "warn",
|
|
3835
|
-
"nextfriday/prefer-inline-type-export": "warn",
|
|
3836
3776
|
"nextfriday/prefer-named-param-types": "warn",
|
|
3837
3777
|
"nextfriday/prefer-react-import-types": "warn",
|
|
3838
3778
|
"nextfriday/require-explicit-return-type": "warn",
|
|
@@ -3878,7 +3818,6 @@ const baseRecommendedRules = {
|
|
|
3878
3818
|
"nextfriday/prefer-guard-clause": "error",
|
|
3879
3819
|
"nextfriday/prefer-import-type": "error",
|
|
3880
3820
|
"nextfriday/prefer-inline-literal-union": "error",
|
|
3881
|
-
"nextfriday/prefer-inline-type-export": "error",
|
|
3882
3821
|
"nextfriday/prefer-named-param-types": "error",
|
|
3883
3822
|
"nextfriday/prefer-react-import-types": "error",
|
|
3884
3823
|
"nextfriday/require-explicit-return-type": "error",
|