eslint-plugin-nextfriday 1.22.0 → 1.23.1

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,17 @@
1
1
  # eslint-plugin-nextfriday
2
2
 
3
+ ## 1.23.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#96](https://github.com/next-friday/eslint-plugin-nextfriday/pull/96) [`1821f08`](https://github.com/next-friday/eslint-plugin-nextfriday/commit/1821f08a00cf60a0b1ab6d654e700b54b86f364b) Thanks [@joetakara](https://github.com/joetakara)! - Upgrade dependencies to latest compatible versions: typescript-eslint 8.58 → 8.59, eslint-plugin-unicorn 63 → 64, eslint-plugin-sonarjs 4.0.2 → 4.0.3, plus dev tooling (prettier, changesets, commitlint, swc). Pinned eslint, typescript, and @types/node to their latest 9.x/5.x/22.x lines for ecosystem and engine compatibility.
8
+
9
+ ## 1.23.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#94](https://github.com/next-friday/eslint-plugin-nextfriday/pull/94) [`7eaf83e`](https://github.com/next-friday/eslint-plugin-nextfriday/commit/7eaf83e365bb0867679f9abe764ade784eeb4594) Thanks [@joetakara](https://github.com/joetakara)! - Add auto-fix support to jsx-sort-props rule. Running eslint --fix will automatically reorder JSX props by value type.
14
+
3
15
  ## 1.22.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -231,7 +231,7 @@ export default [
231
231
  | [jsx-no-variable-in-callback](docs/rules/JSX_NO_VARIABLE_IN_CALLBACK.md) | Disallow variable declarations inside callback functions in JSX | ❌ |
232
232
  | [jsx-require-suspense](docs/rules/JSX_REQUIRE_SUSPENSE.md) | Require lazy-loaded components to be wrapped in Suspense | ❌ |
233
233
  | [jsx-simple-props](docs/rules/JSX_SIMPLE_PROPS.md) | Enforce simple prop values (strings, variables, callbacks, ReactNode) | ❌ |
234
- | [jsx-sort-props](docs/rules/JSX_SORT_PROPS.md) | Enforce JSX props are sorted by value type | |
234
+ | [jsx-sort-props](docs/rules/JSX_SORT_PROPS.md) | Enforce JSX props are sorted by value type | |
235
235
  | [prefer-jsx-template-literals](docs/rules/PREFER_JSX_TEMPLATE_LITERALS.md) | Enforce template literals instead of mixing text and JSX expressions | ✅ |
236
236
  | [react-props-destructure](docs/rules/REACT_PROPS_DESTRUCTURE.md) | Enforce destructuring props inside React component body | ❌ |
237
237
  | [enforce-props-suffix](docs/rules/ENFORCE_PROPS_SUFFIX.md) | Enforce 'Props' suffix for interfaces and types in \*.tsx files | ❌ |
@@ -2,6 +2,8 @@
2
2
 
3
3
  Enforce JSX props are sorted by value type.
4
4
 
5
+ > This rule is auto-fixable using `--fix`.
6
+
5
7
  ## Rule Details
6
8
 
7
9
  This rule enforces a consistent ordering of JSX props based on the type of their value. Props must appear in the following order:
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.22.0",
45
+ version: "1.23.1",
46
46
  description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
47
47
  keywords: [
48
48
  "eslint",
@@ -106,29 +106,29 @@ var package_default = {
106
106
  typecheck: "tsc --noEmit"
107
107
  },
108
108
  dependencies: {
109
- "@typescript-eslint/utils": "^8.57.2",
109
+ "@typescript-eslint/utils": "^8.59.1",
110
110
  "emoji-regex": "^10.6.0",
111
- "eslint-plugin-sonarjs": "^4.0.2",
112
- "eslint-plugin-unicorn": "^63.0.0",
111
+ "eslint-plugin-sonarjs": "^4.0.3",
112
+ "eslint-plugin-unicorn": "^64.0.0",
113
113
  tsup: "^8.5.1"
114
114
  },
115
115
  devDependencies: {
116
116
  "@changesets/changelog-github": "^0.6.0",
117
- "@changesets/cli": "^2.30.0",
118
- "@commitlint/cli": "^20.5.0",
117
+ "@changesets/cli": "^2.31.0",
118
+ "@commitlint/cli": "^20.5.2",
119
119
  "@commitlint/config-conventional": "^20.5.0",
120
- "@eslint/js": "^9.35.0",
120
+ "@eslint/js": "^9.39.4",
121
121
  "@jest/globals": "^30.3.0",
122
122
  "@stylistic/eslint-plugin": "^5.10.0",
123
- "@swc/core": "^1.15.21",
123
+ "@swc/core": "^1.15.32",
124
124
  "@swc/jest": "^0.2.39",
125
125
  "@types/eslint": "^9.6.1",
126
126
  "@types/jest": "^30.0.0",
127
- "@types/node": "^22.18.1",
127
+ "@types/node": "^22.19.17",
128
128
  "@types/ramda": "^0.31.1",
129
- "@typescript-eslint/parser": "^8.57.2",
130
- "@typescript-eslint/rule-tester": "^8.57.2",
131
- eslint: "^9.39.3",
129
+ "@typescript-eslint/parser": "^8.59.1",
130
+ "@typescript-eslint/rule-tester": "^8.59.1",
131
+ eslint: "^9.39.4",
132
132
  "eslint-config-airbnb-extended": "^3.0.1",
133
133
  "eslint-config-prettier": "^10.1.8",
134
134
  "eslint-import-resolver-typescript": "^4.4.4",
@@ -138,12 +138,12 @@ var package_default = {
138
138
  husky: "^9.1.7",
139
139
  jest: "^30.3.0",
140
140
  "lint-staged": "^16.4.0",
141
- prettier: "^3.8.1",
141
+ prettier: "^3.8.3",
142
142
  "sort-package-json": "^3.6.1",
143
143
  "ts-jest": "^29.4.6",
144
144
  "ts-node": "^10.9.2",
145
- typescript: "^5.6.2",
146
- "typescript-eslint": "^8.57.2"
145
+ typescript: "^5.9.3",
146
+ "typescript-eslint": "^8.59.1"
147
147
  },
148
148
  peerDependencies: {
149
149
  eslint: "^9.0.0"
@@ -1814,6 +1814,29 @@ function hasUnsortedProps(attributes) {
1814
1814
  return false;
1815
1815
  });
1816
1816
  }
1817
+ function sortSegment(segment, sourceCode, fixer) {
1818
+ const sorted = [...segment].sort((a, b) => (getTypeGroup(a) ?? 0) - (getTypeGroup(b) ?? 0));
1819
+ const sortedTexts = sorted.map((attr) => sourceCode.getText(attr));
1820
+ return segment.map((attr, i) => ({ attr, sortedText: sortedTexts[i] })).filter(({ attr, sortedText }) => sourceCode.getText(attr) !== sortedText).map(({ attr, sortedText }) => fixer.replaceText(attr, sortedText));
1821
+ }
1822
+ function getSegments(attributes) {
1823
+ const result = [];
1824
+ let current = [];
1825
+ attributes.forEach((attr) => {
1826
+ if (attr.type === import_utils24.AST_NODE_TYPES.JSXSpreadAttribute) {
1827
+ if (current.length > 0) {
1828
+ result.push(current);
1829
+ current = [];
1830
+ }
1831
+ } else {
1832
+ current.push(attr);
1833
+ }
1834
+ });
1835
+ if (current.length > 0) {
1836
+ result.push(current);
1837
+ }
1838
+ return result;
1839
+ }
1817
1840
  var jsxSortProps = createRule22({
1818
1841
  name: "jsx-sort-props",
1819
1842
  meta: {
@@ -1821,6 +1844,7 @@ var jsxSortProps = createRule22({
1821
1844
  docs: {
1822
1845
  description: "Enforce JSX props are sorted by value type: strings, hyphenated strings, numbers/booleans, expressions, objects/arrays, functions, JSX elements, then shorthand booleans"
1823
1846
  },
1847
+ fixable: "code",
1824
1848
  messages: {
1825
1849
  unsortedProps: "JSX props should be sorted by value type: strings, hyphenated strings, numbers/booleans/null, expressions, objects/arrays, functions, JSX elements, then shorthand booleans."
1826
1850
  },
@@ -1828,14 +1852,19 @@ var jsxSortProps = createRule22({
1828
1852
  },
1829
1853
  defaultOptions: [],
1830
1854
  create(context) {
1855
+ const { sourceCode } = context;
1831
1856
  return {
1832
1857
  JSXOpeningElement(node) {
1833
- if (hasUnsortedProps(node.attributes)) {
1834
- context.report({
1835
- node,
1836
- messageId: "unsortedProps"
1837
- });
1858
+ if (!hasUnsortedProps(node.attributes)) {
1859
+ return;
1838
1860
  }
1861
+ context.report({
1862
+ node,
1863
+ messageId: "unsortedProps",
1864
+ fix(fixer) {
1865
+ return getSegments(node.attributes).flatMap((segment) => sortSegment(segment, sourceCode, fixer));
1866
+ }
1867
+ });
1839
1868
  }
1840
1869
  };
1841
1870
  }