Skip to content

Commit 962c083

Browse files
graynortonRajdeepccaseyisonit
authored
chore: do not sort export conditions (#5683)
* chore: update eslint configs * chore: add explanatory comment --------- Co-authored-by: Rajdeep Chandra <rajrock38@gmail.com> Co-authored-by: Casey Eickhoff <48574582+caseyisonit@users.noreply.github.com>
1 parent e624795 commit 962c083

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

.eslintrc.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
"extends": ["plugin:jsonc/recommended-with-jsonc"],
1717
"files": ["*.json"],
1818
"parser": "jsonc-eslint-parser",
19+
"rules": {
20+
"jsonc/sort-keys": ["warn"],
21+
"notice/notice": "off"
22+
}
23+
},
24+
{
25+
"extends": ["plugin:jsonc/recommended-with-jsonc"],
26+
"files": ["package.json"],
27+
"parser": "jsonc-eslint-parser",
1928
"rules": {
2029
"jsonc/sort-keys": [
2130
"warn",
@@ -65,14 +74,18 @@
6574
"cpu",
6675
"publishConfig"
6776
],
68-
"pathPattern": ".*" // Hits the all properties
77+
"pathPattern": "^$" // Top-level properties
6978
},
7079
{
80+
/*
81+
* This rule excludes export conditions from alphabetical sorting.
82+
* Since node.js processes export conditions in order and chooses the
83+
* first match, they need to be ordered logically, not alphabetically.
84+
*/
7185
"order": { "type": "asc" },
72-
"pathPattern": ".*"
86+
"pathPattern": "^(?!exports\\[).*" // All properties except export conditions
7387
}
74-
],
75-
"notice/notice": "off"
88+
]
7689
}
7790
},
7891
{

packages/.eslintrc.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@
134134
"extends": ["plugin:jsonc/recommended-with-jsonc"],
135135
"files": ["*.json"],
136136
"parser": "jsonc-eslint-parser",
137+
"rules": {
138+
"jsonc/sort-keys": ["warn"],
139+
"notice/notice": "off"
140+
}
141+
},
142+
{
143+
"extends": ["plugin:jsonc/recommended-with-jsonc"],
144+
"files": ["package.json"],
145+
"parser": "jsonc-eslint-parser",
137146
"rules": {
138147
"jsonc/sort-keys": [
139148
"warn",
@@ -183,14 +192,18 @@
183192
"cpu",
184193
"publishConfig"
185194
],
186-
"pathPattern": ".*" // Hits the all properties
195+
"pathPattern": "^$" // Top-level properties
187196
},
188197
{
198+
/*
199+
* This rule excludes export conditions from alphabetical sorting.
200+
* Since node.js processes export conditions in order and chooses the
201+
* first match, they need to be ordered logically, not alphabetically.
202+
*/
189203
"order": { "type": "asc" },
190-
"pathPattern": ".*"
204+
"pathPattern": "^(?!exports\\[).*" // All properties except export conditions
191205
}
192-
],
193-
"notice/notice": "off"
206+
]
194207
}
195208
}
196209
]

tools/.eslintrc.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@
127127
"extends": ["plugin:jsonc/recommended-with-jsonc"],
128128
"files": ["*.json"],
129129
"parser": "jsonc-eslint-parser",
130+
"rules": {
131+
"jsonc/sort-keys": ["warn"],
132+
"notice/notice": "off"
133+
}
134+
},
135+
{
136+
"extends": ["plugin:jsonc/recommended-with-jsonc"],
137+
"files": ["package.json"],
138+
"parser": "jsonc-eslint-parser",
130139
"rules": {
131140
"jsonc/sort-keys": [
132141
"warn",
@@ -176,14 +185,18 @@
176185
"cpu",
177186
"publishConfig"
178187
],
179-
"pathPattern": ".*" // Hits the all properties
188+
"pathPattern": "^$" // Top-level properties
180189
},
181190
{
191+
/*
192+
* This rule excludes export conditions from alphabetical sorting.
193+
* Since node.js processes export conditions in order and chooses the
194+
* first match, they need to be ordered logically, not alphabetically.
195+
*/
182196
"order": { "type": "asc" },
183-
"pathPattern": ".*"
197+
"pathPattern": "^(?!exports\\[).*" // All properties except export conditions
184198
}
185-
],
186-
"notice/notice": "off"
199+
]
187200
}
188201
}
189202
]

0 commit comments

Comments
 (0)