eslint-plugin-nextfriday 1.23.1 → 2.0.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 +16 -0
- package/README.md +4 -1
- package/docs/rules/JSX_SPREAD_PROPS_LAST.md +42 -0
- package/lib/index.cjs +355 -311
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +42 -0
- package/lib/index.d.ts +42 -0
- package/lib/index.js +355 -311
- package/lib/index.js.map +1 -1
- package/package.json +4 -5
package/lib/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
|
42
42
|
// package.json
|
|
43
43
|
var package_default = {
|
|
44
44
|
name: "eslint-plugin-nextfriday",
|
|
45
|
-
version: "
|
|
45
|
+
version: "2.0.0",
|
|
46
46
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
47
47
|
keywords: [
|
|
48
48
|
"eslint",
|
|
@@ -117,7 +117,7 @@ var package_default = {
|
|
|
117
117
|
"@changesets/cli": "^2.31.0",
|
|
118
118
|
"@commitlint/cli": "^20.5.2",
|
|
119
119
|
"@commitlint/config-conventional": "^20.5.0",
|
|
120
|
-
"@eslint/js": "^
|
|
120
|
+
"@eslint/js": "^10.0.1",
|
|
121
121
|
"@jest/globals": "^30.3.0",
|
|
122
122
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
123
123
|
"@swc/core": "^1.15.32",
|
|
@@ -128,8 +128,7 @@ var package_default = {
|
|
|
128
128
|
"@types/ramda": "^0.31.1",
|
|
129
129
|
"@typescript-eslint/parser": "^8.59.1",
|
|
130
130
|
"@typescript-eslint/rule-tester": "^8.59.1",
|
|
131
|
-
eslint: "^
|
|
132
|
-
"eslint-config-airbnb-extended": "^3.0.1",
|
|
131
|
+
eslint: "^10.2.1",
|
|
133
132
|
"eslint-config-prettier": "^10.1.8",
|
|
134
133
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
135
134
|
"eslint-plugin-import-x": "^4.16.2",
|
|
@@ -146,7 +145,7 @@ var package_default = {
|
|
|
146
145
|
"typescript-eslint": "^8.59.1"
|
|
147
146
|
},
|
|
148
147
|
peerDependencies: {
|
|
149
|
-
eslint: "^
|
|
148
|
+
eslint: "^10.0.0"
|
|
150
149
|
},
|
|
151
150
|
packageManager: "pnpm@9.12.0",
|
|
152
151
|
engines: {
|
|
@@ -1871,13 +1870,55 @@ var jsxSortProps = createRule22({
|
|
|
1871
1870
|
});
|
|
1872
1871
|
var jsx_sort_props_default = jsxSortProps;
|
|
1873
1872
|
|
|
1874
|
-
// src/rules/
|
|
1873
|
+
// src/rules/jsx-spread-props-last.ts
|
|
1875
1874
|
var import_utils25 = require("@typescript-eslint/utils");
|
|
1876
1875
|
var createRule23 = import_utils25.ESLintUtils.RuleCreator(
|
|
1877
1876
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1878
1877
|
);
|
|
1878
|
+
var jsxSpreadPropsLast = createRule23({
|
|
1879
|
+
name: "jsx-spread-props-last",
|
|
1880
|
+
meta: {
|
|
1881
|
+
type: "suggestion",
|
|
1882
|
+
docs: {
|
|
1883
|
+
description: "Enforce JSX spread attributes appear after all other props"
|
|
1884
|
+
},
|
|
1885
|
+
messages: {
|
|
1886
|
+
spreadNotLast: "JSX spread attributes must come after all other props."
|
|
1887
|
+
},
|
|
1888
|
+
schema: []
|
|
1889
|
+
},
|
|
1890
|
+
defaultOptions: [],
|
|
1891
|
+
create(context) {
|
|
1892
|
+
return {
|
|
1893
|
+
JSXOpeningElement(node) {
|
|
1894
|
+
const { attributes } = node;
|
|
1895
|
+
let lastNonSpreadIndex = -1;
|
|
1896
|
+
attributes.forEach((attribute, index) => {
|
|
1897
|
+
if (attribute.type !== import_utils25.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1898
|
+
lastNonSpreadIndex = index;
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
attributes.forEach((attribute, index) => {
|
|
1902
|
+
if (attribute.type === import_utils25.AST_NODE_TYPES.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1903
|
+
context.report({
|
|
1904
|
+
node: attribute,
|
|
1905
|
+
messageId: "spreadNotLast"
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
});
|
|
1913
|
+
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1914
|
+
|
|
1915
|
+
// src/rules/newline-after-multiline-block.ts
|
|
1916
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
1917
|
+
var createRule24 = import_utils26.ESLintUtils.RuleCreator(
|
|
1918
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1919
|
+
);
|
|
1879
1920
|
function isImportDeclaration(node) {
|
|
1880
|
-
return node.type ===
|
|
1921
|
+
return node.type === import_utils26.AST_NODE_TYPES.ImportDeclaration;
|
|
1881
1922
|
}
|
|
1882
1923
|
function checkStatements(statements, context) {
|
|
1883
1924
|
const { sourceCode } = context;
|
|
@@ -1912,7 +1953,7 @@ function checkStatements(statements, context) {
|
|
|
1912
1953
|
}
|
|
1913
1954
|
});
|
|
1914
1955
|
}
|
|
1915
|
-
var newlineAfterMultilineBlock =
|
|
1956
|
+
var newlineAfterMultilineBlock = createRule24({
|
|
1916
1957
|
name: "newline-after-multiline-block",
|
|
1917
1958
|
meta: {
|
|
1918
1959
|
type: "layout",
|
|
@@ -1940,11 +1981,11 @@ var newlineAfterMultilineBlock = createRule23({
|
|
|
1940
1981
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
1941
1982
|
|
|
1942
1983
|
// src/rules/newline-before-return.ts
|
|
1943
|
-
var
|
|
1944
|
-
var
|
|
1984
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
1985
|
+
var createRule25 = import_utils27.ESLintUtils.RuleCreator(
|
|
1945
1986
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1946
1987
|
);
|
|
1947
|
-
var newlineBeforeReturn =
|
|
1988
|
+
var newlineBeforeReturn = createRule25({
|
|
1948
1989
|
name: "newline-before-return",
|
|
1949
1990
|
meta: {
|
|
1950
1991
|
type: "layout",
|
|
@@ -1962,7 +2003,7 @@ var newlineBeforeReturn = createRule24({
|
|
|
1962
2003
|
const { sourceCode } = context;
|
|
1963
2004
|
function checkReturnStatement(node) {
|
|
1964
2005
|
const { parent } = node;
|
|
1965
|
-
if (!parent || parent.type !==
|
|
2006
|
+
if (!parent || parent.type !== import_utils27.AST_NODE_TYPES.BlockStatement) {
|
|
1966
2007
|
return;
|
|
1967
2008
|
}
|
|
1968
2009
|
const { body: statements } = parent;
|
|
@@ -1999,11 +2040,11 @@ var newlineBeforeReturn = createRule24({
|
|
|
1999
2040
|
var newline_before_return_default = newlineBeforeReturn;
|
|
2000
2041
|
|
|
2001
2042
|
// src/rules/nextjs-require-public-env.ts
|
|
2002
|
-
var
|
|
2003
|
-
var
|
|
2043
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
2044
|
+
var createRule26 = import_utils28.ESLintUtils.RuleCreator(
|
|
2004
2045
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2005
2046
|
);
|
|
2006
|
-
var nextjsRequirePublicEnv =
|
|
2047
|
+
var nextjsRequirePublicEnv = createRule26({
|
|
2007
2048
|
name: "nextjs-require-public-env",
|
|
2008
2049
|
meta: {
|
|
2009
2050
|
type: "problem",
|
|
@@ -2021,7 +2062,7 @@ var nextjsRequirePublicEnv = createRule25({
|
|
|
2021
2062
|
return {
|
|
2022
2063
|
Program(node) {
|
|
2023
2064
|
const firstStatement = node.body[0];
|
|
2024
|
-
if (firstStatement?.type ===
|
|
2065
|
+
if (firstStatement?.type === import_utils28.AST_NODE_TYPES.ExpressionStatement && firstStatement.expression.type === import_utils28.AST_NODE_TYPES.Literal && firstStatement.expression.value === "use client") {
|
|
2025
2066
|
isClientComponent = true;
|
|
2026
2067
|
}
|
|
2027
2068
|
},
|
|
@@ -2029,7 +2070,7 @@ var nextjsRequirePublicEnv = createRule25({
|
|
|
2029
2070
|
if (!isClientComponent) {
|
|
2030
2071
|
return;
|
|
2031
2072
|
}
|
|
2032
|
-
if (node.object.type ===
|
|
2073
|
+
if (node.object.type === import_utils28.AST_NODE_TYPES.MemberExpression && node.object.object.type === import_utils28.AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === import_utils28.AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === import_utils28.AST_NODE_TYPES.Identifier) {
|
|
2033
2074
|
const envVarName = node.property.name;
|
|
2034
2075
|
if (!envVarName.startsWith("NEXT_PUBLIC_") && envVarName !== "NODE_ENV") {
|
|
2035
2076
|
context.report({
|
|
@@ -2048,11 +2089,11 @@ var nextjsRequirePublicEnv = createRule25({
|
|
|
2048
2089
|
var nextjs_require_public_env_default = nextjsRequirePublicEnv;
|
|
2049
2090
|
|
|
2050
2091
|
// src/rules/no-complex-inline-return.ts
|
|
2051
|
-
var
|
|
2052
|
-
var
|
|
2092
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
2093
|
+
var createRule27 = import_utils29.ESLintUtils.RuleCreator(
|
|
2053
2094
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2054
2095
|
);
|
|
2055
|
-
var noComplexInlineReturn =
|
|
2096
|
+
var noComplexInlineReturn = createRule27({
|
|
2056
2097
|
name: "no-complex-inline-return",
|
|
2057
2098
|
meta: {
|
|
2058
2099
|
type: "suggestion",
|
|
@@ -2068,13 +2109,13 @@ var noComplexInlineReturn = createRule26({
|
|
|
2068
2109
|
create(context) {
|
|
2069
2110
|
const isComplexExpression = (node) => {
|
|
2070
2111
|
if (!node) return false;
|
|
2071
|
-
if (node.type ===
|
|
2112
|
+
if (node.type === import_utils29.AST_NODE_TYPES.ConditionalExpression) {
|
|
2072
2113
|
return true;
|
|
2073
2114
|
}
|
|
2074
|
-
if (node.type ===
|
|
2115
|
+
if (node.type === import_utils29.AST_NODE_TYPES.LogicalExpression) {
|
|
2075
2116
|
return true;
|
|
2076
2117
|
}
|
|
2077
|
-
if (node.type ===
|
|
2118
|
+
if (node.type === import_utils29.AST_NODE_TYPES.NewExpression) {
|
|
2078
2119
|
return true;
|
|
2079
2120
|
}
|
|
2080
2121
|
return false;
|
|
@@ -2094,11 +2135,11 @@ var noComplexInlineReturn = createRule26({
|
|
|
2094
2135
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
2095
2136
|
|
|
2096
2137
|
// src/rules/no-direct-date.ts
|
|
2097
|
-
var
|
|
2098
|
-
var
|
|
2138
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
2139
|
+
var createRule28 = import_utils30.ESLintUtils.RuleCreator(
|
|
2099
2140
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2100
2141
|
);
|
|
2101
|
-
var noDirectDate =
|
|
2142
|
+
var noDirectDate = createRule28({
|
|
2102
2143
|
name: "no-direct-date",
|
|
2103
2144
|
meta: {
|
|
2104
2145
|
type: "problem",
|
|
@@ -2116,7 +2157,7 @@ var noDirectDate = createRule27({
|
|
|
2116
2157
|
create(context) {
|
|
2117
2158
|
return {
|
|
2118
2159
|
NewExpression(node) {
|
|
2119
|
-
if (node.callee.type ===
|
|
2160
|
+
if (node.callee.type === import_utils30.AST_NODE_TYPES.Identifier && node.callee.name === "Date") {
|
|
2120
2161
|
context.report({
|
|
2121
2162
|
node,
|
|
2122
2163
|
messageId: "noNewDate"
|
|
@@ -2124,7 +2165,7 @@ var noDirectDate = createRule27({
|
|
|
2124
2165
|
}
|
|
2125
2166
|
},
|
|
2126
2167
|
CallExpression(node) {
|
|
2127
|
-
if (node.callee.type ===
|
|
2168
|
+
if (node.callee.type === import_utils30.AST_NODE_TYPES.MemberExpression && node.callee.object.type === import_utils30.AST_NODE_TYPES.Identifier && node.callee.object.name === "Date" && node.callee.property.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
2128
2169
|
const methodName = node.callee.property.name;
|
|
2129
2170
|
if (methodName === "now") {
|
|
2130
2171
|
context.report({
|
|
@@ -2147,11 +2188,11 @@ var no_direct_date_default = noDirectDate;
|
|
|
2147
2188
|
|
|
2148
2189
|
// src/rules/no-emoji.ts
|
|
2149
2190
|
var import_emoji_regex = __toESM(require("emoji-regex"), 1);
|
|
2150
|
-
var
|
|
2151
|
-
var
|
|
2191
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
2192
|
+
var createRule29 = import_utils31.ESLintUtils.RuleCreator(
|
|
2152
2193
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2153
2194
|
);
|
|
2154
|
-
var noEmoji =
|
|
2195
|
+
var noEmoji = createRule29({
|
|
2155
2196
|
name: "no-emoji",
|
|
2156
2197
|
meta: {
|
|
2157
2198
|
type: "problem",
|
|
@@ -2185,11 +2226,11 @@ var noEmoji = createRule28({
|
|
|
2185
2226
|
var no_emoji_default = noEmoji;
|
|
2186
2227
|
|
|
2187
2228
|
// src/rules/no-env-fallback.ts
|
|
2188
|
-
var
|
|
2189
|
-
var
|
|
2229
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
2230
|
+
var createRule30 = import_utils32.ESLintUtils.RuleCreator(
|
|
2190
2231
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2191
2232
|
);
|
|
2192
|
-
var noEnvFallback =
|
|
2233
|
+
var noEnvFallback = createRule30({
|
|
2193
2234
|
name: "no-env-fallback",
|
|
2194
2235
|
meta: {
|
|
2195
2236
|
type: "problem",
|
|
@@ -2204,16 +2245,16 @@ var noEnvFallback = createRule29({
|
|
|
2204
2245
|
defaultOptions: [],
|
|
2205
2246
|
create(context) {
|
|
2206
2247
|
const isProcessEnvAccess = (node) => {
|
|
2207
|
-
if (node.type !==
|
|
2248
|
+
if (node.type !== import_utils32.AST_NODE_TYPES.MemberExpression) {
|
|
2208
2249
|
return false;
|
|
2209
2250
|
}
|
|
2210
2251
|
const { object } = node;
|
|
2211
|
-
if (object.type !==
|
|
2252
|
+
if (object.type !== import_utils32.AST_NODE_TYPES.MemberExpression) {
|
|
2212
2253
|
return false;
|
|
2213
2254
|
}
|
|
2214
2255
|
const processNode = object.object;
|
|
2215
2256
|
const envNode = object.property;
|
|
2216
|
-
return processNode.type ===
|
|
2257
|
+
return processNode.type === import_utils32.AST_NODE_TYPES.Identifier && processNode.name === "process" && envNode.type === import_utils32.AST_NODE_TYPES.Identifier && envNode.name === "env";
|
|
2217
2258
|
};
|
|
2218
2259
|
return {
|
|
2219
2260
|
LogicalExpression(node) {
|
|
@@ -2238,11 +2279,11 @@ var noEnvFallback = createRule29({
|
|
|
2238
2279
|
var no_env_fallback_default = noEnvFallback;
|
|
2239
2280
|
|
|
2240
2281
|
// src/rules/no-inline-default-export.ts
|
|
2241
|
-
var
|
|
2242
|
-
var
|
|
2282
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
2283
|
+
var createRule31 = import_utils33.ESLintUtils.RuleCreator(
|
|
2243
2284
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2244
2285
|
);
|
|
2245
|
-
var noInlineDefaultExport =
|
|
2286
|
+
var noInlineDefaultExport = createRule31({
|
|
2246
2287
|
name: "no-inline-default-export",
|
|
2247
2288
|
meta: {
|
|
2248
2289
|
type: "suggestion",
|
|
@@ -2261,7 +2302,7 @@ var noInlineDefaultExport = createRule30({
|
|
|
2261
2302
|
return {
|
|
2262
2303
|
ExportDefaultDeclaration(node) {
|
|
2263
2304
|
const { declaration } = node;
|
|
2264
|
-
if (declaration.type ===
|
|
2305
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2265
2306
|
if (declaration.id) {
|
|
2266
2307
|
context.report({
|
|
2267
2308
|
node,
|
|
@@ -2276,7 +2317,7 @@ var noInlineDefaultExport = createRule30({
|
|
|
2276
2317
|
});
|
|
2277
2318
|
}
|
|
2278
2319
|
}
|
|
2279
|
-
if (declaration.type ===
|
|
2320
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.ClassDeclaration) {
|
|
2280
2321
|
if (declaration.id) {
|
|
2281
2322
|
context.report({
|
|
2282
2323
|
node,
|
|
@@ -2291,7 +2332,7 @@ var noInlineDefaultExport = createRule30({
|
|
|
2291
2332
|
});
|
|
2292
2333
|
}
|
|
2293
2334
|
}
|
|
2294
|
-
if (declaration.type ===
|
|
2335
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.ArrowFunctionExpression || declaration.type === import_utils33.AST_NODE_TYPES.FunctionExpression) {
|
|
2295
2336
|
context.report({
|
|
2296
2337
|
node,
|
|
2297
2338
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2304,14 +2345,14 @@ var noInlineDefaultExport = createRule30({
|
|
|
2304
2345
|
if (!declaration) {
|
|
2305
2346
|
return;
|
|
2306
2347
|
}
|
|
2307
|
-
if (declaration.type ===
|
|
2348
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.FunctionDeclaration && declaration.id) {
|
|
2308
2349
|
context.report({
|
|
2309
2350
|
node,
|
|
2310
2351
|
messageId: "noInlineNamedExport",
|
|
2311
2352
|
data: { type: "function", name: declaration.id.name }
|
|
2312
2353
|
});
|
|
2313
2354
|
}
|
|
2314
|
-
if (declaration.type ===
|
|
2355
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.ClassDeclaration && declaration.id) {
|
|
2315
2356
|
context.report({
|
|
2316
2357
|
node,
|
|
2317
2358
|
messageId: "noInlineNamedExport",
|
|
@@ -2325,15 +2366,15 @@ var noInlineDefaultExport = createRule30({
|
|
|
2325
2366
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2326
2367
|
|
|
2327
2368
|
// src/rules/no-inline-nested-object.ts
|
|
2328
|
-
var
|
|
2329
|
-
var
|
|
2369
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
2370
|
+
var createRule32 = import_utils34.ESLintUtils.RuleCreator(
|
|
2330
2371
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2331
2372
|
);
|
|
2332
2373
|
function isObjectOrArray(node) {
|
|
2333
|
-
return node.type ===
|
|
2374
|
+
return node.type === import_utils34.AST_NODE_TYPES.ObjectExpression || node.type === import_utils34.AST_NODE_TYPES.ArrayExpression || node.type === import_utils34.AST_NODE_TYPES.TSAsExpression;
|
|
2334
2375
|
}
|
|
2335
2376
|
function getInnerExpression(node) {
|
|
2336
|
-
if (node.type ===
|
|
2377
|
+
if (node.type === import_utils34.AST_NODE_TYPES.TSAsExpression) {
|
|
2337
2378
|
return getInnerExpression(node.expression);
|
|
2338
2379
|
}
|
|
2339
2380
|
return node;
|
|
@@ -2342,10 +2383,10 @@ function arrayContainsOnlyPrimitives(node) {
|
|
|
2342
2383
|
return node.elements.every((el) => {
|
|
2343
2384
|
if (el === null) return true;
|
|
2344
2385
|
const inner = getInnerExpression(el);
|
|
2345
|
-
return inner.type ===
|
|
2386
|
+
return inner.type === import_utils34.AST_NODE_TYPES.Literal || inner.type === import_utils34.AST_NODE_TYPES.Identifier || inner.type === import_utils34.AST_NODE_TYPES.TemplateLiteral || inner.type === import_utils34.AST_NODE_TYPES.UnaryExpression;
|
|
2346
2387
|
});
|
|
2347
2388
|
}
|
|
2348
|
-
var noInlineNestedObject =
|
|
2389
|
+
var noInlineNestedObject = createRule32({
|
|
2349
2390
|
name: "no-inline-nested-object",
|
|
2350
2391
|
meta: {
|
|
2351
2392
|
type: "layout",
|
|
@@ -2367,17 +2408,17 @@ var noInlineNestedObject = createRule31({
|
|
|
2367
2408
|
return;
|
|
2368
2409
|
}
|
|
2369
2410
|
const valueNode = getInnerExpression(node.value);
|
|
2370
|
-
if (valueNode.type !==
|
|
2411
|
+
if (valueNode.type !== import_utils34.AST_NODE_TYPES.ObjectExpression && valueNode.type !== import_utils34.AST_NODE_TYPES.ArrayExpression) {
|
|
2371
2412
|
return;
|
|
2372
2413
|
}
|
|
2373
2414
|
if (!valueNode.loc) {
|
|
2374
2415
|
return;
|
|
2375
2416
|
}
|
|
2376
|
-
const elements = valueNode.type ===
|
|
2417
|
+
const elements = valueNode.type === import_utils34.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2377
2418
|
if (elements.length <= 1) {
|
|
2378
2419
|
return;
|
|
2379
2420
|
}
|
|
2380
|
-
if (valueNode.type ===
|
|
2421
|
+
if (valueNode.type === import_utils34.AST_NODE_TYPES.ArrayExpression && arrayContainsOnlyPrimitives(valueNode)) {
|
|
2381
2422
|
return;
|
|
2382
2423
|
}
|
|
2383
2424
|
const isMultiline = valueNode.loc.start.line !== valueNode.loc.end.line;
|
|
@@ -2396,7 +2437,7 @@ var noInlineNestedObject = createRule31({
|
|
|
2396
2437
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2397
2438
|
const innerIndent = `${indent} `;
|
|
2398
2439
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2399
|
-
const isObject = valueNode.type ===
|
|
2440
|
+
const isObject = valueNode.type === import_utils34.AST_NODE_TYPES.ObjectExpression;
|
|
2400
2441
|
const openChar = isObject ? "{" : "[";
|
|
2401
2442
|
const closeChar = isObject ? "}" : "]";
|
|
2402
2443
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2413,20 +2454,20 @@ ${indent}${closeChar}`;
|
|
|
2413
2454
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2414
2455
|
|
|
2415
2456
|
// src/rules/no-inline-return-properties.ts
|
|
2416
|
-
var
|
|
2417
|
-
var
|
|
2457
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
2458
|
+
var createRule33 = import_utils35.ESLintUtils.RuleCreator(
|
|
2418
2459
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2419
2460
|
);
|
|
2420
2461
|
var isShorthandProperty = (property) => {
|
|
2421
|
-
if (property.type ===
|
|
2462
|
+
if (property.type === import_utils35.AST_NODE_TYPES.SpreadElement) {
|
|
2422
2463
|
return true;
|
|
2423
2464
|
}
|
|
2424
|
-
if (property.type !==
|
|
2465
|
+
if (property.type !== import_utils35.AST_NODE_TYPES.Property) {
|
|
2425
2466
|
return false;
|
|
2426
2467
|
}
|
|
2427
2468
|
return property.shorthand;
|
|
2428
2469
|
};
|
|
2429
|
-
var noInlineReturnProperties =
|
|
2470
|
+
var noInlineReturnProperties = createRule33({
|
|
2430
2471
|
name: "no-inline-return-properties",
|
|
2431
2472
|
meta: {
|
|
2432
2473
|
type: "suggestion",
|
|
@@ -2442,20 +2483,20 @@ var noInlineReturnProperties = createRule32({
|
|
|
2442
2483
|
create(context) {
|
|
2443
2484
|
return {
|
|
2444
2485
|
ReturnStatement(node) {
|
|
2445
|
-
if (!node.argument || node.argument.type !==
|
|
2486
|
+
if (!node.argument || node.argument.type !== import_utils35.AST_NODE_TYPES.ObjectExpression) {
|
|
2446
2487
|
return;
|
|
2447
2488
|
}
|
|
2448
2489
|
node.argument.properties.forEach((property) => {
|
|
2449
2490
|
if (isShorthandProperty(property)) {
|
|
2450
2491
|
return;
|
|
2451
2492
|
}
|
|
2452
|
-
if (property.type !==
|
|
2493
|
+
if (property.type !== import_utils35.AST_NODE_TYPES.Property) {
|
|
2453
2494
|
return;
|
|
2454
2495
|
}
|
|
2455
2496
|
let keyName = null;
|
|
2456
|
-
if (property.key.type ===
|
|
2497
|
+
if (property.key.type === import_utils35.AST_NODE_TYPES.Identifier) {
|
|
2457
2498
|
keyName = property.key.name;
|
|
2458
|
-
} else if (property.key.type ===
|
|
2499
|
+
} else if (property.key.type === import_utils35.AST_NODE_TYPES.Literal) {
|
|
2459
2500
|
keyName = String(property.key.value);
|
|
2460
2501
|
}
|
|
2461
2502
|
context.report({
|
|
@@ -2471,8 +2512,8 @@ var noInlineReturnProperties = createRule32({
|
|
|
2471
2512
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2472
2513
|
|
|
2473
2514
|
// src/rules/no-lazy-identifiers.ts
|
|
2474
|
-
var
|
|
2475
|
-
var
|
|
2515
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
2516
|
+
var createRule34 = import_utils36.ESLintUtils.RuleCreator(
|
|
2476
2517
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2477
2518
|
);
|
|
2478
2519
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2513,7 +2554,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2513
2554
|
}
|
|
2514
2555
|
return false;
|
|
2515
2556
|
};
|
|
2516
|
-
var noLazyIdentifiers =
|
|
2557
|
+
var noLazyIdentifiers = createRule34({
|
|
2517
2558
|
name: "no-lazy-identifiers",
|
|
2518
2559
|
meta: {
|
|
2519
2560
|
type: "problem",
|
|
@@ -2539,27 +2580,27 @@ var noLazyIdentifiers = createRule33({
|
|
|
2539
2580
|
});
|
|
2540
2581
|
};
|
|
2541
2582
|
const checkPattern = (pattern) => {
|
|
2542
|
-
if (pattern.type ===
|
|
2583
|
+
if (pattern.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2543
2584
|
checkIdentifier(pattern);
|
|
2544
|
-
} else if (pattern.type ===
|
|
2585
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.ObjectPattern) {
|
|
2545
2586
|
pattern.properties.forEach((prop) => {
|
|
2546
|
-
if (prop.type ===
|
|
2587
|
+
if (prop.type === import_utils36.AST_NODE_TYPES.Property && prop.value.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2547
2588
|
checkIdentifier(prop.value);
|
|
2548
|
-
} else if (prop.type ===
|
|
2589
|
+
} else if (prop.type === import_utils36.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2549
2590
|
checkIdentifier(prop.argument);
|
|
2550
2591
|
}
|
|
2551
2592
|
});
|
|
2552
|
-
} else if (pattern.type ===
|
|
2593
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.ArrayPattern) {
|
|
2553
2594
|
pattern.elements.forEach((element) => {
|
|
2554
|
-
if (element?.type ===
|
|
2595
|
+
if (element?.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2555
2596
|
checkIdentifier(element);
|
|
2556
|
-
} else if (element?.type ===
|
|
2597
|
+
} else if (element?.type === import_utils36.AST_NODE_TYPES.RestElement && element.argument.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2557
2598
|
checkIdentifier(element.argument);
|
|
2558
2599
|
}
|
|
2559
2600
|
});
|
|
2560
|
-
} else if (pattern.type ===
|
|
2601
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2561
2602
|
checkIdentifier(pattern.left);
|
|
2562
|
-
} else if (pattern.type ===
|
|
2603
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2563
2604
|
checkIdentifier(pattern.argument);
|
|
2564
2605
|
}
|
|
2565
2606
|
};
|
|
@@ -2604,11 +2645,11 @@ var noLazyIdentifiers = createRule33({
|
|
|
2604
2645
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2605
2646
|
|
|
2606
2647
|
// src/rules/no-logic-in-params.ts
|
|
2607
|
-
var
|
|
2608
|
-
var
|
|
2648
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
2649
|
+
var createRule35 = import_utils37.ESLintUtils.RuleCreator(
|
|
2609
2650
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2610
2651
|
);
|
|
2611
|
-
var noLogicInParams =
|
|
2652
|
+
var noLogicInParams = createRule35({
|
|
2612
2653
|
name: "no-logic-in-params",
|
|
2613
2654
|
meta: {
|
|
2614
2655
|
type: "suggestion",
|
|
@@ -2623,20 +2664,20 @@ var noLogicInParams = createRule34({
|
|
|
2623
2664
|
defaultOptions: [],
|
|
2624
2665
|
create(context) {
|
|
2625
2666
|
const isComplexExpression = (node) => {
|
|
2626
|
-
if (node.type ===
|
|
2667
|
+
if (node.type === import_utils37.AST_NODE_TYPES.SpreadElement) {
|
|
2627
2668
|
return false;
|
|
2628
2669
|
}
|
|
2629
|
-
if (node.type ===
|
|
2670
|
+
if (node.type === import_utils37.AST_NODE_TYPES.ConditionalExpression) {
|
|
2630
2671
|
return true;
|
|
2631
2672
|
}
|
|
2632
|
-
if (node.type ===
|
|
2673
|
+
if (node.type === import_utils37.AST_NODE_TYPES.LogicalExpression) {
|
|
2633
2674
|
return true;
|
|
2634
2675
|
}
|
|
2635
|
-
if (node.type ===
|
|
2676
|
+
if (node.type === import_utils37.AST_NODE_TYPES.BinaryExpression) {
|
|
2636
2677
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2637
2678
|
return logicalOperators.includes(node.operator);
|
|
2638
2679
|
}
|
|
2639
|
-
if (node.type ===
|
|
2680
|
+
if (node.type === import_utils37.AST_NODE_TYPES.UnaryExpression) {
|
|
2640
2681
|
return node.operator === "!";
|
|
2641
2682
|
}
|
|
2642
2683
|
return false;
|
|
@@ -2649,7 +2690,7 @@ var noLogicInParams = createRule34({
|
|
|
2649
2690
|
messageId: "noLogicInParams"
|
|
2650
2691
|
});
|
|
2651
2692
|
}
|
|
2652
|
-
if (arg.type ===
|
|
2693
|
+
if (arg.type === import_utils37.AST_NODE_TYPES.ArrayExpression) {
|
|
2653
2694
|
arg.elements.forEach((element) => {
|
|
2654
2695
|
if (element && isComplexExpression(element)) {
|
|
2655
2696
|
context.report({
|
|
@@ -2674,46 +2715,46 @@ var noLogicInParams = createRule34({
|
|
|
2674
2715
|
var no_logic_in_params_default = noLogicInParams;
|
|
2675
2716
|
|
|
2676
2717
|
// src/rules/no-misleading-constant-case.ts
|
|
2677
|
-
var
|
|
2678
|
-
var
|
|
2718
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
2719
|
+
var createRule36 = import_utils38.ESLintUtils.RuleCreator(
|
|
2679
2720
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2680
2721
|
);
|
|
2681
2722
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2682
|
-
var isAsConstAssertion2 = (node) => node.type ===
|
|
2723
|
+
var isAsConstAssertion2 = (node) => node.type === import_utils38.AST_NODE_TYPES.TSAsExpression && node.typeAnnotation.type === import_utils38.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === import_utils38.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
2683
2724
|
var isStaticValue3 = (init) => {
|
|
2684
2725
|
if (isAsConstAssertion2(init)) {
|
|
2685
2726
|
return true;
|
|
2686
2727
|
}
|
|
2687
|
-
if (init.type ===
|
|
2728
|
+
if (init.type === import_utils38.AST_NODE_TYPES.Literal) {
|
|
2688
2729
|
return true;
|
|
2689
2730
|
}
|
|
2690
|
-
if (init.type ===
|
|
2731
|
+
if (init.type === import_utils38.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils38.AST_NODE_TYPES.Literal) {
|
|
2691
2732
|
return true;
|
|
2692
2733
|
}
|
|
2693
|
-
if (init.type ===
|
|
2734
|
+
if (init.type === import_utils38.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
2694
2735
|
return true;
|
|
2695
2736
|
}
|
|
2696
|
-
if (init.type ===
|
|
2697
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
2737
|
+
if (init.type === import_utils38.AST_NODE_TYPES.ArrayExpression) {
|
|
2738
|
+
return init.elements.every((el) => el !== null && el.type !== import_utils38.AST_NODE_TYPES.SpreadElement && isStaticValue3(el));
|
|
2698
2739
|
}
|
|
2699
|
-
if (init.type ===
|
|
2740
|
+
if (init.type === import_utils38.AST_NODE_TYPES.ObjectExpression) {
|
|
2700
2741
|
return init.properties.every(
|
|
2701
|
-
(prop) => prop.type ===
|
|
2742
|
+
(prop) => prop.type === import_utils38.AST_NODE_TYPES.Property && isStaticValue3(prop.value)
|
|
2702
2743
|
);
|
|
2703
2744
|
}
|
|
2704
2745
|
return false;
|
|
2705
2746
|
};
|
|
2706
2747
|
var isGlobalScope3 = (node) => {
|
|
2707
2748
|
const { parent } = node;
|
|
2708
|
-
if (parent.type ===
|
|
2749
|
+
if (parent.type === import_utils38.AST_NODE_TYPES.Program) {
|
|
2709
2750
|
return true;
|
|
2710
2751
|
}
|
|
2711
|
-
if (parent.type ===
|
|
2752
|
+
if (parent.type === import_utils38.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils38.AST_NODE_TYPES.Program) {
|
|
2712
2753
|
return true;
|
|
2713
2754
|
}
|
|
2714
2755
|
return false;
|
|
2715
2756
|
};
|
|
2716
|
-
var noMisleadingConstantCase =
|
|
2757
|
+
var noMisleadingConstantCase = createRule36({
|
|
2717
2758
|
name: "no-misleading-constant-case",
|
|
2718
2759
|
meta: {
|
|
2719
2760
|
type: "suggestion",
|
|
@@ -2732,7 +2773,7 @@ var noMisleadingConstantCase = createRule35({
|
|
|
2732
2773
|
return {
|
|
2733
2774
|
VariableDeclaration(node) {
|
|
2734
2775
|
node.declarations.forEach((declarator) => {
|
|
2735
|
-
if (declarator.id.type !==
|
|
2776
|
+
if (declarator.id.type !== import_utils38.AST_NODE_TYPES.Identifier) {
|
|
2736
2777
|
return;
|
|
2737
2778
|
}
|
|
2738
2779
|
const { name } = declarator.id;
|
|
@@ -2773,11 +2814,11 @@ var noMisleadingConstantCase = createRule35({
|
|
|
2773
2814
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2774
2815
|
|
|
2775
2816
|
// src/rules/no-nested-interface-declaration.ts
|
|
2776
|
-
var
|
|
2777
|
-
var
|
|
2817
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
2818
|
+
var createRule37 = import_utils39.ESLintUtils.RuleCreator(
|
|
2778
2819
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2779
2820
|
);
|
|
2780
|
-
var noNestedInterfaceDeclaration =
|
|
2821
|
+
var noNestedInterfaceDeclaration = createRule37({
|
|
2781
2822
|
name: "no-nested-interface-declaration",
|
|
2782
2823
|
meta: {
|
|
2783
2824
|
type: "suggestion",
|
|
@@ -2798,15 +2839,15 @@ var noNestedInterfaceDeclaration = createRule36({
|
|
|
2798
2839
|
return;
|
|
2799
2840
|
}
|
|
2800
2841
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2801
|
-
if (typeAnnotation.type ===
|
|
2842
|
+
if (typeAnnotation.type === import_utils39.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2802
2843
|
context.report({
|
|
2803
2844
|
node: typeAnnotation,
|
|
2804
2845
|
messageId: "noNestedInterface"
|
|
2805
2846
|
});
|
|
2806
2847
|
return;
|
|
2807
2848
|
}
|
|
2808
|
-
if (typeAnnotation.type ===
|
|
2809
|
-
if (typeAnnotation.elementType.type ===
|
|
2849
|
+
if (typeAnnotation.type === import_utils39.AST_NODE_TYPES.TSArrayType) {
|
|
2850
|
+
if (typeAnnotation.elementType.type === import_utils39.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2810
2851
|
context.report({
|
|
2811
2852
|
node: typeAnnotation.elementType,
|
|
2812
2853
|
messageId: "noNestedInterface"
|
|
@@ -2814,9 +2855,9 @@ var noNestedInterfaceDeclaration = createRule36({
|
|
|
2814
2855
|
}
|
|
2815
2856
|
return;
|
|
2816
2857
|
}
|
|
2817
|
-
if (typeAnnotation.type ===
|
|
2858
|
+
if (typeAnnotation.type === import_utils39.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2818
2859
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2819
|
-
if (param.type ===
|
|
2860
|
+
if (param.type === import_utils39.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2820
2861
|
context.report({
|
|
2821
2862
|
node: param,
|
|
2822
2863
|
messageId: "noNestedInterface"
|
|
@@ -2831,11 +2872,11 @@ var noNestedInterfaceDeclaration = createRule36({
|
|
|
2831
2872
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2832
2873
|
|
|
2833
2874
|
// src/rules/no-nested-ternary.ts
|
|
2834
|
-
var
|
|
2835
|
-
var
|
|
2875
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
2876
|
+
var createRule38 = import_utils40.ESLintUtils.RuleCreator(
|
|
2836
2877
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2837
2878
|
);
|
|
2838
|
-
var noNestedTernary =
|
|
2879
|
+
var noNestedTernary = createRule38({
|
|
2839
2880
|
name: "no-nested-ternary",
|
|
2840
2881
|
meta: {
|
|
2841
2882
|
type: "suggestion",
|
|
@@ -2852,13 +2893,13 @@ var noNestedTernary = createRule37({
|
|
|
2852
2893
|
return {
|
|
2853
2894
|
ConditionalExpression(node) {
|
|
2854
2895
|
const { consequent, alternate } = node;
|
|
2855
|
-
if (consequent.type ===
|
|
2896
|
+
if (consequent.type === import_utils40.AST_NODE_TYPES.ConditionalExpression) {
|
|
2856
2897
|
context.report({
|
|
2857
2898
|
node: consequent,
|
|
2858
2899
|
messageId: "noNestedTernary"
|
|
2859
2900
|
});
|
|
2860
2901
|
}
|
|
2861
|
-
if (alternate.type ===
|
|
2902
|
+
if (alternate.type === import_utils40.AST_NODE_TYPES.ConditionalExpression) {
|
|
2862
2903
|
context.report({
|
|
2863
2904
|
node: alternate,
|
|
2864
2905
|
messageId: "noNestedTernary"
|
|
@@ -2871,11 +2912,11 @@ var noNestedTernary = createRule37({
|
|
|
2871
2912
|
var no_nested_ternary_default = noNestedTernary;
|
|
2872
2913
|
|
|
2873
2914
|
// src/rules/no-relative-imports.ts
|
|
2874
|
-
var
|
|
2875
|
-
var
|
|
2915
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
2916
|
+
var createRule39 = import_utils41.ESLintUtils.RuleCreator(
|
|
2876
2917
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2877
2918
|
);
|
|
2878
|
-
var noRelativeImports =
|
|
2919
|
+
var noRelativeImports = createRule39({
|
|
2879
2920
|
name: "no-relative-imports",
|
|
2880
2921
|
meta: {
|
|
2881
2922
|
type: "suggestion",
|
|
@@ -2899,22 +2940,22 @@ var noRelativeImports = createRule38({
|
|
|
2899
2940
|
};
|
|
2900
2941
|
return {
|
|
2901
2942
|
ImportDeclaration(node) {
|
|
2902
|
-
if (node.source.type ===
|
|
2943
|
+
if (node.source.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2903
2944
|
checkImportPath(node.source.value, node);
|
|
2904
2945
|
}
|
|
2905
2946
|
},
|
|
2906
2947
|
ImportExpression(node) {
|
|
2907
|
-
if (node.source.type ===
|
|
2948
|
+
if (node.source.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2908
2949
|
checkImportPath(node.source.value, node);
|
|
2909
2950
|
}
|
|
2910
2951
|
},
|
|
2911
2952
|
ExportNamedDeclaration(node) {
|
|
2912
|
-
if (node.source?.type ===
|
|
2953
|
+
if (node.source?.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2913
2954
|
checkImportPath(node.source.value, node);
|
|
2914
2955
|
}
|
|
2915
2956
|
},
|
|
2916
2957
|
ExportAllDeclaration(node) {
|
|
2917
|
-
if (node.source.type ===
|
|
2958
|
+
if (node.source.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2918
2959
|
checkImportPath(node.source.value, node);
|
|
2919
2960
|
}
|
|
2920
2961
|
}
|
|
@@ -2924,8 +2965,8 @@ var noRelativeImports = createRule38({
|
|
|
2924
2965
|
var no_relative_imports_default = noRelativeImports;
|
|
2925
2966
|
|
|
2926
2967
|
// src/rules/no-single-char-variables.ts
|
|
2927
|
-
var
|
|
2928
|
-
var
|
|
2968
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
2969
|
+
var createRule40 = import_utils42.ESLintUtils.RuleCreator(
|
|
2929
2970
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2930
2971
|
);
|
|
2931
2972
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -2937,7 +2978,7 @@ var isForLoopInit = (node) => {
|
|
|
2937
2978
|
if (!parentNode) {
|
|
2938
2979
|
return false;
|
|
2939
2980
|
}
|
|
2940
|
-
if (parentNode.type ===
|
|
2981
|
+
if (parentNode.type === import_utils42.AST_NODE_TYPES.ForStatement) {
|
|
2941
2982
|
const { init } = parentNode;
|
|
2942
2983
|
if (init && init === current) {
|
|
2943
2984
|
return true;
|
|
@@ -2956,7 +2997,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
2956
2997
|
}
|
|
2957
2998
|
return false;
|
|
2958
2999
|
};
|
|
2959
|
-
var noSingleCharVariables =
|
|
3000
|
+
var noSingleCharVariables = createRule40({
|
|
2960
3001
|
name: "no-single-char-variables",
|
|
2961
3002
|
meta: {
|
|
2962
3003
|
type: "suggestion",
|
|
@@ -2985,27 +3026,27 @@ var noSingleCharVariables = createRule39({
|
|
|
2985
3026
|
});
|
|
2986
3027
|
};
|
|
2987
3028
|
const checkPattern = (pattern, declarationNode) => {
|
|
2988
|
-
if (pattern.type ===
|
|
3029
|
+
if (pattern.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
2989
3030
|
checkIdentifier(pattern, declarationNode);
|
|
2990
|
-
} else if (pattern.type ===
|
|
3031
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.ObjectPattern) {
|
|
2991
3032
|
pattern.properties.forEach((prop) => {
|
|
2992
|
-
if (prop.type ===
|
|
3033
|
+
if (prop.type === import_utils42.AST_NODE_TYPES.Property && prop.value.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
2993
3034
|
checkIdentifier(prop.value, declarationNode);
|
|
2994
|
-
} else if (prop.type ===
|
|
3035
|
+
} else if (prop.type === import_utils42.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
2995
3036
|
checkIdentifier(prop.argument, declarationNode);
|
|
2996
3037
|
}
|
|
2997
3038
|
});
|
|
2998
|
-
} else if (pattern.type ===
|
|
3039
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.ArrayPattern) {
|
|
2999
3040
|
pattern.elements.forEach((element) => {
|
|
3000
|
-
if (element?.type ===
|
|
3041
|
+
if (element?.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3001
3042
|
checkIdentifier(element, declarationNode);
|
|
3002
|
-
} else if (element?.type ===
|
|
3043
|
+
} else if (element?.type === import_utils42.AST_NODE_TYPES.RestElement && element.argument.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3003
3044
|
checkIdentifier(element.argument, declarationNode);
|
|
3004
3045
|
}
|
|
3005
3046
|
});
|
|
3006
|
-
} else if (pattern.type ===
|
|
3047
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3007
3048
|
checkIdentifier(pattern.left, declarationNode);
|
|
3008
|
-
} else if (pattern.type ===
|
|
3049
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3009
3050
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3010
3051
|
}
|
|
3011
3052
|
};
|
|
@@ -3039,11 +3080,11 @@ var noSingleCharVariables = createRule39({
|
|
|
3039
3080
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3040
3081
|
|
|
3041
3082
|
// src/rules/prefer-async-await.ts
|
|
3042
|
-
var
|
|
3043
|
-
var
|
|
3083
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
3084
|
+
var createRule41 = import_utils43.ESLintUtils.RuleCreator(
|
|
3044
3085
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3045
3086
|
);
|
|
3046
|
-
var preferAsyncAwait =
|
|
3087
|
+
var preferAsyncAwait = createRule41({
|
|
3047
3088
|
name: "prefer-async-await",
|
|
3048
3089
|
meta: {
|
|
3049
3090
|
type: "suggestion",
|
|
@@ -3059,7 +3100,7 @@ var preferAsyncAwait = createRule40({
|
|
|
3059
3100
|
create(context) {
|
|
3060
3101
|
return {
|
|
3061
3102
|
CallExpression(node) {
|
|
3062
|
-
if (node.callee.type ===
|
|
3103
|
+
if (node.callee.type === import_utils43.AST_NODE_TYPES.MemberExpression && node.callee.property.type === import_utils43.AST_NODE_TYPES.Identifier && node.callee.property.name === "then") {
|
|
3063
3104
|
context.report({
|
|
3064
3105
|
node: node.callee.property,
|
|
3065
3106
|
messageId: "preferAsyncAwait"
|
|
@@ -3072,11 +3113,11 @@ var preferAsyncAwait = createRule40({
|
|
|
3072
3113
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3073
3114
|
|
|
3074
3115
|
// src/rules/prefer-destructuring-params.ts
|
|
3075
|
-
var
|
|
3076
|
-
var
|
|
3116
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
3117
|
+
var createRule42 = import_utils44.ESLintUtils.RuleCreator(
|
|
3077
3118
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3078
3119
|
);
|
|
3079
|
-
var preferDestructuringParams =
|
|
3120
|
+
var preferDestructuringParams = createRule42({
|
|
3080
3121
|
name: "prefer-destructuring-params",
|
|
3081
3122
|
meta: {
|
|
3082
3123
|
type: "suggestion",
|
|
@@ -3092,18 +3133,18 @@ var preferDestructuringParams = createRule41({
|
|
|
3092
3133
|
create(context) {
|
|
3093
3134
|
const isCallbackFunction2 = (node) => {
|
|
3094
3135
|
const { parent } = node;
|
|
3095
|
-
return parent?.type ===
|
|
3136
|
+
return parent?.type === import_utils44.AST_NODE_TYPES.CallExpression;
|
|
3096
3137
|
};
|
|
3097
3138
|
const isDeveloperFunction = (node) => {
|
|
3098
|
-
if (node.type ===
|
|
3139
|
+
if (node.type === import_utils44.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3099
3140
|
return true;
|
|
3100
3141
|
}
|
|
3101
|
-
if (node.type ===
|
|
3142
|
+
if (node.type === import_utils44.AST_NODE_TYPES.FunctionExpression || node.type === import_utils44.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3102
3143
|
if (isCallbackFunction2(node)) {
|
|
3103
3144
|
return false;
|
|
3104
3145
|
}
|
|
3105
3146
|
const { parent } = node;
|
|
3106
|
-
return parent?.type ===
|
|
3147
|
+
return parent?.type === import_utils44.AST_NODE_TYPES.VariableDeclarator || parent?.type === import_utils44.AST_NODE_TYPES.AssignmentExpression || parent?.type === import_utils44.AST_NODE_TYPES.Property || parent?.type === import_utils44.AST_NODE_TYPES.MethodDefinition;
|
|
3107
3148
|
}
|
|
3108
3149
|
return false;
|
|
3109
3150
|
};
|
|
@@ -3115,7 +3156,7 @@ var preferDestructuringParams = createRule41({
|
|
|
3115
3156
|
if (!isDeveloperFunction(node)) {
|
|
3116
3157
|
return;
|
|
3117
3158
|
}
|
|
3118
|
-
if (node.type ===
|
|
3159
|
+
if (node.type === import_utils44.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
3119
3160
|
const functionName = node.id.name;
|
|
3120
3161
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3121
3162
|
return;
|
|
@@ -3125,7 +3166,7 @@ var preferDestructuringParams = createRule41({
|
|
|
3125
3166
|
return;
|
|
3126
3167
|
}
|
|
3127
3168
|
const hasNonDestructuredParams = node.params.some(
|
|
3128
|
-
(param) => param.type !==
|
|
3169
|
+
(param) => param.type !== import_utils44.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils44.AST_NODE_TYPES.RestElement
|
|
3129
3170
|
);
|
|
3130
3171
|
if (hasNonDestructuredParams) {
|
|
3131
3172
|
context.report({
|
|
@@ -3144,8 +3185,8 @@ var preferDestructuringParams = createRule41({
|
|
|
3144
3185
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3145
3186
|
|
|
3146
3187
|
// src/rules/prefer-function-declaration.ts
|
|
3147
|
-
var
|
|
3148
|
-
var
|
|
3188
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
3189
|
+
var createRule43 = import_utils45.ESLintUtils.RuleCreator(
|
|
3149
3190
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3150
3191
|
);
|
|
3151
3192
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3154,33 +3195,33 @@ var isCallbackContext = (node) => {
|
|
|
3154
3195
|
if (!parent) {
|
|
3155
3196
|
return false;
|
|
3156
3197
|
}
|
|
3157
|
-
if (parent.type ===
|
|
3198
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
3158
3199
|
return true;
|
|
3159
3200
|
}
|
|
3160
|
-
if (parent.type ===
|
|
3201
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
3161
3202
|
return true;
|
|
3162
3203
|
}
|
|
3163
|
-
if (parent.type ===
|
|
3204
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ReturnStatement) {
|
|
3164
3205
|
return true;
|
|
3165
3206
|
}
|
|
3166
|
-
if (parent.type ===
|
|
3207
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.Property) {
|
|
3167
3208
|
return true;
|
|
3168
3209
|
}
|
|
3169
|
-
if (parent.type ===
|
|
3210
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ArrayExpression) {
|
|
3170
3211
|
return true;
|
|
3171
3212
|
}
|
|
3172
|
-
if (parent.type ===
|
|
3213
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ConditionalExpression) {
|
|
3173
3214
|
return true;
|
|
3174
3215
|
}
|
|
3175
|
-
if (parent.type ===
|
|
3216
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.LogicalExpression) {
|
|
3176
3217
|
return true;
|
|
3177
3218
|
}
|
|
3178
|
-
if (parent.type ===
|
|
3219
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
3179
3220
|
return true;
|
|
3180
3221
|
}
|
|
3181
3222
|
return false;
|
|
3182
3223
|
};
|
|
3183
|
-
var preferFunctionDeclaration =
|
|
3224
|
+
var preferFunctionDeclaration = createRule43({
|
|
3184
3225
|
name: "prefer-function-declaration",
|
|
3185
3226
|
meta: {
|
|
3186
3227
|
type: "suggestion",
|
|
@@ -3201,14 +3242,14 @@ var preferFunctionDeclaration = createRule42({
|
|
|
3201
3242
|
}
|
|
3202
3243
|
return {
|
|
3203
3244
|
VariableDeclarator(node) {
|
|
3204
|
-
if (node.id.type !==
|
|
3245
|
+
if (node.id.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
3205
3246
|
return;
|
|
3206
3247
|
}
|
|
3207
3248
|
const { init } = node;
|
|
3208
3249
|
if (!init) {
|
|
3209
3250
|
return;
|
|
3210
3251
|
}
|
|
3211
|
-
if (init.type ===
|
|
3252
|
+
if (init.type === import_utils45.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3212
3253
|
if (isCallbackContext(init)) {
|
|
3213
3254
|
return;
|
|
3214
3255
|
}
|
|
@@ -3218,7 +3259,7 @@ var preferFunctionDeclaration = createRule42({
|
|
|
3218
3259
|
data: { name: node.id.name }
|
|
3219
3260
|
});
|
|
3220
3261
|
}
|
|
3221
|
-
if (init.type ===
|
|
3262
|
+
if (init.type === import_utils45.AST_NODE_TYPES.FunctionExpression) {
|
|
3222
3263
|
if (isCallbackContext(init)) {
|
|
3223
3264
|
return;
|
|
3224
3265
|
}
|
|
@@ -3235,11 +3276,11 @@ var preferFunctionDeclaration = createRule42({
|
|
|
3235
3276
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3236
3277
|
|
|
3237
3278
|
// src/rules/prefer-guard-clause.ts
|
|
3238
|
-
var
|
|
3239
|
-
var
|
|
3279
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
3280
|
+
var createRule44 = import_utils46.ESLintUtils.RuleCreator(
|
|
3240
3281
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3241
3282
|
);
|
|
3242
|
-
var preferGuardClause =
|
|
3283
|
+
var preferGuardClause = createRule44({
|
|
3243
3284
|
name: "prefer-guard-clause",
|
|
3244
3285
|
meta: {
|
|
3245
3286
|
type: "suggestion",
|
|
@@ -3256,8 +3297,8 @@ var preferGuardClause = createRule43({
|
|
|
3256
3297
|
return {
|
|
3257
3298
|
IfStatement(node) {
|
|
3258
3299
|
const { consequent } = node;
|
|
3259
|
-
if (consequent.type ===
|
|
3260
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3300
|
+
if (consequent.type === import_utils46.AST_NODE_TYPES.BlockStatement) {
|
|
3301
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === import_utils46.AST_NODE_TYPES.IfStatement);
|
|
3261
3302
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3262
3303
|
context.report({
|
|
3263
3304
|
node,
|
|
@@ -3265,7 +3306,7 @@ var preferGuardClause = createRule43({
|
|
|
3265
3306
|
});
|
|
3266
3307
|
}
|
|
3267
3308
|
}
|
|
3268
|
-
if (consequent.type ===
|
|
3309
|
+
if (consequent.type === import_utils46.AST_NODE_TYPES.IfStatement) {
|
|
3269
3310
|
context.report({
|
|
3270
3311
|
node,
|
|
3271
3312
|
messageId: "preferGuardClause"
|
|
@@ -3278,11 +3319,11 @@ var preferGuardClause = createRule43({
|
|
|
3278
3319
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3279
3320
|
|
|
3280
3321
|
// src/rules/prefer-import-type.ts
|
|
3281
|
-
var
|
|
3282
|
-
var
|
|
3322
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
3323
|
+
var createRule45 = import_utils47.ESLintUtils.RuleCreator(
|
|
3283
3324
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3284
3325
|
);
|
|
3285
|
-
var preferImportType =
|
|
3326
|
+
var preferImportType = createRule45({
|
|
3286
3327
|
name: "prefer-import-type",
|
|
3287
3328
|
meta: {
|
|
3288
3329
|
type: "suggestion",
|
|
@@ -3301,22 +3342,22 @@ var preferImportType = createRule44({
|
|
|
3301
3342
|
let current = node;
|
|
3302
3343
|
while (current) {
|
|
3303
3344
|
switch (current.type) {
|
|
3304
|
-
case
|
|
3305
|
-
case
|
|
3306
|
-
case
|
|
3307
|
-
case
|
|
3308
|
-
case
|
|
3309
|
-
case
|
|
3310
|
-
case
|
|
3311
|
-
case
|
|
3312
|
-
case
|
|
3313
|
-
case
|
|
3314
|
-
case
|
|
3315
|
-
case
|
|
3316
|
-
case
|
|
3345
|
+
case import_utils47.AST_NODE_TYPES.TSTypeReference:
|
|
3346
|
+
case import_utils47.AST_NODE_TYPES.TSTypeAnnotation:
|
|
3347
|
+
case import_utils47.AST_NODE_TYPES.TSTypeParameterInstantiation:
|
|
3348
|
+
case import_utils47.AST_NODE_TYPES.TSInterfaceHeritage:
|
|
3349
|
+
case import_utils47.AST_NODE_TYPES.TSClassImplements:
|
|
3350
|
+
case import_utils47.AST_NODE_TYPES.TSTypeQuery:
|
|
3351
|
+
case import_utils47.AST_NODE_TYPES.TSTypeAssertion:
|
|
3352
|
+
case import_utils47.AST_NODE_TYPES.TSAsExpression:
|
|
3353
|
+
case import_utils47.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
3354
|
+
case import_utils47.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3355
|
+
case import_utils47.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3356
|
+
case import_utils47.AST_NODE_TYPES.TSTypeParameter:
|
|
3357
|
+
case import_utils47.AST_NODE_TYPES.TSQualifiedName:
|
|
3317
3358
|
return true;
|
|
3318
|
-
case
|
|
3319
|
-
case
|
|
3359
|
+
case import_utils47.AST_NODE_TYPES.MemberExpression:
|
|
3360
|
+
case import_utils47.AST_NODE_TYPES.Identifier:
|
|
3320
3361
|
current = current.parent;
|
|
3321
3362
|
break;
|
|
3322
3363
|
default:
|
|
@@ -3346,27 +3387,27 @@ var preferImportType = createRule44({
|
|
|
3346
3387
|
return false;
|
|
3347
3388
|
}
|
|
3348
3389
|
switch (parent.type) {
|
|
3349
|
-
case
|
|
3350
|
-
case
|
|
3351
|
-
case
|
|
3352
|
-
case
|
|
3353
|
-
case
|
|
3354
|
-
case
|
|
3355
|
-
case
|
|
3356
|
-
case
|
|
3357
|
-
case
|
|
3358
|
-
case
|
|
3359
|
-
case
|
|
3360
|
-
case
|
|
3361
|
-
case
|
|
3362
|
-
case
|
|
3363
|
-
case
|
|
3364
|
-
case
|
|
3365
|
-
case
|
|
3366
|
-
case
|
|
3367
|
-
case
|
|
3368
|
-
case
|
|
3369
|
-
case
|
|
3390
|
+
case import_utils47.AST_NODE_TYPES.CallExpression:
|
|
3391
|
+
case import_utils47.AST_NODE_TYPES.NewExpression:
|
|
3392
|
+
case import_utils47.AST_NODE_TYPES.JSXOpeningElement:
|
|
3393
|
+
case import_utils47.AST_NODE_TYPES.JSXClosingElement:
|
|
3394
|
+
case import_utils47.AST_NODE_TYPES.MemberExpression:
|
|
3395
|
+
case import_utils47.AST_NODE_TYPES.VariableDeclarator:
|
|
3396
|
+
case import_utils47.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
3397
|
+
case import_utils47.AST_NODE_TYPES.SpreadElement:
|
|
3398
|
+
case import_utils47.AST_NODE_TYPES.ExportSpecifier:
|
|
3399
|
+
case import_utils47.AST_NODE_TYPES.ArrayExpression:
|
|
3400
|
+
case import_utils47.AST_NODE_TYPES.ObjectExpression:
|
|
3401
|
+
case import_utils47.AST_NODE_TYPES.BinaryExpression:
|
|
3402
|
+
case import_utils47.AST_NODE_TYPES.LogicalExpression:
|
|
3403
|
+
case import_utils47.AST_NODE_TYPES.UnaryExpression:
|
|
3404
|
+
case import_utils47.AST_NODE_TYPES.ReturnStatement:
|
|
3405
|
+
case import_utils47.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
3406
|
+
case import_utils47.AST_NODE_TYPES.ConditionalExpression:
|
|
3407
|
+
case import_utils47.AST_NODE_TYPES.AwaitExpression:
|
|
3408
|
+
case import_utils47.AST_NODE_TYPES.YieldExpression:
|
|
3409
|
+
case import_utils47.AST_NODE_TYPES.Property:
|
|
3410
|
+
case import_utils47.AST_NODE_TYPES.JSXExpressionContainer:
|
|
3370
3411
|
return true;
|
|
3371
3412
|
default:
|
|
3372
3413
|
return false;
|
|
@@ -3390,13 +3431,13 @@ var preferImportType = createRule44({
|
|
|
3390
3431
|
}
|
|
3391
3432
|
const scope = context.sourceCode.getScope(node);
|
|
3392
3433
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3393
|
-
if (specifier.type ===
|
|
3434
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
3394
3435
|
return false;
|
|
3395
3436
|
}
|
|
3396
|
-
if (specifier.type ===
|
|
3437
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
3397
3438
|
return false;
|
|
3398
3439
|
}
|
|
3399
|
-
if (specifier.type ===
|
|
3440
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportSpecifier) {
|
|
3400
3441
|
const localName = specifier.local.name;
|
|
3401
3442
|
return !isUsedAsValue(localName, scope);
|
|
3402
3443
|
}
|
|
@@ -3422,19 +3463,19 @@ var preferImportType = createRule44({
|
|
|
3422
3463
|
var prefer_import_type_default = preferImportType;
|
|
3423
3464
|
|
|
3424
3465
|
// src/rules/prefer-inline-literal-union.ts
|
|
3425
|
-
var
|
|
3426
|
-
var
|
|
3466
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
3467
|
+
var createRule46 = import_utils48.ESLintUtils.RuleCreator(
|
|
3427
3468
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3428
3469
|
);
|
|
3429
3470
|
function isLiteralUnionType(node) {
|
|
3430
|
-
if (node.type !==
|
|
3471
|
+
if (node.type !== import_utils48.AST_NODE_TYPES.TSUnionType) {
|
|
3431
3472
|
return false;
|
|
3432
3473
|
}
|
|
3433
3474
|
return node.types.every(
|
|
3434
|
-
(member) => member.type ===
|
|
3475
|
+
(member) => member.type === import_utils48.AST_NODE_TYPES.TSLiteralType || member.type === import_utils48.AST_NODE_TYPES.TSNullKeyword || member.type === import_utils48.AST_NODE_TYPES.TSUndefinedKeyword
|
|
3435
3476
|
);
|
|
3436
3477
|
}
|
|
3437
|
-
var preferInlineLiteralUnion =
|
|
3478
|
+
var preferInlineLiteralUnion = createRule46({
|
|
3438
3479
|
name: "prefer-inline-literal-union",
|
|
3439
3480
|
meta: {
|
|
3440
3481
|
type: "suggestion",
|
|
@@ -3461,10 +3502,10 @@ var preferInlineLiteralUnion = createRule45({
|
|
|
3461
3502
|
return;
|
|
3462
3503
|
}
|
|
3463
3504
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3464
|
-
if (typeAnnotation.type !==
|
|
3505
|
+
if (typeAnnotation.type !== import_utils48.AST_NODE_TYPES.TSTypeReference) {
|
|
3465
3506
|
return;
|
|
3466
3507
|
}
|
|
3467
|
-
if (typeAnnotation.typeName.type !==
|
|
3508
|
+
if (typeAnnotation.typeName.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
3468
3509
|
return;
|
|
3469
3510
|
}
|
|
3470
3511
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3488,12 +3529,12 @@ var preferInlineLiteralUnion = createRule45({
|
|
|
3488
3529
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3489
3530
|
|
|
3490
3531
|
// src/rules/prefer-inline-type-export.ts
|
|
3491
|
-
var
|
|
3492
|
-
var
|
|
3532
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
3533
|
+
var createRule47 = import_utils49.ESLintUtils.RuleCreator(
|
|
3493
3534
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3494
3535
|
);
|
|
3495
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3496
|
-
var preferInlineTypeExport =
|
|
3536
|
+
var isTypeDeclaration = (node) => node.type === import_utils49.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === import_utils49.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
3537
|
+
var preferInlineTypeExport = createRule47({
|
|
3497
3538
|
name: "prefer-inline-type-export",
|
|
3498
3539
|
meta: {
|
|
3499
3540
|
type: "suggestion",
|
|
@@ -3510,12 +3551,12 @@ var preferInlineTypeExport = createRule46({
|
|
|
3510
3551
|
create(context) {
|
|
3511
3552
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3512
3553
|
function collectDeclaration(node) {
|
|
3513
|
-
if (node.parent.type !==
|
|
3554
|
+
if (node.parent.type !== import_utils49.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
3514
3555
|
typeDeclarations.set(node.id.name, node);
|
|
3515
3556
|
}
|
|
3516
3557
|
}
|
|
3517
3558
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3518
|
-
if (specifier.local.type !==
|
|
3559
|
+
if (specifier.local.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
3519
3560
|
return;
|
|
3520
3561
|
}
|
|
3521
3562
|
const { name } = specifier.local;
|
|
@@ -3548,16 +3589,16 @@ var preferInlineTypeExport = createRule46({
|
|
|
3548
3589
|
return {
|
|
3549
3590
|
Program(node) {
|
|
3550
3591
|
node.body.forEach((statement) => {
|
|
3551
|
-
if (statement.type ===
|
|
3592
|
+
if (statement.type === import_utils49.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === import_utils49.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
3552
3593
|
collectDeclaration(statement);
|
|
3553
3594
|
}
|
|
3554
3595
|
});
|
|
3555
3596
|
node.body.forEach((statement) => {
|
|
3556
|
-
if (statement.type !==
|
|
3597
|
+
if (statement.type !== import_utils49.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3557
3598
|
return;
|
|
3558
3599
|
}
|
|
3559
3600
|
statement.specifiers.forEach((specifier) => {
|
|
3560
|
-
if (specifier.local.type !==
|
|
3601
|
+
if (specifier.local.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
3561
3602
|
return;
|
|
3562
3603
|
}
|
|
3563
3604
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3574,11 +3615,11 @@ var preferInlineTypeExport = createRule46({
|
|
|
3574
3615
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3575
3616
|
|
|
3576
3617
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3577
|
-
var
|
|
3578
|
-
var
|
|
3618
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
3619
|
+
var createRule48 = import_utils50.ESLintUtils.RuleCreator(
|
|
3579
3620
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3580
3621
|
);
|
|
3581
|
-
var preferInterfaceOverInlineTypes =
|
|
3622
|
+
var preferInterfaceOverInlineTypes = createRule48({
|
|
3582
3623
|
name: "prefer-interface-over-inline-types",
|
|
3583
3624
|
meta: {
|
|
3584
3625
|
type: "suggestion",
|
|
@@ -3594,54 +3635,54 @@ var preferInterfaceOverInlineTypes = createRule47({
|
|
|
3594
3635
|
defaultOptions: [],
|
|
3595
3636
|
create(context) {
|
|
3596
3637
|
function hasJSXInConditional(node) {
|
|
3597
|
-
return node.consequent.type ===
|
|
3638
|
+
return node.consequent.type === import_utils50.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils50.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils50.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils50.AST_NODE_TYPES.JSXFragment;
|
|
3598
3639
|
}
|
|
3599
3640
|
function hasJSXInLogical(node) {
|
|
3600
|
-
return node.right.type ===
|
|
3641
|
+
return node.right.type === import_utils50.AST_NODE_TYPES.JSXElement || node.right.type === import_utils50.AST_NODE_TYPES.JSXFragment;
|
|
3601
3642
|
}
|
|
3602
3643
|
function hasJSXReturn(block) {
|
|
3603
3644
|
return block.body.some((stmt) => {
|
|
3604
|
-
if (stmt.type ===
|
|
3605
|
-
return stmt.argument.type ===
|
|
3645
|
+
if (stmt.type === import_utils50.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
3646
|
+
return stmt.argument.type === import_utils50.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils50.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils50.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils50.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
3606
3647
|
}
|
|
3607
3648
|
return false;
|
|
3608
3649
|
});
|
|
3609
3650
|
}
|
|
3610
3651
|
function isReactComponent2(node) {
|
|
3611
|
-
if (node.type ===
|
|
3612
|
-
if (node.body.type ===
|
|
3652
|
+
if (node.type === import_utils50.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3653
|
+
if (node.body.type === import_utils50.AST_NODE_TYPES.JSXElement || node.body.type === import_utils50.AST_NODE_TYPES.JSXFragment) {
|
|
3613
3654
|
return true;
|
|
3614
3655
|
}
|
|
3615
|
-
if (node.body.type ===
|
|
3656
|
+
if (node.body.type === import_utils50.AST_NODE_TYPES.BlockStatement) {
|
|
3616
3657
|
return hasJSXReturn(node.body);
|
|
3617
3658
|
}
|
|
3618
|
-
} else if (node.type ===
|
|
3619
|
-
if (node.body && node.body.type ===
|
|
3659
|
+
} else if (node.type === import_utils50.AST_NODE_TYPES.FunctionExpression || node.type === import_utils50.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3660
|
+
if (node.body && node.body.type === import_utils50.AST_NODE_TYPES.BlockStatement) {
|
|
3620
3661
|
return hasJSXReturn(node.body);
|
|
3621
3662
|
}
|
|
3622
3663
|
}
|
|
3623
3664
|
return false;
|
|
3624
3665
|
}
|
|
3625
3666
|
function isInlineTypeAnnotation(node) {
|
|
3626
|
-
if (node.type ===
|
|
3667
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3627
3668
|
return true;
|
|
3628
3669
|
}
|
|
3629
|
-
if (node.type ===
|
|
3630
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3670
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3671
|
+
return node.typeArguments.params.some((param) => param.type === import_utils50.AST_NODE_TYPES.TSTypeLiteral);
|
|
3631
3672
|
}
|
|
3632
|
-
if (node.type ===
|
|
3673
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TSUnionType) {
|
|
3633
3674
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3634
3675
|
}
|
|
3635
3676
|
return false;
|
|
3636
3677
|
}
|
|
3637
3678
|
function hasInlineObjectType(node) {
|
|
3638
|
-
if (node.type ===
|
|
3679
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3639
3680
|
return true;
|
|
3640
3681
|
}
|
|
3641
|
-
if (node.type ===
|
|
3642
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3682
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3683
|
+
return node.typeArguments.params.some((param) => param.type === import_utils50.AST_NODE_TYPES.TSTypeLiteral);
|
|
3643
3684
|
}
|
|
3644
|
-
if (node.type ===
|
|
3685
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TSUnionType) {
|
|
3645
3686
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3646
3687
|
}
|
|
3647
3688
|
return false;
|
|
@@ -3654,7 +3695,7 @@ var preferInterfaceOverInlineTypes = createRule47({
|
|
|
3654
3695
|
return;
|
|
3655
3696
|
}
|
|
3656
3697
|
const param = node.params[0];
|
|
3657
|
-
if (param.type ===
|
|
3698
|
+
if (param.type === import_utils50.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
3658
3699
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3659
3700
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3660
3701
|
context.report({
|
|
@@ -3674,11 +3715,11 @@ var preferInterfaceOverInlineTypes = createRule47({
|
|
|
3674
3715
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3675
3716
|
|
|
3676
3717
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3677
|
-
var
|
|
3678
|
-
var
|
|
3718
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
3719
|
+
var createRule49 = import_utils51.ESLintUtils.RuleCreator(
|
|
3679
3720
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3680
3721
|
);
|
|
3681
|
-
var preferJSXTemplateLiterals =
|
|
3722
|
+
var preferJSXTemplateLiterals = createRule49({
|
|
3682
3723
|
name: "prefer-jsx-template-literals",
|
|
3683
3724
|
meta: {
|
|
3684
3725
|
type: "suggestion",
|
|
@@ -3747,9 +3788,9 @@ var preferJSXTemplateLiterals = createRule48({
|
|
|
3747
3788
|
if (!child || !nextChild) {
|
|
3748
3789
|
return;
|
|
3749
3790
|
}
|
|
3750
|
-
if (child.type ===
|
|
3791
|
+
if (child.type === import_utils51.AST_NODE_TYPES.JSXText && nextChild.type === import_utils51.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
3751
3792
|
handleTextBeforeExpression(child, nextChild);
|
|
3752
|
-
} else if (child.type ===
|
|
3793
|
+
} else if (child.type === import_utils51.AST_NODE_TYPES.JSXExpressionContainer && nextChild.type === import_utils51.AST_NODE_TYPES.JSXText) {
|
|
3753
3794
|
handleExpressionBeforeText(child, nextChild);
|
|
3754
3795
|
}
|
|
3755
3796
|
}
|
|
@@ -3762,11 +3803,11 @@ var preferJSXTemplateLiterals = createRule48({
|
|
|
3762
3803
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3763
3804
|
|
|
3764
3805
|
// src/rules/prefer-named-param-types.ts
|
|
3765
|
-
var
|
|
3766
|
-
var
|
|
3806
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
3807
|
+
var createRule50 = import_utils52.ESLintUtils.RuleCreator(
|
|
3767
3808
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3768
3809
|
);
|
|
3769
|
-
var preferNamedParamTypes =
|
|
3810
|
+
var preferNamedParamTypes = createRule50({
|
|
3770
3811
|
name: "prefer-named-param-types",
|
|
3771
3812
|
meta: {
|
|
3772
3813
|
type: "suggestion",
|
|
@@ -3781,16 +3822,16 @@ var preferNamedParamTypes = createRule49({
|
|
|
3781
3822
|
defaultOptions: [],
|
|
3782
3823
|
create(context) {
|
|
3783
3824
|
function hasInlineObjectType(param) {
|
|
3784
|
-
if (param.type ===
|
|
3825
|
+
if (param.type === import_utils52.AST_NODE_TYPES.AssignmentPattern) {
|
|
3785
3826
|
return hasInlineObjectType(param.left);
|
|
3786
3827
|
}
|
|
3787
|
-
if (param.type ===
|
|
3788
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3828
|
+
if (param.type === import_utils52.AST_NODE_TYPES.ObjectPattern) {
|
|
3829
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils52.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3789
3830
|
return true;
|
|
3790
3831
|
}
|
|
3791
3832
|
}
|
|
3792
|
-
if (param.type ===
|
|
3793
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3833
|
+
if (param.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3834
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils52.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3794
3835
|
return true;
|
|
3795
3836
|
}
|
|
3796
3837
|
}
|
|
@@ -3824,11 +3865,11 @@ var preferNamedParamTypes = createRule49({
|
|
|
3824
3865
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3825
3866
|
|
|
3826
3867
|
// src/rules/prefer-react-import-types.ts
|
|
3827
|
-
var
|
|
3828
|
-
var
|
|
3868
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
3869
|
+
var createRule51 = import_utils53.ESLintUtils.RuleCreator(
|
|
3829
3870
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3830
3871
|
);
|
|
3831
|
-
var preferReactImportTypes =
|
|
3872
|
+
var preferReactImportTypes = createRule51({
|
|
3832
3873
|
name: "prefer-react-import-types",
|
|
3833
3874
|
meta: {
|
|
3834
3875
|
type: "suggestion",
|
|
@@ -3904,7 +3945,7 @@ var preferReactImportTypes = createRule50({
|
|
|
3904
3945
|
]);
|
|
3905
3946
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
3906
3947
|
function checkMemberExpression(node) {
|
|
3907
|
-
if (node.object.type ===
|
|
3948
|
+
if (node.object.type === import_utils53.AST_NODE_TYPES.Identifier && node.object.name === "React" && node.property.type === import_utils53.AST_NODE_TYPES.Identifier && allReactExports.has(node.property.name)) {
|
|
3908
3949
|
const typeName = node.property.name;
|
|
3909
3950
|
const isType = reactTypes.has(typeName);
|
|
3910
3951
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -3921,7 +3962,7 @@ var preferReactImportTypes = createRule50({
|
|
|
3921
3962
|
return {
|
|
3922
3963
|
MemberExpression: checkMemberExpression,
|
|
3923
3964
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
3924
|
-
if (node.left.type ===
|
|
3965
|
+
if (node.left.type === import_utils53.AST_NODE_TYPES.Identifier && node.left.name === "React" && node.right.type === import_utils53.AST_NODE_TYPES.Identifier && allReactExports.has(node.right.name)) {
|
|
3925
3966
|
const typeName = node.right.name;
|
|
3926
3967
|
const isType = reactTypes.has(typeName);
|
|
3927
3968
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -3941,11 +3982,11 @@ var preferReactImportTypes = createRule50({
|
|
|
3941
3982
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
3942
3983
|
|
|
3943
3984
|
// src/rules/react-props-destructure.ts
|
|
3944
|
-
var
|
|
3945
|
-
var
|
|
3985
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
3986
|
+
var createRule52 = import_utils54.ESLintUtils.RuleCreator(
|
|
3946
3987
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3947
3988
|
);
|
|
3948
|
-
var reactPropsDestructure =
|
|
3989
|
+
var reactPropsDestructure = createRule52({
|
|
3949
3990
|
name: "react-props-destructure",
|
|
3950
3991
|
meta: {
|
|
3951
3992
|
type: "suggestion",
|
|
@@ -3961,29 +4002,29 @@ var reactPropsDestructure = createRule51({
|
|
|
3961
4002
|
defaultOptions: [],
|
|
3962
4003
|
create(context) {
|
|
3963
4004
|
function hasJSXInConditional(node) {
|
|
3964
|
-
return node.consequent.type ===
|
|
4005
|
+
return node.consequent.type === import_utils54.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils54.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils54.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils54.AST_NODE_TYPES.JSXFragment;
|
|
3965
4006
|
}
|
|
3966
4007
|
function hasJSXInLogical(node) {
|
|
3967
|
-
return node.right.type ===
|
|
4008
|
+
return node.right.type === import_utils54.AST_NODE_TYPES.JSXElement || node.right.type === import_utils54.AST_NODE_TYPES.JSXFragment;
|
|
3968
4009
|
}
|
|
3969
4010
|
function hasJSXReturn(block) {
|
|
3970
4011
|
return block.body.some((stmt) => {
|
|
3971
|
-
if (stmt.type ===
|
|
3972
|
-
return stmt.argument.type ===
|
|
4012
|
+
if (stmt.type === import_utils54.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
4013
|
+
return stmt.argument.type === import_utils54.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils54.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils54.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils54.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
3973
4014
|
}
|
|
3974
4015
|
return false;
|
|
3975
4016
|
});
|
|
3976
4017
|
}
|
|
3977
4018
|
function isReactComponent2(node) {
|
|
3978
|
-
if (node.type ===
|
|
3979
|
-
if (node.body.type ===
|
|
4019
|
+
if (node.type === import_utils54.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4020
|
+
if (node.body.type === import_utils54.AST_NODE_TYPES.JSXElement || node.body.type === import_utils54.AST_NODE_TYPES.JSXFragment) {
|
|
3980
4021
|
return true;
|
|
3981
4022
|
}
|
|
3982
|
-
if (node.body.type ===
|
|
4023
|
+
if (node.body.type === import_utils54.AST_NODE_TYPES.BlockStatement) {
|
|
3983
4024
|
return hasJSXReturn(node.body);
|
|
3984
4025
|
}
|
|
3985
|
-
} else if (node.type ===
|
|
3986
|
-
if (node.body && node.body.type ===
|
|
4026
|
+
} else if (node.type === import_utils54.AST_NODE_TYPES.FunctionExpression || node.type === import_utils54.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4027
|
+
if (node.body && node.body.type === import_utils54.AST_NODE_TYPES.BlockStatement) {
|
|
3987
4028
|
return hasJSXReturn(node.body);
|
|
3988
4029
|
}
|
|
3989
4030
|
}
|
|
@@ -3997,9 +4038,9 @@ var reactPropsDestructure = createRule51({
|
|
|
3997
4038
|
return;
|
|
3998
4039
|
}
|
|
3999
4040
|
const param = node.params[0];
|
|
4000
|
-
if (param.type ===
|
|
4001
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4002
|
-
if (prop.key.type ===
|
|
4041
|
+
if (param.type === import_utils54.AST_NODE_TYPES.ObjectPattern) {
|
|
4042
|
+
const properties = param.properties.filter((prop) => prop.type === import_utils54.AST_NODE_TYPES.Property).map((prop) => {
|
|
4043
|
+
if (prop.key.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
4003
4044
|
return prop.key.name;
|
|
4004
4045
|
}
|
|
4005
4046
|
return null;
|
|
@@ -4026,57 +4067,57 @@ var reactPropsDestructure = createRule51({
|
|
|
4026
4067
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4027
4068
|
|
|
4028
4069
|
// src/rules/require-explicit-return-type.ts
|
|
4029
|
-
var
|
|
4030
|
-
var
|
|
4070
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
4071
|
+
var createRule53 = import_utils55.ESLintUtils.RuleCreator(
|
|
4031
4072
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4032
4073
|
);
|
|
4033
4074
|
var isReactComponent = (node) => {
|
|
4034
|
-
if (node.type ===
|
|
4075
|
+
if (node.type === import_utils55.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4035
4076
|
const { parent } = node;
|
|
4036
|
-
if (parent?.type ===
|
|
4077
|
+
if (parent?.type === import_utils55.AST_NODE_TYPES.VariableDeclarator) {
|
|
4037
4078
|
const { id } = parent;
|
|
4038
|
-
if (id.type ===
|
|
4079
|
+
if (id.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
4039
4080
|
return /^[A-Z]/.test(id.name);
|
|
4040
4081
|
}
|
|
4041
4082
|
}
|
|
4042
4083
|
}
|
|
4043
|
-
if (node.type ===
|
|
4084
|
+
if (node.type === import_utils55.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4044
4085
|
return /^[A-Z]/.test(node.id.name);
|
|
4045
4086
|
}
|
|
4046
4087
|
return false;
|
|
4047
4088
|
};
|
|
4048
4089
|
var isCallbackFunction = (node) => {
|
|
4049
|
-
if (node.type ===
|
|
4090
|
+
if (node.type === import_utils55.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4050
4091
|
return false;
|
|
4051
4092
|
}
|
|
4052
4093
|
const { parent } = node;
|
|
4053
4094
|
if (!parent) {
|
|
4054
4095
|
return false;
|
|
4055
4096
|
}
|
|
4056
|
-
if (parent.type ===
|
|
4097
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
4057
4098
|
return true;
|
|
4058
4099
|
}
|
|
4059
|
-
if (parent.type ===
|
|
4100
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.Property) {
|
|
4060
4101
|
return true;
|
|
4061
4102
|
}
|
|
4062
|
-
if (parent.type ===
|
|
4103
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.ArrayExpression) {
|
|
4063
4104
|
return true;
|
|
4064
4105
|
}
|
|
4065
4106
|
return false;
|
|
4066
4107
|
};
|
|
4067
4108
|
var getFunctionName = (node) => {
|
|
4068
|
-
if (node.type ===
|
|
4109
|
+
if (node.type === import_utils55.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4069
4110
|
return node.id.name;
|
|
4070
4111
|
}
|
|
4071
|
-
if (node.type ===
|
|
4112
|
+
if (node.type === import_utils55.AST_NODE_TYPES.FunctionExpression && node.id) {
|
|
4072
4113
|
return node.id.name;
|
|
4073
4114
|
}
|
|
4074
|
-
if ((node.type ===
|
|
4115
|
+
if ((node.type === import_utils55.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils55.AST_NODE_TYPES.FunctionExpression) && node.parent?.type === import_utils55.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
4075
4116
|
return node.parent.id.name;
|
|
4076
4117
|
}
|
|
4077
4118
|
return null;
|
|
4078
4119
|
};
|
|
4079
|
-
var requireExplicitReturnType =
|
|
4120
|
+
var requireExplicitReturnType = createRule53({
|
|
4080
4121
|
name: "require-explicit-return-type",
|
|
4081
4122
|
meta: {
|
|
4082
4123
|
type: "suggestion",
|
|
@@ -4125,8 +4166,8 @@ var requireExplicitReturnType = createRule52({
|
|
|
4125
4166
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4126
4167
|
|
|
4127
4168
|
// src/rules/sort-exports.ts
|
|
4128
|
-
var
|
|
4129
|
-
var
|
|
4169
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
4170
|
+
var createRule54 = import_utils56.ESLintUtils.RuleCreator(
|
|
4130
4171
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4131
4172
|
);
|
|
4132
4173
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4140,7 +4181,7 @@ function getExportGroup(node) {
|
|
|
4140
4181
|
}
|
|
4141
4182
|
return 1;
|
|
4142
4183
|
}
|
|
4143
|
-
var sortExports =
|
|
4184
|
+
var sortExports = createRule54({
|
|
4144
4185
|
name: "sort-exports",
|
|
4145
4186
|
meta: {
|
|
4146
4187
|
type: "suggestion",
|
|
@@ -4180,7 +4221,7 @@ var sortExports = createRule53({
|
|
|
4180
4221
|
Program(node) {
|
|
4181
4222
|
const exportGroups = [];
|
|
4182
4223
|
node.body.forEach((statement) => {
|
|
4183
|
-
if (statement.type !==
|
|
4224
|
+
if (statement.type !== import_utils56.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4184
4225
|
if (exportGroups.length > 0) {
|
|
4185
4226
|
checkOrder(exportGroups);
|
|
4186
4227
|
exportGroups.length = 0;
|
|
@@ -4199,8 +4240,8 @@ var sortExports = createRule53({
|
|
|
4199
4240
|
var sort_exports_default = sortExports;
|
|
4200
4241
|
|
|
4201
4242
|
// src/rules/sort-imports.ts
|
|
4202
|
-
var
|
|
4203
|
-
var
|
|
4243
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
4244
|
+
var createRule55 = import_utils57.ESLintUtils.RuleCreator(
|
|
4204
4245
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4205
4246
|
);
|
|
4206
4247
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4267,7 +4308,7 @@ function getImportGroup(node) {
|
|
|
4267
4308
|
function isTypeOnlyImport(node) {
|
|
4268
4309
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4269
4310
|
}
|
|
4270
|
-
var sortImports =
|
|
4311
|
+
var sortImports = createRule55({
|
|
4271
4312
|
name: "sort-imports",
|
|
4272
4313
|
meta: {
|
|
4273
4314
|
type: "suggestion",
|
|
@@ -4311,7 +4352,7 @@ var sortImports = createRule54({
|
|
|
4311
4352
|
Program(node) {
|
|
4312
4353
|
const importGroups = [];
|
|
4313
4354
|
node.body.forEach((statement) => {
|
|
4314
|
-
if (statement.type !==
|
|
4355
|
+
if (statement.type !== import_utils57.AST_NODE_TYPES.ImportDeclaration) {
|
|
4315
4356
|
if (importGroups.length > 0) {
|
|
4316
4357
|
checkOrder(importGroups);
|
|
4317
4358
|
importGroups.length = 0;
|
|
@@ -4333,13 +4374,13 @@ var sortImports = createRule54({
|
|
|
4333
4374
|
var sort_imports_default = sortImports;
|
|
4334
4375
|
|
|
4335
4376
|
// src/rules/sort-type-alphabetically.ts
|
|
4336
|
-
var
|
|
4337
|
-
var
|
|
4377
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
4378
|
+
var createRule56 = import_utils58.ESLintUtils.RuleCreator(
|
|
4338
4379
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4339
4380
|
);
|
|
4340
4381
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4341
4382
|
const properties = members.filter(
|
|
4342
|
-
(member) => member.type ===
|
|
4383
|
+
(member) => member.type === import_utils58.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils58.AST_NODE_TYPES.Identifier
|
|
4343
4384
|
);
|
|
4344
4385
|
if (properties.length < 2) {
|
|
4345
4386
|
return true;
|
|
@@ -4350,7 +4391,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4350
4391
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4351
4392
|
return isRequiredSorted && isOptionalSorted;
|
|
4352
4393
|
}
|
|
4353
|
-
var sortTypeAlphabetically =
|
|
4394
|
+
var sortTypeAlphabetically = createRule56({
|
|
4354
4395
|
name: "sort-type-alphabetically",
|
|
4355
4396
|
meta: {
|
|
4356
4397
|
type: "suggestion",
|
|
@@ -4368,7 +4409,7 @@ var sortTypeAlphabetically = createRule55({
|
|
|
4368
4409
|
function fixMembers(fixer, members) {
|
|
4369
4410
|
const { sourceCode } = context;
|
|
4370
4411
|
const properties = members.filter(
|
|
4371
|
-
(member) => member.type ===
|
|
4412
|
+
(member) => member.type === import_utils58.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils58.AST_NODE_TYPES.Identifier
|
|
4372
4413
|
);
|
|
4373
4414
|
const required = properties.filter((prop) => !prop.optional);
|
|
4374
4415
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4405,7 +4446,7 @@ var sortTypeAlphabetically = createRule55({
|
|
|
4405
4446
|
}
|
|
4406
4447
|
},
|
|
4407
4448
|
TSTypeAliasDeclaration(node) {
|
|
4408
|
-
if (node.typeAnnotation.type !==
|
|
4449
|
+
if (node.typeAnnotation.type !== import_utils58.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4409
4450
|
return;
|
|
4410
4451
|
}
|
|
4411
4452
|
const { members } = node.typeAnnotation;
|
|
@@ -4425,13 +4466,13 @@ var sortTypeAlphabetically = createRule55({
|
|
|
4425
4466
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4426
4467
|
|
|
4427
4468
|
// src/rules/sort-type-required-first.ts
|
|
4428
|
-
var
|
|
4429
|
-
var
|
|
4469
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
4470
|
+
var createRule57 = import_utils59.ESLintUtils.RuleCreator(
|
|
4430
4471
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4431
4472
|
);
|
|
4432
4473
|
function isRequiredBeforeOptional(members) {
|
|
4433
4474
|
const properties = members.filter(
|
|
4434
|
-
(member) => member.type ===
|
|
4475
|
+
(member) => member.type === import_utils59.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils59.AST_NODE_TYPES.Identifier
|
|
4435
4476
|
);
|
|
4436
4477
|
if (properties.length < 2) {
|
|
4437
4478
|
return true;
|
|
@@ -4442,7 +4483,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4442
4483
|
}
|
|
4443
4484
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4444
4485
|
}
|
|
4445
|
-
var sortTypeRequiredFirst =
|
|
4486
|
+
var sortTypeRequiredFirst = createRule57({
|
|
4446
4487
|
name: "sort-type-required-first",
|
|
4447
4488
|
meta: {
|
|
4448
4489
|
type: "suggestion",
|
|
@@ -4460,7 +4501,7 @@ var sortTypeRequiredFirst = createRule56({
|
|
|
4460
4501
|
function fixMembers(fixer, members) {
|
|
4461
4502
|
const { sourceCode } = context;
|
|
4462
4503
|
const properties = members.filter(
|
|
4463
|
-
(member) => member.type ===
|
|
4504
|
+
(member) => member.type === import_utils59.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils59.AST_NODE_TYPES.Identifier
|
|
4464
4505
|
);
|
|
4465
4506
|
const required = properties.filter((prop) => !prop.optional);
|
|
4466
4507
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4481,7 +4522,7 @@ var sortTypeRequiredFirst = createRule56({
|
|
|
4481
4522
|
}
|
|
4482
4523
|
},
|
|
4483
4524
|
TSTypeAliasDeclaration(node) {
|
|
4484
|
-
if (node.typeAnnotation.type !==
|
|
4525
|
+
if (node.typeAnnotation.type !== import_utils59.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4485
4526
|
return;
|
|
4486
4527
|
}
|
|
4487
4528
|
const { members } = node.typeAnnotation;
|
|
@@ -4528,6 +4569,7 @@ var rules = {
|
|
|
4528
4569
|
"jsx-require-suspense": jsx_require_suspense_default,
|
|
4529
4570
|
"jsx-simple-props": jsx_simple_props_default,
|
|
4530
4571
|
"jsx-sort-props": jsx_sort_props_default,
|
|
4572
|
+
"jsx-spread-props-last": jsx_spread_props_last_default,
|
|
4531
4573
|
"newline-after-multiline-block": newline_after_multiline_block_default,
|
|
4532
4574
|
"newline-before-return": newline_before_return_default,
|
|
4533
4575
|
"nextjs-require-public-env": nextjs_require_public_env_default,
|
|
@@ -4664,6 +4706,7 @@ var jsxRules = {
|
|
|
4664
4706
|
"nextfriday/jsx-require-suspense": "warn",
|
|
4665
4707
|
"nextfriday/jsx-simple-props": "warn",
|
|
4666
4708
|
"nextfriday/jsx-sort-props": "warn",
|
|
4709
|
+
"nextfriday/jsx-spread-props-last": "warn",
|
|
4667
4710
|
"nextfriday/prefer-interface-over-inline-types": "warn",
|
|
4668
4711
|
"nextfriday/prefer-jsx-template-literals": "warn",
|
|
4669
4712
|
"nextfriday/react-props-destructure": "warn"
|
|
@@ -4681,6 +4724,7 @@ var jsxRecommendedRules = {
|
|
|
4681
4724
|
"nextfriday/jsx-require-suspense": "error",
|
|
4682
4725
|
"nextfriday/jsx-simple-props": "error",
|
|
4683
4726
|
"nextfriday/jsx-sort-props": "error",
|
|
4727
|
+
"nextfriday/jsx-spread-props-last": "error",
|
|
4684
4728
|
"nextfriday/prefer-interface-over-inline-types": "error",
|
|
4685
4729
|
"nextfriday/prefer-jsx-template-literals": "error",
|
|
4686
4730
|
"nextfriday/react-props-destructure": "error"
|