eslint-plugin-nextfriday 1.17.0 → 1.18.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # eslint-plugin-nextfriday
2
2
 
3
+ ## 1.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#81](https://github.com/next-friday/eslint-plugin-nextfriday/pull/81) [`081326a`](https://github.com/next-friday/eslint-plugin-nextfriday/commit/081326adf199aee711e97b1627def3bf867ad89c) Thanks [@joetakara](https://github.com/joetakara)! - Add hyphenated string group to jsx-sort-props for props like aria-label and data-slot. Fix jsx-newline-between-elements to include self-closing elements
8
+
3
9
  ## 1.17.0
4
10
 
5
11
  ### Minor Changes
@@ -6,13 +6,14 @@ Enforce JSX props are sorted by value type.
6
6
 
7
7
  This rule enforces a consistent ordering of JSX props based on the type of their value. Props must appear in the following order:
8
8
 
9
- 1. **String** - String literals and template literals
10
- 2. **Number/Boolean/Null** - Numeric literals, boolean literals, null, and undefined
11
- 3. **Expression** - Variable references, member expressions, call expressions, and other dynamic values
12
- 4. **Object/Array** - Inline objects and arrays
13
- 5. **Function** - Arrow functions and function expressions
14
- 6. **JSX Element** - JSX elements and fragments
15
- 7. **Shorthand boolean** - Props with no value (e.g., `disabled`, `required`)
9
+ 1. **String** - String literals and template literals (e.g., `className="cover"`)
10
+ 2. **Hyphenated string** - Props with hyphenated names and string values (e.g., `aria-label="label"`, `data-slot="nav"`)
11
+ 3. **Number/Boolean/Null** - Numeric literals, boolean literals, null, and undefined
12
+ 4. **Expression** - Variable references, member expressions, call expressions, and other dynamic values
13
+ 5. **Object/Array** - Inline objects and arrays
14
+ 6. **Function** - Arrow functions and function expressions
15
+ 7. **JSX Element** - JSX elements and fragments
16
+ 8. **Shorthand boolean** - Props with no value (e.g., `disabled`, `required`)
16
17
 
17
18
  Spread attributes (`{...props}`) reset the ordering context.
18
19
 
@@ -29,7 +30,6 @@ Spread attributes (`{...props}`) reset the ordering context.
29
30
  ```tsx
30
31
  <Component disabled title="hello" />
31
32
  <Component onClick={() => {}} count={42} />
32
- <Component icon={<Icon />} style={{ color: "red" }} />
33
33
  <Component className="cover" src={src} fill sizes={sizes} />
34
34
  ```
35
35
 
@@ -38,6 +38,7 @@ Spread attributes (`{...props}`) reset the ordering context.
38
38
  ```tsx
39
39
  <Component
40
40
  title="hello"
41
+ aria-label="close"
41
42
  count={100}
42
43
  src={src}
43
44
  style={{ color: "red" }}
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: "1.17.0",
45
+ version: "1.18.0",
46
46
  description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
47
47
  keywords: [
48
48
  "eslint",
@@ -932,13 +932,7 @@ var jsxNewlineBetweenElements = createRule11({
932
932
  create(context) {
933
933
  const { sourceCode } = context;
934
934
  function isJSXElementOrFragment2(node) {
935
- if (node.type === import_utils11.AST_NODE_TYPES.JSXFragment) {
936
- return true;
937
- }
938
- if (node.type === import_utils11.AST_NODE_TYPES.JSXElement) {
939
- return node.closingElement !== null;
940
- }
941
- return false;
935
+ return node.type === import_utils11.AST_NODE_TYPES.JSXElement || node.type === import_utils11.AST_NODE_TYPES.JSXFragment;
942
936
  }
943
937
  function isMultiLine(node) {
944
938
  return node.loc.start.line !== node.loc.end.line;
@@ -1416,15 +1410,15 @@ var createRule19 = import_utils21.ESLintUtils.RuleCreator(
1416
1410
  );
1417
1411
  var TYPE_GROUP = {
1418
1412
  STRING: 1,
1419
- NUMBER_BOOLEAN_NULL: 2,
1420
- EXPRESSION: 3,
1421
- OBJECT_ARRAY: 4,
1422
- FUNCTION: 5,
1423
- JSX: 6,
1424
- SHORTHAND: 7
1413
+ HYPHENATED_STRING: 2,
1414
+ NUMBER_BOOLEAN_NULL: 3,
1415
+ EXPRESSION: 4,
1416
+ OBJECT_ARRAY: 5,
1417
+ FUNCTION: 6,
1418
+ JSX: 7,
1419
+ SHORTHAND: 8
1425
1420
  };
1426
1421
  var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
1427
- [import_utils21.AST_NODE_TYPES.TemplateLiteral, TYPE_GROUP.STRING],
1428
1422
  [import_utils21.AST_NODE_TYPES.ObjectExpression, TYPE_GROUP.OBJECT_ARRAY],
1429
1423
  [import_utils21.AST_NODE_TYPES.ArrayExpression, TYPE_GROUP.OBJECT_ARRAY],
1430
1424
  [import_utils21.AST_NODE_TYPES.ArrowFunctionExpression, TYPE_GROUP.FUNCTION],
@@ -1432,15 +1426,24 @@ var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
1432
1426
  [import_utils21.AST_NODE_TYPES.JSXElement, TYPE_GROUP.JSX],
1433
1427
  [import_utils21.AST_NODE_TYPES.JSXFragment, TYPE_GROUP.JSX]
1434
1428
  ]);
1435
- function getLiteralGroup(value) {
1429
+ function isHyphenatedName(node) {
1430
+ return node.name.type === import_utils21.AST_NODE_TYPES.JSXIdentifier && node.name.name.includes("-");
1431
+ }
1432
+ function getStringGroup(node) {
1433
+ return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
1434
+ }
1435
+ function getLiteralValueGroup(value) {
1436
1436
  if (typeof value === "string") {
1437
- return TYPE_GROUP.STRING;
1437
+ return null;
1438
1438
  }
1439
1439
  return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
1440
1440
  }
1441
1441
  function getExpressionGroup(expression) {
1442
1442
  if (expression.type === import_utils21.AST_NODE_TYPES.Literal) {
1443
- return getLiteralGroup(expression.value);
1443
+ return getLiteralValueGroup(expression.value);
1444
+ }
1445
+ if (expression.type === import_utils21.AST_NODE_TYPES.TemplateLiteral) {
1446
+ return null;
1444
1447
  }
1445
1448
  if (expression.type === import_utils21.AST_NODE_TYPES.Identifier && expression.name === "undefined") {
1446
1449
  return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
@@ -1452,7 +1455,10 @@ function getTypeGroup(node) {
1452
1455
  return TYPE_GROUP.SHORTHAND;
1453
1456
  }
1454
1457
  if (node.value.type === import_utils21.AST_NODE_TYPES.Literal) {
1455
- return getLiteralGroup(node.value.value);
1458
+ if (typeof node.value.value === "string") {
1459
+ return getStringGroup(node);
1460
+ }
1461
+ return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
1456
1462
  }
1457
1463
  if (node.value.type !== import_utils21.AST_NODE_TYPES.JSXExpressionContainer) {
1458
1464
  return null;
@@ -1461,7 +1467,11 @@ function getTypeGroup(node) {
1461
1467
  if (expression.type === import_utils21.AST_NODE_TYPES.JSXEmptyExpression) {
1462
1468
  return null;
1463
1469
  }
1464
- return getExpressionGroup(expression);
1470
+ const group = getExpressionGroup(expression);
1471
+ if (group === null) {
1472
+ return getStringGroup(node);
1473
+ }
1474
+ return group;
1465
1475
  }
1466
1476
  function hasUnsortedProps(attributes) {
1467
1477
  let lastGroup = 0;
@@ -1486,10 +1496,10 @@ var jsxSortProps = createRule19({
1486
1496
  meta: {
1487
1497
  type: "suggestion",
1488
1498
  docs: {
1489
- description: "Enforce JSX props are sorted by value type: strings, numbers/booleans, expressions, objects/arrays, functions, JSX elements, then shorthand booleans"
1499
+ description: "Enforce JSX props are sorted by value type: strings, hyphenated strings, numbers/booleans, expressions, objects/arrays, functions, JSX elements, then shorthand booleans"
1490
1500
  },
1491
1501
  messages: {
1492
- unsortedProps: "JSX props should be sorted by value type: strings, numbers/booleans/null, expressions, objects/arrays, functions, JSX elements, then shorthand booleans."
1502
+ unsortedProps: "JSX props should be sorted by value type: strings, hyphenated strings, numbers/booleans/null, expressions, objects/arrays, functions, JSX elements, then shorthand booleans."
1493
1503
  },
1494
1504
  schema: []
1495
1505
  },