hermes-transform 0.5.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/LICENSE +21 -0
- package/README.md +8 -0
- package/dist/detachedNode.js +128 -0
- package/dist/detachedNode.js.flow +113 -0
- package/dist/generated/TransformCloneSignatures.js.flow +19 -0
- package/dist/generated/TransformReplaceSignatures.js.flow +943 -0
- package/dist/generated/node-types.js +2071 -0
- package/dist/generated/node-types.js.flow +3149 -0
- package/dist/generated/special-case-node-types.js +178 -0
- package/dist/generated/special-case-node-types.js.flow +248 -0
- package/dist/getVisitorKeys.js +35 -0
- package/dist/getVisitorKeys.js.flow +31 -0
- package/dist/index.js +41 -0
- package/dist/index.js.flow +15 -0
- package/dist/transform/Errors.js +151 -0
- package/dist/transform/Errors.js.flow +17 -0
- package/dist/transform/MutationContext.js +94 -0
- package/dist/transform/MutationContext.js.flow +80 -0
- package/dist/transform/TransformContext.js +136 -0
- package/dist/transform/TransformContext.js.flow +378 -0
- package/dist/transform/comments/comments.js +140 -0
- package/dist/transform/comments/comments.js.flow +145 -0
- package/dist/transform/comments/prettier/README.md +6 -0
- package/dist/transform/comments/prettier/common/util.js +365 -0
- package/dist/transform/comments/prettier/common/util.js.flow +349 -0
- package/dist/transform/comments/prettier/language-js/comments.js +777 -0
- package/dist/transform/comments/prettier/language-js/comments.js.flow +950 -0
- package/dist/transform/comments/prettier/language-js/loc.js +41 -0
- package/dist/transform/comments/prettier/language-js/loc.js.flow +41 -0
- package/dist/transform/comments/prettier/language-js/printer-estree.js +31 -0
- package/dist/transform/comments/prettier/language-js/printer-estree.js.flow +37 -0
- package/dist/transform/comments/prettier/language-js/utils.js +131 -0
- package/dist/transform/comments/prettier/language-js/utils.js.flow +135 -0
- package/dist/transform/comments/prettier/main/comments.js +513 -0
- package/dist/transform/comments/prettier/main/comments.js.flow +436 -0
- package/dist/transform/comments/prettier/utils/get-last.js +15 -0
- package/dist/transform/comments/prettier/utils/get-last.js.flow +14 -0
- package/dist/transform/getTransformedAST.js +159 -0
- package/dist/transform/getTransformedAST.js.flow +128 -0
- package/dist/transform/mutations/AddLeadingComments.js +47 -0
- package/dist/transform/mutations/AddLeadingComments.js.flow +49 -0
- package/dist/transform/mutations/AddTrailingComments.js +47 -0
- package/dist/transform/mutations/AddTrailingComments.js.flow +49 -0
- package/dist/transform/mutations/CloneCommentsTo.js +46 -0
- package/dist/transform/mutations/CloneCommentsTo.js.flow +51 -0
- package/dist/transform/mutations/InsertStatement.js +92 -0
- package/dist/transform/mutations/InsertStatement.js.flow +113 -0
- package/dist/transform/mutations/RemoveComment.js +96 -0
- package/dist/transform/mutations/RemoveComment.js.flow +80 -0
- package/dist/transform/mutations/RemoveStatement.js +61 -0
- package/dist/transform/mutations/RemoveStatement.js.flow +68 -0
- package/dist/transform/mutations/ReplaceNode.js +96 -0
- package/dist/transform/mutations/ReplaceNode.js.flow +113 -0
- package/dist/transform/mutations/ReplaceStatementWithMany.js +81 -0
- package/dist/transform/mutations/ReplaceStatementWithMany.js.flow +102 -0
- package/dist/transform/mutations/utils/arrayUtils.js +41 -0
- package/dist/transform/mutations/utils/arrayUtils.js.flow +35 -0
- package/dist/transform/mutations/utils/getStatementParent.js +147 -0
- package/dist/transform/mutations/utils/getStatementParent.js.flow +143 -0
- package/dist/transform/mutations/utils/isValidModuleDeclarationParent.js +53 -0
- package/dist/transform/mutations/utils/isValidModuleDeclarationParent.js.flow +50 -0
- package/dist/transform/transform.js +69 -0
- package/dist/transform/transform.js.flow +60 -0
- package/dist/traverse/NodeEventGenerator.js +427 -0
- package/dist/traverse/NodeEventGenerator.js.flow +406 -0
- package/dist/traverse/SafeEmitter.js +70 -0
- package/dist/traverse/SafeEmitter.js.flow +46 -0
- package/dist/traverse/SimpleTraverser.js +149 -0
- package/dist/traverse/SimpleTraverser.js.flow +109 -0
- package/dist/traverse/esquery.js +37 -0
- package/dist/traverse/esquery.js.flow +173 -0
- package/dist/traverse/traverse.js +139 -0
- package/dist/traverse/traverse.js.flow +149 -0
- package/package.json +22 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
var _require = require('../common/util.js'),
|
|
12
|
+
isNonEmptyArray = _require.isNonEmptyArray;
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import("./types/estree").Node} Node
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function locStart(node, opts) {
|
|
19
|
+
var _ref = opts || {},
|
|
20
|
+
ignoreDecorators = _ref.ignoreDecorators; // Handle nodes with decorators. They should start at the first decorator
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if (!ignoreDecorators) {
|
|
24
|
+
var decorators = node.declaration && node.declaration.decorators || node.decorators;
|
|
25
|
+
|
|
26
|
+
if (isNonEmptyArray(decorators)) {
|
|
27
|
+
return locStart(decorators[0]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return node.range ? node.range[0] : node.start;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function locEnd(node) {
|
|
35
|
+
return node.range ? node.range[1] : node.end;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
locStart: locStart,
|
|
40
|
+
locEnd: locEnd
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const {isNonEmptyArray} = require('../common/util.js');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import("./types/estree").Node} Node
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function locStart(node, opts) {
|
|
19
|
+
const {ignoreDecorators} = opts || {};
|
|
20
|
+
|
|
21
|
+
// Handle nodes with decorators. They should start at the first decorator
|
|
22
|
+
if (!ignoreDecorators) {
|
|
23
|
+
const decorators =
|
|
24
|
+
(node.declaration && node.declaration.decorators) || node.decorators;
|
|
25
|
+
|
|
26
|
+
if (isNonEmptyArray(decorators)) {
|
|
27
|
+
return locStart(decorators[0]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return node.range ? node.range[0] : node.start;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function locEnd(node) {
|
|
35
|
+
return node.range ? node.range[1] : node.end;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
locStart,
|
|
40
|
+
locEnd,
|
|
41
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
var handleComments = require('./comments.js');
|
|
12
|
+
|
|
13
|
+
var _require = require('./utils.js'),
|
|
14
|
+
isBlockComment = _require.isBlockComment,
|
|
15
|
+
isLineComment = _require.isLineComment;
|
|
16
|
+
|
|
17
|
+
function canAttachComment(node) {
|
|
18
|
+
return node.type && !isBlockComment(node) && !isLineComment(node) && node.type !== 'EmptyStatement' && node.type !== 'TemplateElement' && node.type !== 'Import' && // `babel-ts` don't have similar node for `class Foo { bar() /* bat */; }`
|
|
19
|
+
node.type !== 'TSEmptyBodyFunctionExpression';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
canAttachComment: canAttachComment,
|
|
24
|
+
handleComments: {
|
|
25
|
+
avoidAstMutation: true,
|
|
26
|
+
ownLine: handleComments.handleOwnLineComment,
|
|
27
|
+
endOfLine: handleComments.handleEndOfLineComment,
|
|
28
|
+
remaining: handleComments.handleRemainingComment
|
|
29
|
+
},
|
|
30
|
+
getCommentChildNodes: handleComments.getCommentChildNodes
|
|
31
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const handleComments = require('./comments.js');
|
|
13
|
+
const {isBlockComment, isLineComment} = require('./utils.js');
|
|
14
|
+
|
|
15
|
+
function canAttachComment(node) {
|
|
16
|
+
return (
|
|
17
|
+
node.type &&
|
|
18
|
+
!isBlockComment(node) &&
|
|
19
|
+
!isLineComment(node) &&
|
|
20
|
+
node.type !== 'EmptyStatement' &&
|
|
21
|
+
node.type !== 'TemplateElement' &&
|
|
22
|
+
node.type !== 'Import' &&
|
|
23
|
+
// `babel-ts` don't have similar node for `class Foo { bar() /* bat */; }`
|
|
24
|
+
node.type !== 'TSEmptyBodyFunctionExpression'
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
canAttachComment,
|
|
30
|
+
handleComments: {
|
|
31
|
+
avoidAstMutation: true,
|
|
32
|
+
ownLine: handleComments.handleOwnLineComment,
|
|
33
|
+
endOfLine: handleComments.handleEndOfLineComment,
|
|
34
|
+
remaining: handleComments.handleRemainingComment,
|
|
35
|
+
},
|
|
36
|
+
getCommentChildNodes: handleComments.getCommentChildNodes,
|
|
37
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
/**
|
|
11
|
+
* @param {Comment} comment
|
|
12
|
+
* @returns {boolean}
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
16
|
+
|
|
17
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
18
|
+
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
|
|
21
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
22
|
+
|
|
23
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
24
|
+
|
|
25
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
26
|
+
|
|
27
|
+
function isBlockComment(comment) {
|
|
28
|
+
return comment.type === 'Block' || comment.type === 'CommentBlock' || // `meriyah`
|
|
29
|
+
comment.type === 'MultiLine';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @param {Comment} comment
|
|
33
|
+
* @returns {boolean}
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
function isLineComment(comment) {
|
|
38
|
+
return comment.type === 'Line' || comment.type === 'CommentLine' || // `meriyah` has `SingleLine`, `HashbangComment`, `HTMLOpen`, and `HTMLClose`
|
|
39
|
+
comment.type === 'SingleLine' || comment.type === 'HashbangComment' || comment.type === 'HTMLOpen' || comment.type === 'HTMLClose';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @param {Node} node
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function isCallExpression(node) {
|
|
48
|
+
return node && (node.type === 'CallExpression' || node.type === 'OptionalCallExpression');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @param {Node} node
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
function isMemberExpression(node) {
|
|
57
|
+
return node && (node.type === 'MemberExpression' || node.type === 'OptionalMemberExpression');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var functionParametersCache = new WeakMap();
|
|
61
|
+
|
|
62
|
+
function getFunctionParameters(node) {
|
|
63
|
+
if (functionParametersCache.has(node)) {
|
|
64
|
+
return functionParametersCache.get(node);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var parameters = [];
|
|
68
|
+
|
|
69
|
+
if (node["this"]) {
|
|
70
|
+
parameters.push(node["this"]);
|
|
71
|
+
} // `params` vs `parameters` - see https://github.com/babel/babel/issues/9231
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
if (Array.isArray(node.parameters)) {
|
|
75
|
+
parameters.push.apply(parameters, _toConsumableArray(node.parameters));
|
|
76
|
+
} else if (Array.isArray(node.params)) {
|
|
77
|
+
parameters.push.apply(parameters, _toConsumableArray(node.params));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (node.rest) {
|
|
81
|
+
parameters.push(node.rest);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
functionParametersCache.set(node, parameters);
|
|
85
|
+
return parameters;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var callArgumentsCache = new WeakMap();
|
|
89
|
+
|
|
90
|
+
function getCallArguments(node) {
|
|
91
|
+
if (callArgumentsCache.has(node)) {
|
|
92
|
+
return callArgumentsCache.get(node);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
var args = node.arguments;
|
|
96
|
+
|
|
97
|
+
if (node.type === 'ImportExpression') {
|
|
98
|
+
args = [node.source];
|
|
99
|
+
|
|
100
|
+
if (node.attributes) {
|
|
101
|
+
args.push(node.attributes);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
callArgumentsCache.set(node, args);
|
|
106
|
+
return args;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isPrettierIgnoreComment(comment) {
|
|
110
|
+
return comment.value.trim() === 'prettier-ignore' && !comment.unignore;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function isCallLikeExpression(node) {
|
|
114
|
+
return isCallExpression(node) || node.type === 'NewExpression' || node.type === 'ImportExpression';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isObjectProperty(node) {
|
|
118
|
+
return node && (node.type === 'ObjectProperty' || node.type === 'Property' && !node.method && node.kind === 'init');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = {
|
|
122
|
+
getFunctionParameters: getFunctionParameters,
|
|
123
|
+
getCallArguments: getCallArguments,
|
|
124
|
+
isBlockComment: isBlockComment,
|
|
125
|
+
isCallLikeExpression: isCallLikeExpression,
|
|
126
|
+
isLineComment: isLineComment,
|
|
127
|
+
isPrettierIgnoreComment: isPrettierIgnoreComment,
|
|
128
|
+
isCallExpression: isCallExpression,
|
|
129
|
+
isMemberExpression: isMemberExpression,
|
|
130
|
+
isObjectProperty: isObjectProperty
|
|
131
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {Comment} comment
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
function isBlockComment(comment) {
|
|
17
|
+
return (
|
|
18
|
+
comment.type === 'Block' ||
|
|
19
|
+
comment.type === 'CommentBlock' ||
|
|
20
|
+
// `meriyah`
|
|
21
|
+
comment.type === 'MultiLine'
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {Comment} comment
|
|
27
|
+
* @returns {boolean}
|
|
28
|
+
*/
|
|
29
|
+
function isLineComment(comment) {
|
|
30
|
+
return (
|
|
31
|
+
comment.type === 'Line' ||
|
|
32
|
+
comment.type === 'CommentLine' ||
|
|
33
|
+
// `meriyah` has `SingleLine`, `HashbangComment`, `HTMLOpen`, and `HTMLClose`
|
|
34
|
+
comment.type === 'SingleLine' ||
|
|
35
|
+
comment.type === 'HashbangComment' ||
|
|
36
|
+
comment.type === 'HTMLOpen' ||
|
|
37
|
+
comment.type === 'HTMLClose'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {Node} node
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
function isCallExpression(node) {
|
|
46
|
+
return (
|
|
47
|
+
node &&
|
|
48
|
+
(node.type === 'CallExpression' || node.type === 'OptionalCallExpression')
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {Node} node
|
|
54
|
+
* @returns {boolean}
|
|
55
|
+
*/
|
|
56
|
+
function isMemberExpression(node) {
|
|
57
|
+
return (
|
|
58
|
+
node &&
|
|
59
|
+
(node.type === 'MemberExpression' ||
|
|
60
|
+
node.type === 'OptionalMemberExpression')
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const functionParametersCache = new WeakMap();
|
|
65
|
+
function getFunctionParameters(node) {
|
|
66
|
+
if (functionParametersCache.has(node)) {
|
|
67
|
+
return functionParametersCache.get(node);
|
|
68
|
+
}
|
|
69
|
+
const parameters = [];
|
|
70
|
+
if (node.this) {
|
|
71
|
+
parameters.push(node.this);
|
|
72
|
+
}
|
|
73
|
+
// `params` vs `parameters` - see https://github.com/babel/babel/issues/9231
|
|
74
|
+
if (Array.isArray(node.parameters)) {
|
|
75
|
+
parameters.push(...node.parameters);
|
|
76
|
+
} else if (Array.isArray(node.params)) {
|
|
77
|
+
parameters.push(...node.params);
|
|
78
|
+
}
|
|
79
|
+
if (node.rest) {
|
|
80
|
+
parameters.push(node.rest);
|
|
81
|
+
}
|
|
82
|
+
functionParametersCache.set(node, parameters);
|
|
83
|
+
return parameters;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const callArgumentsCache = new WeakMap();
|
|
87
|
+
function getCallArguments(node) {
|
|
88
|
+
if (callArgumentsCache.has(node)) {
|
|
89
|
+
return callArgumentsCache.get(node);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let args = node.arguments;
|
|
93
|
+
if (node.type === 'ImportExpression') {
|
|
94
|
+
args = [node.source];
|
|
95
|
+
|
|
96
|
+
if (node.attributes) {
|
|
97
|
+
args.push(node.attributes);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
callArgumentsCache.set(node, args);
|
|
102
|
+
return args;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function isPrettierIgnoreComment(comment) {
|
|
106
|
+
return comment.value.trim() === 'prettier-ignore' && !comment.unignore;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isCallLikeExpression(node) {
|
|
110
|
+
return (
|
|
111
|
+
isCallExpression(node) ||
|
|
112
|
+
node.type === 'NewExpression' ||
|
|
113
|
+
node.type === 'ImportExpression'
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isObjectProperty(node) {
|
|
118
|
+
return (
|
|
119
|
+
node &&
|
|
120
|
+
(node.type === 'ObjectProperty' ||
|
|
121
|
+
(node.type === 'Property' && !node.method && node.kind === 'init'))
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = {
|
|
126
|
+
getFunctionParameters,
|
|
127
|
+
getCallArguments,
|
|
128
|
+
isBlockComment,
|
|
129
|
+
isCallLikeExpression,
|
|
130
|
+
isLineComment,
|
|
131
|
+
isPrettierIgnoreComment,
|
|
132
|
+
isCallExpression,
|
|
133
|
+
isMemberExpression,
|
|
134
|
+
isObjectProperty,
|
|
135
|
+
};
|