-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathstrict-plugin.js
More file actions
32 lines (30 loc) · 813 Bytes
/
strict-plugin.js
File metadata and controls
32 lines (30 loc) · 813 Bytes
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
'use strict';
const t = require('@babel/types');
module.exports = function () {
return {
visitor: {
CallExpression(path) {
const spath = path.getPathLocation().split('.');
if (
spath.length === 3 &&
spath[0] === 'program' &&
path.node.callee.name === 'define'
) {
path.traverse({
Function(path) {
const spath = path.getPathLocation().split('.');
if (spath.length === 4 && spath[3].startsWith('arguments')) {
path
.get('body')
.unshiftContainer(
'body',
t.expressionStatement(t.stringLiteral('use strict'))
);
}
}
});
}
}
}
};
};