Skip to content

Commit 3f18e81

Browse files
committed
feat!: bump babel and typescript, add two proposals
1 parent 9928a2f commit 3f18e81

18 files changed

+2727
-2601
lines changed

.eslintrc.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ const {
99

1010
const tsBase = ts[0]
1111

12+
js.parser = '@babel/eslint-parser'
13+
js.plugins = ['@babel']
14+
const jsRules = js.rules
15+
16+
delete jsRules['babel/camelcase']
17+
delete jsRules['babel/new-cap']
18+
delete jsRules['babel/no-invalid-this']
19+
delete jsRules['babel/no-unused-expressions']
20+
delete jsRules['babel/valid-typeof']
21+
1222
module.exports = {
1323
extends: ['@1stg/eslint-config/base', 'plugin:import/typescript'],
14-
parser: 'babel-eslint',
1524
settings: {
1625
'import/ignore': [/test\/private-methods.ts$/],
1726
'import/parsers': {
1827
'@typescript-eslint/parser': [],
19-
'babel-eslint': ['.ts'],
28+
'@babel/eslint-parser': ['.ts'],
2029
},
2130
...tsBase.settings,
2231
},
@@ -30,7 +39,14 @@ module.exports = {
3039
},
3140
{
3241
...js,
42+
plugins: ['@babel'],
3343
files: 'test/*.{js,ts}',
44+
rules: {
45+
...jsRules,
46+
'@babel/new-cap': 2,
47+
'@babel/no-invalid-this': 2,
48+
'@babel/no-unused-expressions': 2,
49+
},
3450
},
3551
jest,
3652
mdx,

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,18 @@ So that you can use babel to transform proposals which are current in stage 0-2
3535

3636
## Enabled proposal plugins
3737

38-
1. [class-properties](https://www.npmjs.com/package/@babel/plugin-proposal-class-properties)
39-
2. [do-expressions](https://www.npmjs.com/package/@babel/plugin-proposal-do-expressions)
40-
3. [function-bind](https://www.npmjs.com/package/@babel/plugin-proposal-function-bind)
41-
4. [function-sent](https://www.npmjs.com/package/@babel/plugin-proposal-function-sent)
42-
5. [json-strings](https://www.npmjs.com/package/@babel/plugin-proposal-json-strings)
43-
6. [logical-assignment-operators](https://www.npmjs.com/package/@babel/plugin-proposal-logical-assignment-operators)
38+
1. [class-static-block](https://www.npmjs.com/package/@babel/plugin-proposal-class-static-block)
39+
2. [class-properties](https://www.npmjs.com/package/@babel/plugin-proposal-class-properties)
40+
3. [do-expressions](https://www.npmjs.com/package/@babel/plugin-proposal-do-expressions)
41+
4. [function-bind](https://www.npmjs.com/package/@babel/plugin-proposal-function-bind)
42+
5. [function-sent](https://www.npmjs.com/package/@babel/plugin-proposal-function-sent)
43+
6. [json-strings](https://www.npmjs.com/package/@babel/plugin-proposal-json-strings)
4444
7. [partial-application](https://www.npmjs.com/package/@babel/plugin-proposal-partial-application)
4545
8. [pipeline-operator](https://www.npmjs.com/package/@babel/plugin-proposal-pipeline-operator)
4646
9. [private-methods](https://www.npmjs.com/package/@babel/plugin-proposal-private-methods)
47-
10. [throw-expressions](https://www.npmjs.com/package/@babel/plugin-proposal-throw-expressions)
48-
11. [v8intrinsic](./src/v8intrinsic.ts) - [Further Detail](https://babeljs.io/blog/2019/09/05/7.6.0#v8-intrinsic-runtime-functions-parsing-10148-https-githubcom-babel-babel-pull-10148)
47+
10. [private-property-in-object](https://www.npmjs.com/package/@babel/plugin-proposal-private-property-in-object)
48+
11. [throw-expressions](https://www.npmjs.com/package/@babel/plugin-proposal-throw-expressions)
49+
12. [v8intrinsic](./src/v8intrinsic.ts) - [Further Detail](https://babeljs.io/blog/2019/09/05/7.6.0#v8-intrinsic-runtime-functions-parsing-10148-https-githubcom-babel-babel-pull-10148)
4950

5051
## Install
5152

package.json

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,41 @@
3939
"test": "jest"
4040
},
4141
"peerDependencies": {
42-
"@babel/core": "^7.10.5",
43-
"typescript": "^3.9.7"
42+
"@babel/core": "^7.12.0",
43+
"typescript": "^4.0.0"
4444
},
4545
"dependencies": {
46-
"@babel/core": "^7.10.5",
46+
"@babel/core": "^7.12.10",
4747
"@babel/helper-plugin-utils": "^7.10.4",
48-
"@babel/plugin-proposal-class-properties": "^7.10.4",
49-
"@babel/plugin-proposal-do-expressions": "^7.10.4",
50-
"@babel/plugin-proposal-function-bind": "^7.10.5",
51-
"@babel/plugin-proposal-function-sent": "^7.10.4",
52-
"@babel/plugin-proposal-json-strings": "^7.10.4",
53-
"@babel/plugin-proposal-logical-assignment-operators": "^7.10.4",
54-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
55-
"@babel/plugin-proposal-optional-chaining": "^7.10.4",
56-
"@babel/plugin-proposal-partial-application": "^7.10.5",
57-
"@babel/plugin-proposal-pipeline-operator": "^7.10.5",
58-
"@babel/plugin-proposal-private-methods": "^7.10.4",
59-
"@babel/plugin-proposal-throw-expressions": "^7.10.4",
60-
"@babel/plugin-syntax-decorators": "^7.10.4",
48+
"@babel/plugin-proposal-class-properties": "^7.12.1",
49+
"@babel/plugin-proposal-class-static-block": "^7.12.1",
50+
"@babel/plugin-proposal-do-expressions": "^7.12.1",
51+
"@babel/plugin-proposal-function-bind": "^7.12.1",
52+
"@babel/plugin-proposal-function-sent": "^7.12.1",
53+
"@babel/plugin-proposal-json-strings": "^7.12.1",
54+
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
55+
"@babel/plugin-proposal-partial-application": "^7.12.1",
56+
"@babel/plugin-proposal-pipeline-operator": "^7.12.1",
57+
"@babel/plugin-proposal-private-methods": "^7.12.1",
58+
"@babel/plugin-proposal-private-property-in-object": "^7.12.1",
59+
"@babel/plugin-proposal-throw-expressions": "^7.12.1",
60+
"@babel/plugin-syntax-decorators": "^7.12.1",
6161
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
62-
"@babel/plugin-syntax-typescript": "^7.10.4"
62+
"@babel/plugin-syntax-typescript": "^7.12.1"
6363
},
6464
"devDependencies": {
65-
"@1stg/lib-config": "^0.5.5",
66-
"@types/babel__core": "^7.1.9",
67-
"@types/jest": "^26.0.7",
68-
"babel-eslint": "^11.0.0-beta.2",
69-
"babel-jest": "^26.1.0",
70-
"babel-preset-proposal-typescript": "link:.",
65+
"@1stg/lib-config": "^0.6.0",
66+
"@babel/eslint-parser": "^7.12.1",
67+
"@babel/eslint-plugin": "^7.12.1",
68+
"@types/babel__core": "^7.1.12",
69+
"@types/jest": "^26.0.20",
70+
"babel-jest": "^26.6.3",
7171
"npm-run-all": "^4.1.5",
72-
"typescript": "^3.9.7",
73-
"yarn-deduplicate": "^2.1.1"
72+
"typescript": "^4.1.3",
73+
"yarn-deduplicate": "^3.1.0"
7474
},
7575
"resolutions": {
76-
"prettier": "^2.0.5"
76+
"babel-preset-proposal-typescript": "link:.",
77+
"prettier": "^2.2.1"
7778
}
7879
}

src/index.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { ConfigAPI } from '@babel/core'
22
import { declare } from '@babel/helper-plugin-utils'
33
import proposalClassProperties from '@babel/plugin-proposal-class-properties'
4+
import proposalClassStaticBlock from '@babel/plugin-proposal-class-static-block'
45
import proposalDoExpressions from '@babel/plugin-proposal-do-expressions'
56
import proposalFunctionBind from '@babel/plugin-proposal-function-bind'
67
import proposalFunctionSent from '@babel/plugin-proposal-function-sent'
78
import proposalJsonStrings from '@babel/plugin-proposal-json-strings'
8-
import proposalLogicalAssignmentOperators from '@babel/plugin-proposal-logical-assignment-operators'
9-
import proposalNullishCoalescingOperator from '@babel/plugin-proposal-nullish-coalescing-operator'
109
import proposalOptionalChaining from '@babel/plugin-proposal-optional-chaining'
1110
import proposalPartialApplication from '@babel/plugin-proposal-partial-application'
1211
import proposalPipelineOperator from '@babel/plugin-proposal-pipeline-operator'
1312
import proposalPrivateMethods from '@babel/plugin-proposal-private-methods'
13+
import proposalPrivatePropertyInObject from '@babel/plugin-proposal-private-property-in-object'
1414
import proposalThrowExpression from '@babel/plugin-proposal-throw-expressions'
1515
import syntaxDecorators from '@babel/plugin-syntax-decorators'
1616
import syntaxDynamicImport from '@babel/plugin-syntax-dynamic-import'
@@ -55,6 +55,12 @@ export default declare(
5555
},
5656
],
5757
syntaxV8intrinsic,
58+
[
59+
proposalClassStaticBlock,
60+
{
61+
loose: classLoose,
62+
},
63+
],
5864
[
5965
proposalClassProperties,
6066
{
@@ -65,8 +71,6 @@ export default declare(
6571
proposalFunctionBind,
6672
proposalFunctionSent,
6773
proposalJsonStrings,
68-
proposalLogicalAssignmentOperators,
69-
proposalNullishCoalescingOperator,
7074
proposalOptionalChaining,
7175
proposalPartialApplication,
7276
[
@@ -81,6 +85,12 @@ export default declare(
8185
loose: classLoose,
8286
},
8387
],
88+
[
89+
proposalPrivatePropertyInObject,
90+
{
91+
loose: classLoose,
92+
},
93+
],
8494
proposalThrowExpression,
8595
],
8696
// no need to override if it has been enabled

test/.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"rules": {
3-
"no-magic-numbers": 0
3+
"no-magic-numbers": 0,
4+
"jest/valid-title": 0
45
}
56
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`class-static-block 1`] = `"Unexpected token ')'"`;

test/__snapshots__/logical-assignment-operators.spec.ts.snap

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`private-property-in-object 1`] = `"Unexpected identifier"`;

test/class-static-block.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { C } from './class-static-block'
2+
import { execute } from './helpers'
3+
4+
const proposal = 'class-static-block'
5+
6+
test(proposal, () => {
7+
expect(() => execute(proposal)).toThrowErrorMatchingSnapshot()
8+
expect(C.y).toEqual('bad')
9+
})

test/class-static-block.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const doSomethingWith = (value: number) =>
2+
/* istanbul ignore next */
3+
value >= 80 ? 'good' : value >= 60 ? 'ok' : 'bad'
4+
5+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
6+
export class C {
7+
static #x = 42
8+
// eslint-disable-next-line @typescript-eslint/member-ordering
9+
static y: string
10+
static {
11+
try {
12+
// eslint-disable-next-line @babel/no-invalid-this
13+
this.y = doSomethingWith(this.#x)
14+
} catch {
15+
/* istanbul ignore next */
16+
// eslint-disable-next-line @babel/no-invalid-this
17+
this.y = 'unknown'
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)