eslint-plugin-nextfriday 4.3.1 → 4.3.2
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 +6 -0
- package/lib/index.cjs +25 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +25 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# eslint-plugin-nextfriday
|
|
2
2
|
|
|
3
|
+
## 4.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#132](https://github.com/next-friday/eslint-plugin-nextfriday/pull/132) [`5b2cb71`](https://github.com/next-friday/eslint-plugin-nextfriday/commit/5b2cb713b126917b1205fd54c6a1143d50aef7aa) Thanks [@joetakara](https://github.com/joetakara)! - fix 18 rules missing internal filename guards. `no-helper-function-in-hook` and `no-helper-function-in-test` now self-skip on non-matching files and are included in all presets — no consumer configuration required. all jsx rules now guard against non-jsx files using `isJsxFile()`, consistent with the established codebase pattern.
|
|
8
|
+
|
|
3
9
|
## 4.3.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/lib/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@ 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.3.
|
|
35
|
+
var version = "4.3.2";
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/rules/boolean-naming-prefix.ts
|
|
38
38
|
const createRule$32 = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
|
|
@@ -478,6 +478,7 @@ const enforceReadonlyComponentProps = _typescript_eslint_utils.ESLintUtils.RuleC
|
|
|
478
478
|
},
|
|
479
479
|
defaultOptions: [],
|
|
480
480
|
create(context) {
|
|
481
|
+
if (!isJsxFile(context.filename)) return {};
|
|
481
482
|
function hasJSXInConditional(node) {
|
|
482
483
|
return node.consequent.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXElement || node.consequent.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXFragment || node.alternate.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXElement || node.alternate.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXFragment;
|
|
483
484
|
}
|
|
@@ -897,6 +898,7 @@ const jsxNewlineBetweenElements = _typescript_eslint_utils.ESLintUtils.RuleCreat
|
|
|
897
898
|
},
|
|
898
899
|
defaultOptions: [],
|
|
899
900
|
create(context) {
|
|
901
|
+
if (!isJsxFile(context.filename)) return {};
|
|
900
902
|
const { sourceCode } = context;
|
|
901
903
|
function isSignificantJSXChild(node) {
|
|
902
904
|
return node.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXElement || node.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXFragment || node.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXExpressionContainer;
|
|
@@ -1061,6 +1063,7 @@ const jsxNoInlineObjectProp = _typescript_eslint_utils.ESLintUtils.RuleCreator((
|
|
|
1061
1063
|
},
|
|
1062
1064
|
defaultOptions: [],
|
|
1063
1065
|
create(context) {
|
|
1066
|
+
if (!isJsxFile(context.filename)) return {};
|
|
1064
1067
|
return { JSXAttribute(node) {
|
|
1065
1068
|
if (node.value?.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXExpressionContainer && node.value.expression.type === _typescript_eslint_utils.AST_NODE_TYPES.ObjectExpression) context.report({
|
|
1066
1069
|
node: node.value,
|
|
@@ -1089,6 +1092,7 @@ const jsxNoNewlineSingleLineElements = createRule$21({
|
|
|
1089
1092
|
},
|
|
1090
1093
|
defaultOptions: [],
|
|
1091
1094
|
create(context) {
|
|
1095
|
+
if (!isJsxFile(context.filename)) return {};
|
|
1092
1096
|
const { sourceCode } = context;
|
|
1093
1097
|
function checkSiblings(children) {
|
|
1094
1098
|
const nonWhitespace = children.filter((child) => !(child.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXText && child.value.trim() === ""));
|
|
@@ -1292,6 +1296,7 @@ const jsxNoTernaryNull = createRule$19({
|
|
|
1292
1296
|
},
|
|
1293
1297
|
defaultOptions: [],
|
|
1294
1298
|
create(context) {
|
|
1299
|
+
if (!isJsxFile(context.filename)) return {};
|
|
1295
1300
|
return { JSXExpressionContainer(node) {
|
|
1296
1301
|
const { expression } = node;
|
|
1297
1302
|
if (expression.type !== _typescript_eslint_utils.AST_NODE_TYPES.ConditionalExpression) return;
|
|
@@ -1332,6 +1337,7 @@ const jsxNoVariableInCallback = _typescript_eslint_utils.ESLintUtils.RuleCreator
|
|
|
1332
1337
|
},
|
|
1333
1338
|
defaultOptions: [],
|
|
1334
1339
|
create(context) {
|
|
1340
|
+
if (!isJsxFile(context.filename)) return {};
|
|
1335
1341
|
function isInsideJSX(node) {
|
|
1336
1342
|
let current = node.parent;
|
|
1337
1343
|
while (current) {
|
|
@@ -1378,6 +1384,7 @@ const jsxRequireSuspense = _typescript_eslint_utils.ESLintUtils.RuleCreator((nam
|
|
|
1378
1384
|
},
|
|
1379
1385
|
defaultOptions: [],
|
|
1380
1386
|
create(context) {
|
|
1387
|
+
if (!isJsxFile(context.filename)) return {};
|
|
1381
1388
|
const lazyComponents = /* @__PURE__ */ new Set();
|
|
1382
1389
|
const isInsideSuspense = (node) => {
|
|
1383
1390
|
let current = node.parent;
|
|
@@ -1419,6 +1426,7 @@ const jsxSimpleProps = _typescript_eslint_utils.ESLintUtils.RuleCreator((name) =
|
|
|
1419
1426
|
},
|
|
1420
1427
|
defaultOptions: [],
|
|
1421
1428
|
create(context) {
|
|
1429
|
+
if (!isJsxFile(context.filename)) return {};
|
|
1422
1430
|
const allowedExpressionTypes = new Set([
|
|
1423
1431
|
_typescript_eslint_utils.AST_NODE_TYPES.Identifier,
|
|
1424
1432
|
_typescript_eslint_utils.AST_NODE_TYPES.Literal,
|
|
@@ -1538,6 +1546,7 @@ const jsxSortProps = createRule$18({
|
|
|
1538
1546
|
},
|
|
1539
1547
|
defaultOptions: [],
|
|
1540
1548
|
create(context) {
|
|
1549
|
+
if (!isJsxFile(context.filename)) return {};
|
|
1541
1550
|
const { sourceCode } = context;
|
|
1542
1551
|
return { JSXOpeningElement(node) {
|
|
1543
1552
|
if (!hasUnsortedProps(node.attributes)) return;
|
|
@@ -1563,6 +1572,7 @@ const jsxSpreadPropsLast = _typescript_eslint_utils.ESLintUtils.RuleCreator((nam
|
|
|
1563
1572
|
},
|
|
1564
1573
|
defaultOptions: [],
|
|
1565
1574
|
create(context) {
|
|
1575
|
+
if (!isJsxFile(context.filename)) return {};
|
|
1566
1576
|
return { JSXOpeningElement(node) {
|
|
1567
1577
|
const { attributes } = node;
|
|
1568
1578
|
let lastNonSpreadIndex = -1;
|
|
@@ -1806,6 +1816,7 @@ const noGhostWrapper = createRule$16({
|
|
|
1806
1816
|
},
|
|
1807
1817
|
defaultOptions: [],
|
|
1808
1818
|
create(context) {
|
|
1819
|
+
if (!isJsxFile(context.filename)) return {};
|
|
1809
1820
|
return { JSXOpeningElement(node) {
|
|
1810
1821
|
if (node.name.type !== _typescript_eslint_utils.AST_NODE_TYPES.JSXIdentifier) return;
|
|
1811
1822
|
const tagName = node.name.name;
|
|
@@ -1830,6 +1841,8 @@ const noHelperFunctionInHook = _typescript_eslint_utils.ESLintUtils.RuleCreator(
|
|
|
1830
1841
|
},
|
|
1831
1842
|
defaultOptions: [],
|
|
1832
1843
|
create(context) {
|
|
1844
|
+
const basename = path.default.basename(context.filename);
|
|
1845
|
+
if (!(basename.endsWith(".hook.ts") || basename.endsWith(".hooks.ts"))) return {};
|
|
1833
1846
|
function isAtProgramLevel(node) {
|
|
1834
1847
|
const { parent } = node;
|
|
1835
1848
|
if (parent === void 0) return false;
|
|
@@ -1871,6 +1884,8 @@ const noHelperFunctionInTest = _typescript_eslint_utils.ESLintUtils.RuleCreator(
|
|
|
1871
1884
|
},
|
|
1872
1885
|
defaultOptions: [],
|
|
1873
1886
|
create(context) {
|
|
1887
|
+
const basename = path.default.basename(context.filename);
|
|
1888
|
+
if (!(basename.endsWith(".test.ts") || basename.endsWith(".test.tsx"))) return {};
|
|
1874
1889
|
return {
|
|
1875
1890
|
FunctionDeclaration(node) {
|
|
1876
1891
|
if (node.parent.type === _typescript_eslint_utils.AST_NODE_TYPES.Program) context.report({
|
|
@@ -2413,6 +2428,7 @@ const noRedundantFragment = createRule$10({
|
|
|
2413
2428
|
},
|
|
2414
2429
|
defaultOptions: [],
|
|
2415
2430
|
create(context) {
|
|
2431
|
+
if (!isJsxFile(context.filename)) return {};
|
|
2416
2432
|
return {
|
|
2417
2433
|
JSXFragment(node) {
|
|
2418
2434
|
const count = countMeaningfulChildren(node.children);
|
|
@@ -3017,6 +3033,7 @@ const preferJSXTemplateLiterals = _typescript_eslint_utils.ESLintUtils.RuleCreat
|
|
|
3017
3033
|
},
|
|
3018
3034
|
defaultOptions: [],
|
|
3019
3035
|
create(context) {
|
|
3036
|
+
if (!isJsxFile(context.filename)) return {};
|
|
3020
3037
|
function handleTextBeforeExpression(textNode, exprNode) {
|
|
3021
3038
|
const textValue = textNode.value;
|
|
3022
3039
|
const trimmedText = textValue.trim();
|
|
@@ -3128,6 +3145,7 @@ const preferPropsWithChildren = _typescript_eslint_utils.ESLintUtils.RuleCreator
|
|
|
3128
3145
|
},
|
|
3129
3146
|
defaultOptions: [],
|
|
3130
3147
|
create(context) {
|
|
3148
|
+
if (!isJsxFile(context.filename)) return {};
|
|
3131
3149
|
function isReactNodeType(typeNode) {
|
|
3132
3150
|
if (!typeNode) return false;
|
|
3133
3151
|
if (typeNode.type !== _typescript_eslint_utils.AST_NODE_TYPES.TSTypeReference) return false;
|
|
@@ -3176,6 +3194,7 @@ const preferReactImportTypes = _typescript_eslint_utils.ESLintUtils.RuleCreator(
|
|
|
3176
3194
|
},
|
|
3177
3195
|
defaultOptions: [],
|
|
3178
3196
|
create(context) {
|
|
3197
|
+
if (!isJsxFile(context.filename)) return {};
|
|
3179
3198
|
const reactTypes = new Set([
|
|
3180
3199
|
"ReactNode",
|
|
3181
3200
|
"ReactElement",
|
|
@@ -3288,6 +3307,7 @@ const reactPropsDestructure = _typescript_eslint_utils.ESLintUtils.RuleCreator((
|
|
|
3288
3307
|
},
|
|
3289
3308
|
defaultOptions: [],
|
|
3290
3309
|
create(context) {
|
|
3310
|
+
if (!isJsxFile(context.filename)) return {};
|
|
3291
3311
|
function hasJSXInConditional(node) {
|
|
3292
3312
|
return node.consequent.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXElement || node.consequent.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXFragment || node.alternate.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXElement || node.alternate.type === _typescript_eslint_utils.AST_NODE_TYPES.JSXFragment;
|
|
3293
3313
|
}
|
|
@@ -3793,6 +3813,8 @@ const baseRules = {
|
|
|
3793
3813
|
"nextfriday/no-direct-date": "warn",
|
|
3794
3814
|
"nextfriday/no-emoji": "warn",
|
|
3795
3815
|
"nextfriday/no-env-fallback": "warn",
|
|
3816
|
+
"nextfriday/no-helper-function-in-hook": "warn",
|
|
3817
|
+
"nextfriday/no-helper-function-in-test": "warn",
|
|
3796
3818
|
"nextfriday/no-inline-default-export": "warn",
|
|
3797
3819
|
"nextfriday/no-inline-nested-object": "warn",
|
|
3798
3820
|
"nextfriday/no-inline-return-properties": "warn",
|
|
@@ -3837,6 +3859,8 @@ const baseRecommendedRules = {
|
|
|
3837
3859
|
"nextfriday/no-direct-date": "error",
|
|
3838
3860
|
"nextfriday/no-emoji": "error",
|
|
3839
3861
|
"nextfriday/no-env-fallback": "error",
|
|
3862
|
+
"nextfriday/no-helper-function-in-hook": "error",
|
|
3863
|
+
"nextfriday/no-helper-function-in-test": "error",
|
|
3840
3864
|
"nextfriday/no-inline-default-export": "error",
|
|
3841
3865
|
"nextfriday/no-inline-nested-object": "error",
|
|
3842
3866
|
"nextfriday/no-inline-return-properties": "error",
|