Skip to content

Commit 9def817

Browse files
authored
Drop Babel 6 support (#15)
* Drop Babel 6 support * remove babel 6 snapshots * rename existing
1 parent 2f847b6 commit 9def817

File tree

76 files changed

+91
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+91
-244
lines changed

.lintstagedrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"*.{js,md}": [
3-
"prettier --print-width=120 --single-quote --no-semi --trailing-comma=all --prose-wrap always --write",
3+
"prettier --write",
44
"git add"
55
]
66
}

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
"homepage": "https://github.com/Andarist/babel-plugin-annotate-pure-calls#readme",
2626
"dependencies": {},
2727
"peerDependencies": {
28-
"@babel/core": "^6.0.0-0 || 7.x"
28+
"@babel/core": "^7.0.0"
2929
},
3030
"devDependencies": {
3131
"@babel/cli": "^7.1.0",
3232
"@babel/core": "^7.1.0",
3333
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
3434
"@babel/preset-env": "^7.1.0",
35-
"babel-core": "^6.26.3",
3635
"babel-plugin-tester": "^5.4.0",
3736
"husky": "^0.14.3",
3837
"jest": "^23.1.0",
@@ -50,5 +49,12 @@
5049
"release:patch": "npm version patch && npm publish && git push --follow-tags",
5150
"release:minor": "npm version minor && npm publish && git push --follow-tags",
5251
"release:major": "npm version major && npm publish && git push --follow-tags"
52+
},
53+
"prettier": {
54+
"lineWidth": 120,
55+
"singleQuote": true,
56+
"semi": false,
57+
"trailingComma": "all",
58+
"proseWrap": "always"
5359
}
5460
}

src/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const annotateAsPure = path => {
1717
path.addComment('leading', PURE_ANNOTATION)
1818
}
1919

20-
const hasCallableParent = ({ parentPath }) => parentPath.isCallExpression() || parentPath.isNewExpression()
20+
const hasCallableParent = ({ parentPath }) =>
21+
parentPath.isCallExpression() || parentPath.isNewExpression()
2122

2223
const isUsedAsCallee = path => {
2324
if (!hasCallableParent(path)) {
@@ -43,11 +44,6 @@ const isExecutedDuringInitialization = path => {
4344
let functionParent = path.getFunctionParent()
4445

4546
while (functionParent) {
46-
// babel@6 returns "incorrectly" program as function parent
47-
if (functionParent.isProgram()) {
48-
return true
49-
}
50-
5147
if (!isUsedAsCallee(functionParent)) {
5248
return false
5349
}
@@ -65,7 +61,10 @@ const isInAssignmentContext = path => {
6561
do {
6662
;({ parentPath } = parentPath || path)
6763

68-
if (parentPath.isVariableDeclaration() || parentPath.isAssignmentExpression()) {
64+
if (
65+
parentPath.isVariableDeclaration() ||
66+
parentPath.isAssignmentExpression()
67+
) {
6968
return true
7069
}
7170
} while (parentPath !== statement)
@@ -82,7 +81,10 @@ const callableExpressionVisitor = path => {
8281
return
8382
}
8483

85-
if (!isInAssignmentContext(path) && !path.getStatementParent().isExportDefaultDeclaration()) {
84+
if (
85+
!isInAssignmentContext(path) &&
86+
!path.getStatementParent().isExportDefaultDeclaration()
87+
) {
8688
return
8789
}
8890

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a = /*#__PURE__*/ fn(/*#__PURE__*/ fn2(/*#__PURE__*/ fn3()))

test/fixtures/annotate/arguments-nested/output6.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/annotate/arguments-nested/output7.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
;(inc = /*#__PURE__*/ add(/*#__PURE__*/ one())),
2+
(dec = /*#__PURE__*/ sub(/*#__PURE__*/ one()))

test/fixtures/annotate/arguments/output6.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/annotate/arguments/output7.js

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
;(inc = /*#__PURE__*/ add(1)), (dec = /*#__PURE__*/ sub(1))

0 commit comments

Comments
 (0)