goldstein 5.21.0 → 5.22.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/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -451,18 +451,18 @@ function hello() {}
|
|
|
451
451
|
|
|
452
452
|
### Broken String
|
|
453
453
|
|
|
454
|
-
When you accidentally broke string:
|
|
454
|
+
When you accidentally broke string, Goldstein will fix it:
|
|
455
455
|
|
|
456
|
-
```
|
|
457
|
-
const a = 'hello
|
|
458
|
-
const
|
|
456
|
+
```diff
|
|
457
|
+
-const a = 'hello
|
|
458
|
+
+const a = 'hello';
|
|
459
|
+
-const a = ‘hello world’;
|
|
460
|
+
+const a = 'hello world';
|
|
459
461
|
```
|
|
460
462
|
|
|
461
|
-
|
|
463
|
+
to:
|
|
462
464
|
|
|
463
465
|
```js
|
|
464
|
-
const a = 'hello';
|
|
465
|
-
const b = 'world';
|
|
466
466
|
```
|
|
467
467
|
|
|
468
468
|
### Missing Initializer
|
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import {tokTypes as tt} from '../operator/index.js';
|
|
2
2
|
|
|
3
|
+
const QUOTE = `'`.charCodeAt(0);
|
|
4
|
+
const MOBILE_CLOSE_QUOTE = '’'.charCodeAt(0);
|
|
5
|
+
const MOBILE_OPEN_QUOTE = '‘'.charCodeAt(0);
|
|
6
|
+
|
|
3
7
|
export default function keywordBrokenString(Parser) {
|
|
4
8
|
return class extends Parser {
|
|
9
|
+
getTokenFromCode(code) {
|
|
10
|
+
if (code === MOBILE_OPEN_QUOTE)
|
|
11
|
+
return this.readString(MOBILE_CLOSE_QUOTE);
|
|
12
|
+
|
|
13
|
+
return super.getTokenFromCode(code);
|
|
14
|
+
}
|
|
5
15
|
parseVarStatement(node, kind, allowMissingInitializer) {
|
|
6
16
|
this.next();
|
|
7
17
|
this.parseVar(node, false, kind, allowMissingInitializer);
|
|
@@ -20,8 +30,13 @@ export default function keywordBrokenString(Parser) {
|
|
|
20
30
|
if (!ch)
|
|
21
31
|
break;
|
|
22
32
|
|
|
33
|
+
if (ch === QUOTE || ch === MOBILE_CLOSE_QUOTE)
|
|
34
|
+
break;
|
|
35
|
+
|
|
36
|
+
/* c8 ignore start */
|
|
23
37
|
if (ch === quote)
|
|
24
38
|
break;
|
|
39
|
+
/* c8 ignore end */
|
|
25
40
|
|
|
26
41
|
/* c8 ignore start */
|
|
27
42
|
if (ch === 92) {
|
|
@@ -60,5 +75,8 @@ export default function keywordBrokenString(Parser) {
|
|
|
60
75
|
}
|
|
61
76
|
|
|
62
77
|
function isNewLine(code) {
|
|
63
|
-
return code === 10
|
|
78
|
+
return code === 10
|
|
79
|
+
|| code === 13
|
|
80
|
+
|| code === 0x2028
|
|
81
|
+
|| code === 0x2029;
|
|
64
82
|
}
|
|
@@ -45,7 +45,7 @@ export default function keywordExportNoConst(Parser) {
|
|
|
45
45
|
node.declaration = VariableDeclaration('const', [
|
|
46
46
|
VariableDeclarator(node.declaration.expression.left, node.declaration.expression.right),
|
|
47
47
|
]);
|
|
48
|
-
else
|
|
48
|
+
else if (node.declaration.id)
|
|
49
49
|
this.checkExport(exports, node.declaration.id, node.declaration.id.start);
|
|
50
50
|
|
|
51
51
|
node.specifiers = [];
|