-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathFunctionDeclaration.js
35 lines (30 loc) · 1.01 KB
/
FunctionDeclaration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"use strict";
var _tk = require('rocambole-token');
var _ws = require('rocambole-whitespace');
var _limit = require('../limit');
var _params = require('./Params');
exports.format = function FunctionDeclaration(node) {
if (node.id) {
_limit.around(node.id.startToken, 'FunctionName');
}
// babel-eslint reports async functions as generators.
//
// Make sure the generator function is not an async function before removing
// the whitespace.
//
// This will prevent a function such as `async function fun() {}` being
// converted to `asyncfunction fun() {}`.
if (node.generator && !node.async) {
var genToken = _tk.findNextNonEmpty(node.startToken);
_ws.limitBefore(genToken, 'FunctionGeneratorAsterisk');
}
_params.format(node);
_limit.around(node.body.startToken, 'FunctionDeclarationOpeningBrace');
_limit.around(node.body.endToken, 'FunctionDeclarationClosingBrace');
};
exports.getIndentEdges = function(node, opts) {
return [
_params.getIndentEdges(node, opts),
node.body
];
};