Skip to content

Commit 6cfd4bf

Browse files
committed
add source code
1 parent d0d6136 commit 6cfd4bf

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
module.exports = function ({ types: t }) {
4+
return {
5+
name: 'transform-not-strict',
6+
visitor: {
7+
Directive(path) {
8+
if (path.node.value.value === 'use strict') {
9+
const siblings = path.container // get all the sibilings (code in the same level) of 'use strict'
10+
11+
for (const sibling of siblings) {
12+
if (t.isDirective(sibling)) { // if the sibiling is a directive
13+
if (sibling.value.value === 'not strict') { // check if its 'not strict'
14+
path.remove(); // remove 'use strict'
15+
break;
16+
}
17+
}
18+
}
19+
}
20+
},
21+
},
22+
};
23+
};

0 commit comments

Comments
 (0)