Skip to content

Commit c79e44f

Browse files
committed
Remove auto add comma feature as it will caurse some bug
1 parent 1f91b50 commit c79e44f

File tree

2 files changed

+7
-27
lines changed

2 files changed

+7
-27
lines changed

lib/sort-json-core.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ function sortObject(object, sortOrder) {
9090
}
9191

9292
function selectedTextToSortedText(selectedText, indent, sortOrder) {
93-
var needTailingComma = checkIfNeedTailingComma(selectedText);
94-
9593
var autoIndent = getAutoIndent(selectedText, indent);
9694

9795
const declarePrefix = 'const a = ';
@@ -121,7 +119,6 @@ function selectedTextToSortedText(selectedText, indent, sortOrder) {
121119
sortedText = swithCorrectIndent(sortedText, indent);
122120
sortedText = removeWrapper(sortedText, declarePrefix);
123121
sortedText = addAutoIndent(sortedText, autoIndent);
124-
sortedText = addTaillingComma(sortedText, needTailingComma);
125122

126123
return sortedText;
127124
}

test/extension.test.js

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -194,31 +194,14 @@ suite('Extension Tests', function() {
194194
);
195195
});
196196

197-
test('Auto add comma', function() {
198-
var jsObject = `{
199-
b: 'b',
200-
a: 'a',
201-
}`;
202-
203-
var result = sorter.sort(jsObject, 4, ['asc'], {});
204-
205-
assert.equal(
206-
result,
207-
`{
208-
a: 'a',
209-
b: 'b',
210-
}`
211-
);
212-
});
213-
214197
test('Support line comments', function() {
215198
var jsObject = `{
216199
b: 2,
217200
// some comment
218201
a: 1,
219202
// another comment
220203
d: 5,
221-
c: 4,
204+
c: 4
222205
}`;
223206

224207
var result = sorter.sort(jsObject, 4, ['asc'], {});
@@ -231,7 +214,7 @@ suite('Extension Tests', function() {
231214
b: 2,
232215
c: 4,
233216
// another comment
234-
d: 5,
217+
d: 5
235218
}`
236219
);
237220
});
@@ -256,7 +239,7 @@ suite('Extension Tests', function() {
256239
b: 2,
257240
c: 4,
258241
// another comment
259-
d: 5,
242+
d: 5
260243
}`
261244
);
262245
});
@@ -303,7 +286,7 @@ suite('Extension Tests', function() {
303286
`{
304287
a: '\\' test',
305288
b: 'test \\'',
306-
c: 'test \\' test',
289+
c: 'test \\' test'
307290
}`
308291
);
309292
});
@@ -314,7 +297,7 @@ suite('Extension Tests', function() {
314297
b: 'test " test',
315298
e: "test' test",
316299
a: "test' test",
317-
c: 'test """" test',
300+
c: 'test """" test'
318301
}`;
319302

320303
var result = sorter.sort(jsObject, 4, ['asc'], {});
@@ -326,7 +309,7 @@ suite('Extension Tests', function() {
326309
b: 'test " test',
327310
c: 'test """" test',
328311
d: "\\" test",
329-
e: "test' test",
312+
e: "test' test"
330313
}`
331314
);
332315
});
@@ -347,7 +330,7 @@ suite('Extension Tests', function() {
347330
'a': 1,
348331
'b': 'test',
349332
a: 1,
350-
b: 'test',
333+
b: 'test'
351334
}`
352335
);
353336
});

0 commit comments

Comments
 (0)