@so1ve/eslint-plugin-sort-imports 0.104.2 → 0.105.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/shared.js +9 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-plugin-sort-imports",
3
- "version": "0.104.2",
3
+ "version": "0.105.0",
4
4
  "author": "Simon Lydell",
5
5
  "contributors": [
6
6
  "Ray (https://github.com/so1ve) <i@mk1.io>"
package/src/shared.js CHANGED
@@ -44,7 +44,15 @@ function parseWhitespace(whitespace) {
44
44
  );
45
45
  }
46
46
 
47
- const compare = natsort.default();
47
+ const naturalSort = natsort.default();
48
+ function compare(path1, path2) {
49
+ const path1Depth = path1.split("-").filter((p) => p === "__").length;
50
+ const path2Depth = path2.split("-").filter((p) => p === "__").length;
51
+
52
+ return path1Depth === path2Depth
53
+ ? naturalSort(path1, path2)
54
+ : path2Depth - path1Depth;
55
+ }
48
56
 
49
57
  const isIdentifier = (node) => node.type === "Identifier";
50
58