Skip to content

Commit e64f32b

Browse files
Jantherfvictorio
andauthored
Deprecated concat (#517)
* concat has been deprecated since prettier v2.3.0 * updating dependencies * added lines-and-columns which was an undeclared dependency for jest 27 * Remove remaining usages of the concat builder Co-authored-by: Franco Victorio <[email protected]>
1 parent 053ee47 commit e64f32b

65 files changed

Lines changed: 6354 additions & 4115 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 5874 additions & 3425 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,25 @@
6262
},
6363
"devDependencies": {
6464
"cross-env": "^7.0.3",
65-
"eslint": "^7.24.0",
65+
"eslint": "^7.27.0",
6666
"eslint-config-airbnb-base": "^14.2.1",
67-
"eslint-config-prettier": "^8.2.0",
68-
"eslint-plugin-import": "^2.23.2",
69-
"jest": "^26.6.3",
67+
"eslint-config-prettier": "^8.3.0",
68+
"eslint-plugin-import": "^2.23.3",
69+
"jest": "^27.0.1",
7070
"jest-mock-now": "^1.3.0",
7171
"jest-snapshot-serializer-ansi": "^1.0.0",
72-
"jest-snapshot-serializer-raw": "^1.1.0",
73-
"jest-watch-typeahead": "^0.6.2",
72+
"jest-snapshot-serializer-raw": "^1.2.0",
73+
"jest-watch-typeahead": "^0.6.4",
74+
"lines-and-columns": "^1.1.6",
7475
"outdent": "^0.8.0",
75-
"solc": "^0.8.3"
76+
"solc": "^0.8.4"
7677
},
7778
"dependencies": {
7879
"@solidity-parser/parser": "^0.13.0",
7980
"dir-to-object": "^2.0.0",
8081
"emoji-regex": "^9.2.2",
8182
"escape-string-regexp": "^4.0.0",
82-
"prettier": "^2.2.1",
83+
"prettier": "^2.3.0",
8384
"semver": "^7.3.5",
8485
"solidity-comments-extractor": "^0.0.7",
8586
"string-width": "^4.2.2"

src/binary-operator-printers/arithmetic.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {
22
doc: {
3-
builders: { group, line, concat, indent }
3+
builders: { group, line, indent }
44
}
55
} = require('prettier/standalone');
66
const comparison = require('./comparison');
@@ -38,18 +38,16 @@ module.exports = {
3838
const groupIfNecessary = groupIfNecessaryBuilder(path);
3939
const indentIfNecessary = indentIfNecessaryBuilder(path);
4040

41-
const right = concat([node.operator, line, path.call(print, 'right')]);
41+
const right = [node.operator, line, path.call(print, 'right')];
4242
// If it's a single binary operation, avoid having a small right
4343
// operand like - 1 on its own line
4444
const shouldGroup =
4545
node.left.type !== 'BinaryOperation' &&
4646
path.getParentNode().type !== 'BinaryOperation';
47-
return groupIfNecessary(
48-
concat([
49-
path.call(print, 'left'),
50-
' ',
51-
indentIfNecessary(shouldGroup ? group(right) : right)
52-
])
53-
);
47+
return groupIfNecessary([
48+
path.call(print, 'left'),
49+
' ',
50+
indentIfNecessary(shouldGroup ? group(right) : right)
51+
]);
5452
}
5553
};

src/binary-operator-printers/assignment.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {
22
doc: {
3-
builders: { group, line, concat, indent }
3+
builders: { group, line, indent }
44
}
55
} = require('prettier/standalone');
66

@@ -19,13 +19,12 @@ module.exports = {
1919
'/=',
2020
'%='
2121
].includes(op),
22-
print: (node, path, print) =>
23-
concat([
24-
path.call(print, 'left'),
25-
' ',
26-
node.operator,
27-
node.right.type === 'BinaryOperation'
28-
? group(indent(concat([line, path.call(print, 'right')])))
29-
: concat([' ', path.call(print, 'right')])
30-
])
22+
print: (node, path, print) => [
23+
path.call(print, 'left'),
24+
' ',
25+
node.operator,
26+
node.right.type === 'BinaryOperation'
27+
? group(indent([line, path.call(print, 'right')]))
28+
: [' ', path.call(print, 'right')]
29+
]
3130
};

src/binary-operator-printers/comparison.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {
22
doc: {
3-
builders: { group, line, concat, indent }
3+
builders: { group, line, indent }
44
}
55
} = require('prettier/standalone');
66

@@ -23,18 +23,16 @@ module.exports = {
2323
print: (node, path, print) => {
2424
const indentIfNecessary = indentIfNecessaryBuilder(path);
2525

26-
const right = concat([node.operator, line, path.call(print, 'right')]);
26+
const right = [node.operator, line, path.call(print, 'right')];
2727
// If it's a single binary operation, avoid having a small right
2828
// operand like - 1 on its own line
2929
const shouldGroup =
3030
node.left.type !== 'BinaryOperation' &&
3131
path.getParentNode().type !== 'BinaryOperation';
32-
return group(
33-
concat([
34-
path.call(print, 'left'),
35-
' ',
36-
indentIfNecessary(shouldGroup ? group(right) : right)
37-
])
38-
);
32+
return group([
33+
path.call(print, 'left'),
34+
' ',
35+
indentIfNecessary(shouldGroup ? group(right) : right)
36+
]);
3937
}
4038
};
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
const {
22
doc: {
3-
builders: { group, concat, ifBreak, indent, softline }
3+
builders: { group, ifBreak, indent, softline }
44
}
55
} = require('prettier/standalone');
66

77
module.exports = {
88
match: (op) => op === '**',
99
print: (node, path, print) => {
10-
const right = concat([
10+
const right = [
1111
ifBreak(' ', ''),
1212
node.operator,
1313
softline,
1414
path.call(print, 'right')
15-
]);
15+
];
1616
// If it's a single binary operation, avoid having a small right
1717
// operand like - 1 on its own line
1818
const shouldGroup =
1919
node.left.type !== 'BinaryOperation' &&
2020
path.getParentNode().type !== 'BinaryOperation';
21-
return group(
22-
concat([
23-
path.call(print, 'left'),
24-
indent(shouldGroup ? group(right) : right)
25-
])
26-
);
21+
return group([
22+
path.call(print, 'left'),
23+
indent(shouldGroup ? group(right) : right)
24+
]);
2725
}
2826
};

src/binary-operator-printers/logical.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {
22
doc: {
3-
builders: { group, line, concat, indent }
3+
builders: { group, line, indent }
44
}
55
} = require('prettier/standalone');
66

@@ -26,18 +26,16 @@ module.exports = {
2626
const groupIfNecessary = groupIfNecessaryBuilder(path);
2727
const indentIfNecessary = indentIfNecessaryBuilder(path);
2828

29-
const right = concat([node.operator, line, path.call(print, 'right')]);
29+
const right = [node.operator, line, path.call(print, 'right')];
3030
// If it's a single binary operation, avoid having a small right
3131
// operand like - 1 on its own line
3232
const shouldGroup =
3333
node.left.type !== 'BinaryOperation' &&
3434
path.getParentNode().type !== 'BinaryOperation';
35-
return groupIfNecessary(
36-
concat([
37-
path.call(print, 'left'),
38-
' ',
39-
indentIfNecessary(shouldGroup ? group(right) : right)
40-
])
41-
);
35+
return groupIfNecessary([
36+
path.call(print, 'left'),
37+
' ',
38+
indentIfNecessary(shouldGroup ? group(right) : right)
39+
]);
4240
}
4341
};

src/comments/printer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {
22
doc: {
3-
builders: { concat, hardline, join }
3+
builders: { hardline, join }
44
}
55
} = require('prettier');
66
const { hasNewline } = require('../prettier-comments/common/util');
@@ -17,7 +17,7 @@ function isIndentableBlockComment(comment) {
1717
function printIndentableBlockComment(comment) {
1818
const lines = comment.raw.split('\n');
1919

20-
return concat([
20+
return [
2121
'/*',
2222
join(
2323
hardline,
@@ -28,7 +28,7 @@ function printIndentableBlockComment(comment) {
2828
)
2929
),
3030
'*/'
31-
]);
31+
];
3232
}
3333

3434
function printComment(commentPath, options) {
@@ -47,7 +47,7 @@ function printComment(commentPath, options) {
4747
backwards: true
4848
})
4949
) {
50-
return concat([hardline, printed]);
50+
return [hardline, printed];
5151
}
5252
return printed;
5353
}

src/nodes/ArrayTypeName.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
const {
2-
doc: {
3-
builders: { concat }
4-
}
5-
} = require('prettier/standalone');
6-
71
const ArrayTypeName = {
8-
print: ({ node, path, print }) =>
9-
concat([
10-
path.call(print, 'baseTypeName'),
11-
'[',
12-
node.length ? path.call(print, 'length') : '',
13-
']'
14-
])
2+
print: ({ node, path, print }) => [
3+
path.call(print, 'baseTypeName'),
4+
'[',
5+
node.length ? path.call(print, 'length') : '',
6+
']'
7+
]
158
};
169

1710
module.exports = ArrayTypeName;

src/nodes/AssemblyBlock.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {
22
doc: {
3-
builders: { concat, hardline }
3+
builders: { hardline }
44
}
55
} = require('prettier/standalone');
66

@@ -9,18 +9,17 @@ const printComments = require('./print-comments');
99
const printPreservingEmptyLines = require('./print-preserving-empty-lines');
1010

1111
const AssemblyBlock = {
12-
print: ({ node, options, path, print }) =>
13-
concat([
14-
'{',
15-
printSeparatedItem(
16-
concat([
17-
printPreservingEmptyLines(path, 'operations', options, print),
18-
printComments(node, path, options)
19-
]),
20-
{ firstSeparator: hardline }
21-
),
22-
'}'
23-
])
12+
print: ({ node, options, path, print }) => [
13+
'{',
14+
printSeparatedItem(
15+
[
16+
printPreservingEmptyLines(path, 'operations', options, print),
17+
printComments(node, path, options)
18+
],
19+
{ firstSeparator: hardline }
20+
),
21+
'}'
22+
]
2423
};
2524

2625
module.exports = AssemblyBlock;

0 commit comments

Comments
 (0)