Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build:dev": "webpack --env development",
"build:test": "webpack --config webpack.test.config.js",
"eslint": "eslint 'src/**' 'tests/**'",
"lint": "npm run eslint && npm run prettier -- --list-different && npm run knip",
"lint": "NODE_OPTIONS=\"--max-old-space-size=5120\" npm run eslint && npm run prettier -- --list-different && npm run knip",
"lint:fix": "npm run eslint -- --fix && npm run prettier -- --write",
"prepublishOnly": "npm run build && npx tsc",
"prettier": "prettier './*.{ts,js,cjs,json,md,yml}' '{src,tests}/**/*.{ts,js,cjs}'",
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/AddressType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export class AddressType extends SlangNode {
}

print(): Doc {
return ['address', this.payableKeyword ? ' payable' : ''];
return `address${this.payableKeyword ? ' payable' : ''}`;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is just a bonus detail that didn't merit a PR

}
}
2 changes: 1 addition & 1 deletion src/slang-nodes/ConstructorAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export class ConstructorAttributes extends SlangNode {
}

print(path: AstPath<ConstructorAttributes>, print: PrintFunction): Doc {
return path.map((item) => [line, print(item)], 'items');
return path.map(() => [line, print(path)], 'items');
}
}
2 changes: 1 addition & 1 deletion src/slang-nodes/FallbackFunctionAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export class FallbackFunctionAttributes extends SlangNode {
}

print(path: AstPath<FallbackFunctionAttributes>, print: PrintFunction): Doc {
return path.map((item) => [line, print(item)], 'items');
return path.map(() => [line, print(path)], 'items');
}
}
2 changes: 1 addition & 1 deletion src/slang-nodes/FunctionAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export class FunctionAttributes extends SlangNode {
}

print(path: AstPath<FunctionAttributes>, print: PrintFunction): Doc {
return path.map((item) => [line, print(item)], 'items');
return path.map(() => [line, print(path)], 'items');
}
}
2 changes: 1 addition & 1 deletion src/slang-nodes/FunctionTypeAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export class FunctionTypeAttributes extends SlangNode {
}

print(path: AstPath<FunctionTypeAttributes>, print: PrintFunction): Doc {
return path.map((item) => [line, print(item)], 'items');
return path.map(() => [line, print(path)], 'items');
}
}
2 changes: 1 addition & 1 deletion src/slang-nodes/ModifierAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export class ModifierAttributes extends SlangNode {
}

print(path: AstPath<ModifierAttributes>, print: PrintFunction): Doc {
return path.map((item) => [line, print(item)], 'items');
return path.map(() => [line, print(path)], 'items');
}
}
2 changes: 1 addition & 1 deletion src/slang-nodes/ReceiveFunctionAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export class ReceiveFunctionAttributes extends SlangNode {
}

print(path: AstPath<ReceiveFunctionAttributes>, print: PrintFunction): Doc {
return path.map((item) => [line, print(item)], 'items');
return path.map(() => [line, print(path)], 'items');
}
}
2 changes: 1 addition & 1 deletion src/slang-nodes/StateVariableAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export class StateVariableAttributes extends SlangNode {
}

print(path: AstPath<StateVariableAttributes>, print: PrintFunction): Doc {
return path.map((item) => [line, print(item)], 'items');
return path.map(() => [line, print(path)], 'items');
}
}
2 changes: 1 addition & 1 deletion src/slang-nodes/UnnamedFunctionAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export class UnnamedFunctionAttributes extends SlangNode {
}

print(path: AstPath<UnnamedFunctionAttributes>, print: PrintFunction): Doc {
return path.map((item) => [line, print(item)], 'items');
return path.map(() => [line, print(path)], 'items');
}
}
5 changes: 2 additions & 3 deletions src/slang-printers/print-comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export function printComments(
if (node.comments === undefined) return [];
return joinExisting(
line,
path.map((commentPath, index, comments: Comment[]) => {
const comment = commentPath.node;
path.map(({ node: comment }, index, comments: Comment[]) => {
if (!isPrintable(comment)) {
return '';
}
Expand All @@ -34,7 +33,7 @@ export function printComments(
index === comments.length - 1 ||
comments.slice(index + 1).findIndex(isPrintable) === -1;
return [
printComment(commentPath),
printComment(path),
!isLast && util.isNextLineEmpty(options.originalText, locEnd(comment))
? hardline
: ''
Expand Down
10 changes: 4 additions & 6 deletions src/slang-printers/print-preserving-empty-lines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ export function printPreservingEmptyLines(
options: ParserOptions<AstNode>
): Doc {
return node.items.length > 0
? path.map((childPath) => {
const node = childPath.node;

? path.map(({ node, isFirst, isLast }) => {
return [
// Only attempt to prepend an empty line if `node` is not the first item
!childPath.isFirst &&
!isFirst &&
// YulLabel adds a dedented line so we don't have to prepend a hardline.
node.kind !== NonterminalKind.YulLabel
? hardline
: '',
print(childPath),
print(path),
// Only attempt to append an empty line if `node` is not the last item
!childPath.isLast &&
!isLast &&
// Append an empty line if the original text already had an one after the
// current `node`
util.isNextLineEmpty(options.originalText, locEnd(node))
Expand Down
2 changes: 1 addition & 1 deletion src/slangPrinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function ignoreComments(path: AstPath<StrictAstNode>): void {
// The key `comments` will contain every comment for this node.
case 'comments':
if (node.comments !== undefined) {
path.each((commentPath) => (commentPath.node.printed = true), key);
path.each(({ node }) => (node.printed = true), key);
}
break;
default:
Expand Down