prettier-plugin-solidity 1.0.0-dev.24 → 1.0.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.
- package/.c8rc +11 -0
- package/README.md +2 -2
- package/coverage/clover.xml +215 -209
- package/coverage/coverage-final.json +45 -44
- package/coverage/lcov-report/index.html +7 -7
- package/coverage/lcov-report/src/binary-operator-printers/arithmetic.js.html +18 -18
- package/coverage/lcov-report/src/binary-operator-printers/assignment.js.html +3 -3
- package/coverage/lcov-report/src/binary-operator-printers/bit.js.html +2 -2
- package/coverage/lcov-report/src/binary-operator-printers/comparison.js.html +11 -11
- package/coverage/lcov-report/src/binary-operator-printers/exponentiation.js.html +8 -23
- package/coverage/lcov-report/src/binary-operator-printers/index.html +1 -1
- package/coverage/lcov-report/src/binary-operator-printers/index.js.html +2 -2
- package/coverage/lcov-report/src/binary-operator-printers/logical.js.html +1 -1
- package/coverage/lcov-report/src/binary-operator-printers/shift.js.html +1 -1
- package/coverage/lcov-report/src/clean.js.html +3 -3
- package/coverage/lcov-report/src/comments/handler.js.html +7 -7
- package/coverage/lcov-report/src/comments/handlers/handleContractDefinitionComments.js.html +3 -3
- package/coverage/lcov-report/src/comments/handlers/handleModifierInvocationComments.js.html +3 -3
- package/coverage/lcov-report/src/comments/handlers/index.html +1 -1
- package/coverage/lcov-report/src/comments/handlers/index.js.html +1 -1
- package/coverage/lcov-report/src/comments/ignore.js.html +1 -1
- package/coverage/lcov-report/src/comments/index.html +1 -1
- package/coverage/lcov-report/src/comments/index.js.html +1 -1
- package/coverage/lcov-report/src/comments/printer.js.html +4 -4
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.js.html +2 -2
- package/coverage/lcov-report/src/loc.js.html +5 -5
- package/coverage/lcov-report/src/nodes/ArrayTypeName.js.html +1 -1
- package/coverage/lcov-report/src/nodes/AssemblyAssignment.js.html +8 -11
- package/coverage/lcov-report/src/nodes/AssemblyBlock.js.html +2 -2
- package/coverage/lcov-report/src/nodes/AssemblyCall.js.html +2 -2
- package/coverage/lcov-report/src/nodes/AssemblyCase.js.html +1 -1
- package/coverage/lcov-report/src/nodes/AssemblyFor.js.html +1 -1
- package/coverage/lcov-report/src/nodes/AssemblyFunctionDefinition.js.html +2 -2
- package/coverage/lcov-report/src/nodes/AssemblyIf.js.html +1 -1
- package/coverage/lcov-report/src/nodes/AssemblyLocalDefinition.js.html +5 -5
- package/coverage/lcov-report/src/nodes/AssemblyMemberAccess.js.html +1 -1
- package/coverage/lcov-report/src/nodes/AssemblyStackAssignment.js.html +112 -0
- package/coverage/lcov-report/src/nodes/AssemblySwitch.js.html +1 -1
- package/coverage/lcov-report/src/nodes/BinaryOperation.js.html +5 -5
- package/coverage/lcov-report/src/nodes/Block.js.html +2 -2
- package/coverage/lcov-report/src/nodes/BooleanLiteral.js.html +2 -2
- package/coverage/lcov-report/src/nodes/Break.js.html +1 -1
- package/coverage/lcov-report/src/nodes/BreakStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/CatchClause.js.html +1 -1
- package/coverage/lcov-report/src/nodes/Conditional.js.html +1 -1
- package/coverage/lcov-report/src/nodes/Continue.js.html +1 -1
- package/coverage/lcov-report/src/nodes/ContinueStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/ContractDefinition.js.html +4 -4
- package/coverage/lcov-report/src/nodes/CustomErrorDefinition.js.html +1 -1
- package/coverage/lcov-report/src/nodes/DecimalNumber.js.html +2 -2
- package/coverage/lcov-report/src/nodes/DoWhileStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/ElementaryTypeName.js.html +3 -3
- package/coverage/lcov-report/src/nodes/EmitStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/EnumDefinition.js.html +1 -1
- package/coverage/lcov-report/src/nodes/EnumValue.js.html +1 -1
- package/coverage/lcov-report/src/nodes/EventDefinition.js.html +1 -1
- package/coverage/lcov-report/src/nodes/ExpressionStatement.js.html +7 -7
- package/coverage/lcov-report/src/nodes/FileLevelConstant.js.html +1 -1
- package/coverage/lcov-report/src/nodes/ForStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/FunctionCall.js.html +13 -13
- package/coverage/lcov-report/src/nodes/FunctionDefinition.js.html +16 -16
- package/coverage/lcov-report/src/nodes/FunctionTypeName.js.html +1 -1
- package/coverage/lcov-report/src/nodes/HexLiteral.js.html +1 -1
- package/coverage/lcov-report/src/nodes/HexNumber.js.html +1 -1
- package/coverage/lcov-report/src/nodes/Identifier.js.html +2 -2
- package/coverage/lcov-report/src/nodes/IfStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/ImportDirective.js.html +1 -1
- package/coverage/lcov-report/src/nodes/IndexAccess.js.html +1 -1
- package/coverage/lcov-report/src/nodes/IndexRangeAccess.js.html +1 -1
- package/coverage/lcov-report/src/nodes/InheritanceSpecifier.js.html +1 -1
- package/coverage/lcov-report/src/nodes/InlineAssemblyStatement.js.html +2 -2
- package/coverage/lcov-report/src/nodes/LabelDefinition.js.html +1 -1
- package/coverage/lcov-report/src/nodes/Mapping.js.html +1 -1
- package/coverage/lcov-report/src/nodes/MemberAccess.js.html +21 -21
- package/coverage/lcov-report/src/nodes/ModifierDefinition.js.html +1 -1
- package/coverage/lcov-report/src/nodes/ModifierInvocation.js.html +1 -1
- package/coverage/lcov-report/src/nodes/NameValueExpression.js.html +1 -1
- package/coverage/lcov-report/src/nodes/NameValueList.js.html +1 -1
- package/coverage/lcov-report/src/nodes/NewExpression.js.html +1 -1
- package/coverage/lcov-report/src/nodes/NumberLiteral.js.html +2 -2
- package/coverage/lcov-report/src/nodes/PragmaDirective.js.html +2 -2
- package/coverage/lcov-report/src/nodes/ReturnStatement.js.html +4 -4
- package/coverage/lcov-report/src/nodes/RevertStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/SourceUnit.js.html +2 -2
- package/coverage/lcov-report/src/nodes/StateVariableDeclaration.js.html +6 -6
- package/coverage/lcov-report/src/nodes/StringLiteral.js.html +4 -4
- package/coverage/lcov-report/src/nodes/StructDefinition.js.html +1 -1
- package/coverage/lcov-report/src/nodes/ThrowStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/TryStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/TupleExpression.js.html +1 -1
- package/coverage/lcov-report/src/nodes/TypeDefinition.js.html +1 -1
- package/coverage/lcov-report/src/nodes/UnaryOperation.js.html +1 -1
- package/coverage/lcov-report/src/nodes/UncheckedStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/UserDefinedTypeName.js.html +1 -1
- package/coverage/lcov-report/src/nodes/UsingForDeclaration.js.html +1 -1
- package/coverage/lcov-report/src/nodes/VariableDeclaration.js.html +9 -9
- package/coverage/lcov-report/src/nodes/VariableDeclarationStatement.js.html +8 -8
- package/coverage/lcov-report/src/nodes/WhileStatement.js.html +1 -1
- package/coverage/lcov-report/src/nodes/index.html +19 -4
- package/coverage/lcov-report/src/nodes/index.js.html +6 -3
- package/coverage/lcov-report/src/nodes/print-comments.js.html +2 -2
- package/coverage/lcov-report/src/nodes/print-preserving-empty-lines.js.html +15 -15
- package/coverage/lcov-report/src/nodes/print-separated-item.js.html +3 -3
- package/coverage/lcov-report/src/nodes/print-separated-list.js.html +3 -3
- package/coverage/lcov-report/src/options.js.html +1 -1
- package/coverage/lcov-report/src/parser.js.html +20 -20
- package/coverage/lcov-report/src/printer.js.html +8 -8
- package/coverage/lcov.info +487 -473
- package/jest.config.js +5 -20
- package/package.json +11 -9
- package/src/binary-operator-printers/exponentiation.js +2 -7
- package/src/binary-operator-printers/index.js +1 -1
- package/src/nodes/AssemblyAssignment.js +5 -6
- package/src/nodes/AssemblyStackAssignment.js +9 -0
- package/src/nodes/FunctionDefinition.js +19 -17
- package/src/nodes/index.js +2 -1
package/jest.config.js
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
|
-
const FULL_TEST = Boolean(process.env.FULL_TEST);
|
|
2
1
|
const TEST_STANDALONE = Boolean(process.env.TEST_STANDALONE);
|
|
3
2
|
|
|
4
3
|
module.exports = {
|
|
5
|
-
collectCoverage: FULL_TEST,
|
|
6
|
-
collectCoverageFrom: [
|
|
7
|
-
'scripts/**/*.js',
|
|
8
|
-
'!scripts/generateIndexes.js',
|
|
9
|
-
'src/**/*.js',
|
|
10
|
-
'!<rootDir>/node_modules/',
|
|
11
|
-
'!src/prettier-comments/**/*.js'
|
|
12
|
-
],
|
|
13
|
-
coverageDirectory: './coverage/',
|
|
14
|
-
coveragePathIgnorePatterns: ['/node_modules/', '/scripts/'],
|
|
15
|
-
coverageThreshold: {
|
|
16
|
-
global: {
|
|
17
|
-
branches: 100,
|
|
18
|
-
functions: 100,
|
|
19
|
-
lines: 100,
|
|
20
|
-
statements: 100
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
4
|
moduleNameMapper: {
|
|
24
5
|
'^prettier$': TEST_STANDALONE
|
|
25
6
|
? '<rootDir>/node_modules/prettier/standalone'
|
|
26
7
|
: '<rootDir>/node_modules/prettier'
|
|
27
8
|
},
|
|
9
|
+
runner: 'jest-light-runner',
|
|
28
10
|
setupFiles: ['<rootDir>/tests/config/setup.js'],
|
|
29
11
|
snapshotSerializers: [
|
|
30
12
|
'jest-snapshot-serializer-raw',
|
|
31
13
|
'jest-snapshot-serializer-ansi'
|
|
32
14
|
],
|
|
33
15
|
testEnvironment: 'node',
|
|
34
|
-
|
|
16
|
+
testMatch: [
|
|
17
|
+
'<rootDir>/tests/format/**/jsfmt.spec.js',
|
|
18
|
+
'<rootDir>/tests/unit/**/*.js'
|
|
19
|
+
],
|
|
35
20
|
transform: {},
|
|
36
21
|
watchPlugins: [
|
|
37
22
|
'jest-watch-typeahead/filename',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-solidity",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A Prettier Plugin for automatically formatting your Solidity code.",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"scripts": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"lint:fix": "npm run eslint -- --fix && npm run prettier -- --write",
|
|
11
11
|
"prettier": "prettier './*.{js,json,md,yml}' '{scripts,src,tests}/**/*.js'",
|
|
12
12
|
"test": "jest",
|
|
13
|
-
"test:all": "cross-env FULL_TEST=1 jest"
|
|
13
|
+
"test:all": "cross-env FULL_TEST=1 c8 jest"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -66,27 +66,29 @@
|
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@babel/code-frame": "^7.18.6",
|
|
69
|
+
"c8": "^7.12.0",
|
|
69
70
|
"cross-env": "^7.0.3",
|
|
70
71
|
"dir-to-object": "^2.0.0",
|
|
71
|
-
"eslint": "^8.
|
|
72
|
+
"eslint": "^8.27.0",
|
|
72
73
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
73
74
|
"eslint-config-prettier": "^8.5.0",
|
|
74
75
|
"eslint-plugin-import": "^2.26.0",
|
|
75
|
-
"jest": "^29.
|
|
76
|
+
"jest": "^29.3.1",
|
|
77
|
+
"jest-light-runner": "^0.4.1",
|
|
76
78
|
"jest-mock-now": "^1.3.0",
|
|
77
79
|
"jest-snapshot-serializer-ansi": "^1.0.0",
|
|
78
80
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
79
|
-
"jest-watch-typeahead": "^2.
|
|
81
|
+
"jest-watch-typeahead": "^2.2.0",
|
|
80
82
|
"lines-and-columns": "^2.0.3",
|
|
81
|
-
"outdent": "^0.8.0",
|
|
82
83
|
"prettier": "^2.7.1",
|
|
84
|
+
"proxyquire": "^2.1.3",
|
|
83
85
|
"solc": "^0.8.17"
|
|
84
86
|
},
|
|
85
87
|
"dependencies": {
|
|
86
|
-
"@solidity-parser/parser": "^0.14.
|
|
87
|
-
"emoji-regex": "^10.1
|
|
88
|
+
"@solidity-parser/parser": "^0.14.5",
|
|
89
|
+
"emoji-regex": "^10.2.1",
|
|
88
90
|
"escape-string-regexp": "^4.0.0",
|
|
89
|
-
"semver": "^7.3.
|
|
91
|
+
"semver": "^7.3.8",
|
|
90
92
|
"solidity-comments-extractor": "^0.0.7",
|
|
91
93
|
"string-width": "^4.2.3"
|
|
92
94
|
},
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
const {
|
|
2
2
|
doc: {
|
|
3
|
-
builders: { group,
|
|
3
|
+
builders: { group, indent, line }
|
|
4
4
|
}
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
match: (op) => op === '**',
|
|
9
9
|
print: (node, path, print) => {
|
|
10
|
-
const right = [
|
|
11
|
-
ifBreak(' ', ''),
|
|
12
|
-
node.operator,
|
|
13
|
-
softline,
|
|
14
|
-
path.call(print, 'right')
|
|
15
|
-
];
|
|
10
|
+
const right = [' ', node.operator, line, path.call(print, 'right')];
|
|
16
11
|
// If it's a single binary operation, avoid having a small right
|
|
17
12
|
// operand like - 1 on its own line
|
|
18
13
|
const shouldGroup =
|
|
@@ -5,12 +5,11 @@ const {
|
|
|
5
5
|
} = require('prettier');
|
|
6
6
|
|
|
7
7
|
const AssemblyAssignment = {
|
|
8
|
-
print: ({ path, print }) =>
|
|
9
|
-
join(' ',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
])
|
|
8
|
+
print: ({ path, print }) => [
|
|
9
|
+
join(', ', path.map(print, 'names')),
|
|
10
|
+
' := ',
|
|
11
|
+
path.call(print, 'expression')
|
|
12
|
+
]
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
module.exports = AssemblyAssignment;
|
|
@@ -98,23 +98,25 @@ const body = (node, path, print) => (node.body ? path.call(print, 'body') : '');
|
|
|
98
98
|
|
|
99
99
|
const FunctionDefinition = {
|
|
100
100
|
print: ({ node, path, print, options }) => [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
group([
|
|
102
|
+
functionName(node, options),
|
|
103
|
+
'(',
|
|
104
|
+
parameters('parameters', node, path, print, options),
|
|
105
|
+
')',
|
|
106
|
+
indent(
|
|
107
|
+
group([
|
|
108
|
+
// TODO: sort comments for modifiers and return parameters
|
|
109
|
+
printComments(node, path, options),
|
|
110
|
+
visibility(node),
|
|
111
|
+
stateMutability(node),
|
|
112
|
+
virtual(node),
|
|
113
|
+
override(node, path, print),
|
|
114
|
+
modifiers(node, path, print),
|
|
115
|
+
returnParameters(node, path, print, options),
|
|
116
|
+
signatureEnd(node)
|
|
117
|
+
])
|
|
118
|
+
)
|
|
119
|
+
]),
|
|
118
120
|
body(node, path, print)
|
|
119
121
|
]
|
|
120
122
|
};
|
package/src/nodes/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* This file was automatically generated on
|
|
1
|
+
/* This file was automatically generated on 1666691919.885 */
|
|
2
2
|
|
|
3
3
|
/* eslint-disable global-require */
|
|
4
4
|
|
|
@@ -13,6 +13,7 @@ module.exports = {
|
|
|
13
13
|
AssemblyIf: require('./AssemblyIf'),
|
|
14
14
|
AssemblyLocalDefinition: require('./AssemblyLocalDefinition'),
|
|
15
15
|
AssemblyMemberAccess: require('./AssemblyMemberAccess'),
|
|
16
|
+
AssemblyStackAssignment: require('./AssemblyStackAssignment'),
|
|
16
17
|
AssemblySwitch: require('./AssemblySwitch'),
|
|
17
18
|
BinaryOperation: require('./BinaryOperation'),
|
|
18
19
|
Block: require('./Block'),
|