prettier-plugin-solidity 1.1.0 → 1.1.2
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/dist/standalone.js +1 -1
- package/dist/standalone.js.map +1 -1
- package/package.json +5 -8
- package/src/clean.js +4 -6
- package/src/common/printer-helpers.js +116 -0
- package/src/common/util.js +6 -1
- package/src/nodes/AssemblyBlock.js +5 -3
- package/src/nodes/AssemblyCall.js +1 -1
- package/src/nodes/AssemblyFunctionDefinition.js +4 -2
- package/src/nodes/AssemblyLocalDefinition.js +1 -1
- package/src/nodes/BinaryOperation.js +10 -4
- package/src/nodes/Block.js +4 -2
- package/src/nodes/CatchClause.js +1 -1
- package/src/nodes/ContractDefinition.js +6 -4
- package/src/nodes/CustomErrorDefinition.js +1 -1
- package/src/nodes/DoWhileStatement.js +1 -1
- package/src/nodes/EnumDefinition.js +1 -1
- package/src/nodes/EventDefinition.js +1 -1
- package/src/nodes/ExpressionStatement.js +2 -2
- package/src/nodes/ForStatement.js +1 -1
- package/src/nodes/FunctionCall.js +1 -1
- package/src/nodes/FunctionDefinition.js +7 -7
- package/src/nodes/FunctionTypeName.js +1 -1
- package/src/nodes/IfStatement.js +4 -2
- package/src/nodes/ImportDirective.js +1 -1
- package/src/nodes/InheritanceSpecifier.js +1 -1
- package/src/nodes/InlineAssemblyStatement.js +1 -1
- package/src/nodes/Mapping.js +15 -7
- package/src/nodes/ModifierDefinition.js +1 -1
- package/src/nodes/ModifierInvocation.js +4 -2
- package/src/nodes/NameValueList.js +1 -1
- package/src/nodes/SourceUnit.js +1 -1
- package/src/nodes/StructDefinition.js +1 -1
- package/src/nodes/TryStatement.js +4 -2
- package/src/nodes/TupleExpression.js +1 -1
- package/src/nodes/UsingForDeclaration.js +1 -1
- package/src/nodes/VariableDeclaration.js +1 -1
- package/src/nodes/VariableDeclarationStatement.js +1 -1
- package/src/nodes/WhileStatement.js +1 -1
- package/src/parser.js +1 -1
- package/src/printer.js +5 -4
- package/src/nodes/print-comments.js +0 -27
- package/src/nodes/print-preserving-empty-lines.js +0 -53
- package/src/nodes/print-separated-item.js +0 -21
- package/src/nodes/print-separated-list.js +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-solidity",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A Prettier Plugin for automatically formatting your Solidity code.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"browser": "./dist/standalone.js",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"c8": "^7.12.0",
|
|
84
84
|
"cross-env": "^7.0.3",
|
|
85
85
|
"dir-to-object": "^2.0.0",
|
|
86
|
-
"eslint": "^8.
|
|
86
|
+
"eslint": "^8.31.0",
|
|
87
87
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
88
88
|
"eslint-config-prettier": "^8.5.0",
|
|
89
89
|
"eslint-plugin-import": "^2.26.0",
|
|
@@ -102,15 +102,12 @@
|
|
|
102
102
|
"webpack-cli": "^5.0.1"
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"@solidity-parser/parser": "^0.
|
|
106
|
-
"emoji-regex": "^10.2.1",
|
|
107
|
-
"escape-string-regexp": "^4.0.0",
|
|
105
|
+
"@solidity-parser/parser": "^0.15.0",
|
|
108
106
|
"semver": "^7.3.8",
|
|
109
|
-
"solidity-comments-extractor": "^0.0.7"
|
|
110
|
-
"string-width": "^4.2.3"
|
|
107
|
+
"solidity-comments-extractor": "^0.0.7"
|
|
111
108
|
},
|
|
112
109
|
"peerDependencies": {
|
|
113
|
-
"prettier": "
|
|
110
|
+
"prettier": ">=2.3.0 || >=3.0.0-alpha.0"
|
|
114
111
|
},
|
|
115
112
|
"browserslist": {
|
|
116
113
|
"production": [
|
package/src/clean.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
}
|
|
1
|
+
// Prettier offers a clean way to define ignored properties.
|
|
2
|
+
const ignoredProperties = new Set(['loc', 'range', 'comments']);
|
|
3
|
+
function clean(/* ast, newObj, parent */) {}
|
|
4
|
+
clean.ignoredProperties = ignoredProperties;
|
|
7
5
|
|
|
8
6
|
module.exports = clean;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const {
|
|
2
|
+
doc: {
|
|
3
|
+
builders: { group, indent, join, line, softline, hardline }
|
|
4
|
+
},
|
|
5
|
+
util: { isNextLineEmptyAfterIndex }
|
|
6
|
+
} = require('prettier');
|
|
7
|
+
const { prettierVersionSatisfies } = require('./util');
|
|
8
|
+
|
|
9
|
+
const printComments = (node, path, options, filter = () => true) => {
|
|
10
|
+
if (!node.comments) return '';
|
|
11
|
+
const doc = join(
|
|
12
|
+
line,
|
|
13
|
+
path
|
|
14
|
+
.map((commentPath) => {
|
|
15
|
+
const comment = commentPath.getValue();
|
|
16
|
+
if (comment.trailing || comment.leading || comment.printed) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (!filter(comment)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
comment.printed = true;
|
|
23
|
+
return options.printer.printComment(commentPath);
|
|
24
|
+
}, 'comments')
|
|
25
|
+
.filter(Boolean)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// The following if statement will never be 100% covered in a single run
|
|
29
|
+
// since it depends on the version of Prettier being used.
|
|
30
|
+
// Mocking the behaviour will introduce a lot of maintenance in the tests.
|
|
31
|
+
/* c8 ignore start */
|
|
32
|
+
return prettierVersionSatisfies('^2.3.0')
|
|
33
|
+
? doc.parts // Prettier V2
|
|
34
|
+
: doc; // Prettier V3
|
|
35
|
+
/* c8 ignore stop */
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function printPreservingEmptyLines(path, key, options, print) {
|
|
39
|
+
const parts = [];
|
|
40
|
+
path.each((childPath, index) => {
|
|
41
|
+
const node = childPath.getValue();
|
|
42
|
+
const nodeType = node.type;
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
// Avoid adding a hardline at the beginning of the document.
|
|
46
|
+
parts.length !== 0 &&
|
|
47
|
+
// LabelDefinition adds a dedented line so we don't have to prepend a
|
|
48
|
+
// hardline.
|
|
49
|
+
nodeType !== 'LabelDefinition'
|
|
50
|
+
) {
|
|
51
|
+
parts.push(hardline);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (index > 0) {
|
|
55
|
+
if (
|
|
56
|
+
['ContractDefinition', 'FunctionDefinition'].includes(nodeType) &&
|
|
57
|
+
parts[parts.length - 2] !== hardline
|
|
58
|
+
) {
|
|
59
|
+
parts.push(hardline);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
parts.push(print(childPath));
|
|
64
|
+
|
|
65
|
+
if (
|
|
66
|
+
isNextLineEmptyAfterIndex(
|
|
67
|
+
options.originalText,
|
|
68
|
+
options.locEnd(node) + 1
|
|
69
|
+
) ||
|
|
70
|
+
nodeType === 'FunctionDefinition'
|
|
71
|
+
) {
|
|
72
|
+
parts.push(hardline);
|
|
73
|
+
}
|
|
74
|
+
}, key);
|
|
75
|
+
|
|
76
|
+
if (parts.length > 1 && parts[parts.length - 1] === hardline) {
|
|
77
|
+
parts.pop();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return parts;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// This function will add an indentation to the `item` and separate it from the
|
|
84
|
+
// rest of the `doc` in most cases by a `softline`.
|
|
85
|
+
const printSeparatedItem = (
|
|
86
|
+
item,
|
|
87
|
+
{
|
|
88
|
+
firstSeparator = softline,
|
|
89
|
+
lastSeparator = firstSeparator,
|
|
90
|
+
grouped = true
|
|
91
|
+
} = {}
|
|
92
|
+
) => {
|
|
93
|
+
const doc = [indent([firstSeparator, item]), lastSeparator];
|
|
94
|
+
return grouped ? group(doc) : doc;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// This function will add an indentation to the `list` and separate it from the
|
|
98
|
+
// rest of the `doc` in most cases by a `softline`.
|
|
99
|
+
// the list itself will be printed with a separator that in most cases is a
|
|
100
|
+
// comma (,) and a `line`
|
|
101
|
+
const printSeparatedList = (
|
|
102
|
+
list,
|
|
103
|
+
{ firstSeparator, separator = [',', line], lastSeparator, grouped } = {}
|
|
104
|
+
) =>
|
|
105
|
+
printSeparatedItem(join(separator, list), {
|
|
106
|
+
firstSeparator,
|
|
107
|
+
lastSeparator,
|
|
108
|
+
grouped
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
module.exports = {
|
|
112
|
+
printComments,
|
|
113
|
+
printPreservingEmptyLines,
|
|
114
|
+
printSeparatedList,
|
|
115
|
+
printSeparatedItem
|
|
116
|
+
};
|
package/src/common/util.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const {
|
|
2
|
-
util: { getNextNonSpaceNonCommentCharacterIndex, makeString }
|
|
2
|
+
util: { getNextNonSpaceNonCommentCharacterIndex, makeString },
|
|
3
|
+
version
|
|
3
4
|
} = require('prettier');
|
|
5
|
+
const satisfies = require('semver/functions/satisfies');
|
|
6
|
+
|
|
7
|
+
const prettierVersionSatisfies = (range) => satisfies(version, range);
|
|
4
8
|
|
|
5
9
|
function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
|
|
6
10
|
return text.charAt(
|
|
@@ -55,5 +59,6 @@ function hasNodeIgnoreComment(node) {
|
|
|
55
59
|
module.exports = {
|
|
56
60
|
getNextNonSpaceNonCommentCharacter,
|
|
57
61
|
printString,
|
|
62
|
+
prettierVersionSatisfies,
|
|
58
63
|
hasNodeIgnoreComment
|
|
59
64
|
};
|
|
@@ -4,9 +4,11 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const {
|
|
8
|
+
printComments,
|
|
9
|
+
printPreservingEmptyLines,
|
|
10
|
+
printSeparatedItem
|
|
11
|
+
} = require('../common/printer-helpers');
|
|
10
12
|
|
|
11
13
|
const AssemblyBlock = {
|
|
12
14
|
print: ({ node, options, path, print }) => [
|
|
@@ -4,8 +4,10 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const {
|
|
8
|
+
printSeparatedItem,
|
|
9
|
+
printSeparatedList
|
|
10
|
+
} = require('../common/printer-helpers');
|
|
9
11
|
|
|
10
12
|
const AssemblyFunctionDefinition = {
|
|
11
13
|
print: ({ node, path, print }) => [
|
|
@@ -3,11 +3,17 @@ const printers = require('../binary-operator-printers');
|
|
|
3
3
|
|
|
4
4
|
const BinaryOperation = {
|
|
5
5
|
print: ({ node, path, print, options }) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const binaryOperationPrinter = Object.values(printers).find((printer) =>
|
|
7
|
+
printer.match(node.operator)
|
|
8
|
+
);
|
|
9
|
+
if (binaryOperationPrinter === undefined) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
`Assertion error: no printer found for operator ${JSON.stringify(
|
|
12
|
+
node.operator
|
|
13
|
+
)}`
|
|
14
|
+
);
|
|
10
15
|
}
|
|
16
|
+
return binaryOperationPrinter.print(node, path, print, options);
|
|
11
17
|
}
|
|
12
18
|
};
|
|
13
19
|
|
package/src/nodes/Block.js
CHANGED
|
@@ -4,8 +4,10 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const {
|
|
8
|
+
printComments,
|
|
9
|
+
printPreservingEmptyLines
|
|
10
|
+
} = require('../common/printer-helpers');
|
|
9
11
|
|
|
10
12
|
const Block = {
|
|
11
13
|
print: ({ node, options, path, print }) =>
|
package/src/nodes/CatchClause.js
CHANGED
|
@@ -4,10 +4,12 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const {
|
|
8
|
+
printComments,
|
|
9
|
+
printPreservingEmptyLines,
|
|
10
|
+
printSeparatedItem,
|
|
11
|
+
printSeparatedList
|
|
12
|
+
} = require('../common/printer-helpers');
|
|
11
13
|
|
|
12
14
|
const inheritance = (node, path, print) =>
|
|
13
15
|
node.baseContracts.length > 0
|
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const printComments = require('
|
|
7
|
+
const { printComments } = require('../common/printer-helpers');
|
|
8
8
|
|
|
9
9
|
const ExpressionStatement = {
|
|
10
10
|
print: ({ node, options, path, print }) => {
|
|
@@ -15,7 +15,7 @@ const ExpressionStatement = {
|
|
|
15
15
|
if (parent.type === 'IfStatement') {
|
|
16
16
|
if (node.comments && node.comments.length) {
|
|
17
17
|
const comments = printComments(node, path, options);
|
|
18
|
-
if (comments && comments.
|
|
18
|
+
if (comments && comments.length) {
|
|
19
19
|
parts.push(comments);
|
|
20
20
|
parts.push(hardline);
|
|
21
21
|
}
|
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const printSeparatedList = require('
|
|
7
|
+
const { printSeparatedList } = require('../common/printer-helpers');
|
|
8
8
|
|
|
9
9
|
const initExpression = (node, path, print) =>
|
|
10
10
|
node.initExpression ? path.call(print, 'initExpression') : '';
|
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const printSeparatedList = require('
|
|
7
|
+
const { printSeparatedList } = require('../common/printer-helpers');
|
|
8
8
|
|
|
9
9
|
const printObject = (path, print, options) => {
|
|
10
10
|
const identifiers = path.map(print, 'identifiers');
|
|
@@ -5,9 +5,11 @@ const {
|
|
|
5
5
|
util: { getNextNonSpaceNonCommentCharacterIndex }
|
|
6
6
|
} = require('prettier');
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const {
|
|
9
|
+
printComments,
|
|
10
|
+
printSeparatedItem,
|
|
11
|
+
printSeparatedList
|
|
12
|
+
} = require('../common/printer-helpers');
|
|
11
13
|
|
|
12
14
|
const functionName = (node, options) => {
|
|
13
15
|
if (node.isConstructor && !node.name) return 'constructor';
|
|
@@ -47,7 +49,7 @@ const parameters = (parametersType, node, path, print, options) => {
|
|
|
47
49
|
)
|
|
48
50
|
) === ')'
|
|
49
51
|
);
|
|
50
|
-
return parameterComments.
|
|
52
|
+
return parameterComments.length > 0
|
|
51
53
|
? printSeparatedItem(parameterComments)
|
|
52
54
|
: '';
|
|
53
55
|
}
|
|
@@ -73,9 +75,7 @@ const override = (node, path, print) => {
|
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
const stateMutability = (node) =>
|
|
76
|
-
node.stateMutability
|
|
77
|
-
? [line, node.stateMutability]
|
|
78
|
-
: '';
|
|
78
|
+
node.stateMutability ? [line, node.stateMutability] : '';
|
|
79
79
|
|
|
80
80
|
const modifiers = (node, path, print) =>
|
|
81
81
|
node.modifiers.length > 0
|
package/src/nodes/IfStatement.js
CHANGED
|
@@ -4,8 +4,10 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const {
|
|
8
|
+
printComments,
|
|
9
|
+
printSeparatedItem
|
|
10
|
+
} = require('../common/printer-helpers');
|
|
9
11
|
|
|
10
12
|
const printTrueBody = (node, path, print) => {
|
|
11
13
|
if (node.trueBody.type === 'Block') {
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
const coerce = require('semver/functions/coerce');
|
|
7
7
|
const satisfies = require('semver/functions/satisfies');
|
|
8
8
|
|
|
9
|
-
const printSeparatedList = require('
|
|
9
|
+
const { printSeparatedList } = require('../common/printer-helpers');
|
|
10
10
|
const { printString } = require('../common/util');
|
|
11
11
|
|
|
12
12
|
const ImportDirective = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @TODO: add support for assembly language specifier
|
|
2
2
|
const { printString } = require('../common/util');
|
|
3
|
-
const printSeparatedList = require('
|
|
3
|
+
const { printSeparatedList } = require('../common/printer-helpers');
|
|
4
4
|
|
|
5
5
|
const InlineAssemblyStatement = {
|
|
6
6
|
print: ({ node, path, print, options }) => [
|
package/src/nodes/Mapping.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
const Mapping = {
|
|
2
|
-
print: ({ path, print }) =>
|
|
3
|
-
|
|
4
|
-
path.call(print, '
|
|
5
|
-
|
|
6
|
-
path.call(print, '
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
print: ({ path, print }) => {
|
|
3
|
+
const keyType = path.call(print, 'keyType');
|
|
4
|
+
const keyName = path.call(print, 'keyName');
|
|
5
|
+
const valueType = path.call(print, 'valueType');
|
|
6
|
+
const valueName = path.call(print, 'valueName');
|
|
7
|
+
return [
|
|
8
|
+
'mapping(',
|
|
9
|
+
keyType,
|
|
10
|
+
keyName ? ` ${keyName}` : '',
|
|
11
|
+
' => ',
|
|
12
|
+
valueType,
|
|
13
|
+
valueName ? ` ${valueName}` : '',
|
|
14
|
+
')'
|
|
15
|
+
];
|
|
16
|
+
}
|
|
9
17
|
};
|
|
10
18
|
|
|
11
19
|
module.exports = Mapping;
|
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const printSeparatedList = require('
|
|
7
|
+
const { printSeparatedList } = require('../common/printer-helpers');
|
|
8
8
|
|
|
9
9
|
const modifierParameters = (node, path, print) => {
|
|
10
10
|
if (node.parameters && node.parameters.length > 0) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const {
|
|
2
|
+
printComments,
|
|
3
|
+
printSeparatedList
|
|
4
|
+
} = require('../common/printer-helpers');
|
|
3
5
|
|
|
4
6
|
const modifierArguments = (node, path, print, options) => {
|
|
5
7
|
if (node.arguments) {
|
package/src/nodes/SourceUnit.js
CHANGED
|
@@ -4,8 +4,10 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const {
|
|
8
|
+
printSeparatedItem,
|
|
9
|
+
printSeparatedList
|
|
10
|
+
} = require('../common/printer-helpers');
|
|
9
11
|
|
|
10
12
|
const returnParameters = (node, path, print) =>
|
|
11
13
|
node.returnParameters
|
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
|
-
const printSeparatedList = require('
|
|
7
|
+
const { printSeparatedList } = require('../common/printer-helpers');
|
|
8
8
|
|
|
9
9
|
const embraceVariables = (doc, embrace) =>
|
|
10
10
|
embrace ? ['(', printSeparatedList(doc), ')'] : doc;
|
package/src/parser.js
CHANGED
|
@@ -14,7 +14,7 @@ const tryHug = (node, operators) => {
|
|
|
14
14
|
return node;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
function parse(text, _parsers, options) {
|
|
17
|
+
function parse(text, _parsers, options = _parsers) {
|
|
18
18
|
const compiler = coerce(options.compiler);
|
|
19
19
|
const parsed = parser.parse(text, { loc: true, range: true });
|
|
20
20
|
parsed.comments = extractComments(text);
|
package/src/printer.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
const prettier = require('prettier');
|
|
2
|
-
const satisfies = require('semver/functions/satisfies');
|
|
3
1
|
const nodes = require('./nodes');
|
|
4
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
hasNodeIgnoreComment,
|
|
4
|
+
prettierVersionSatisfies
|
|
5
|
+
} = require('./common/util');
|
|
5
6
|
const ignoreComments = require('./comments/ignore');
|
|
6
7
|
|
|
7
8
|
let checked = false;
|
|
8
9
|
|
|
9
10
|
function prettierVersionCheck() {
|
|
10
11
|
if (checked) return;
|
|
11
|
-
if (!
|
|
12
|
+
if (!prettierVersionSatisfies('>=2.3.0 || >=3.0.0-alpha.0')) {
|
|
12
13
|
throw new Error(
|
|
13
14
|
'The version of prettier in your node-modules does not satisfy the required ">=2.3.0" constraint. Please update the version of Prettier.'
|
|
14
15
|
);
|