goldstein 5.7.1 → 5.8.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 +12 -0
- package/README.md +17 -0
- package/package.json +2 -3
- package/packages/goldstein/parser.js +2 -0
- package/packages/keyword-add-array/index.js +2 -0
- package/packages/keyword-arrow/index.js +2 -0
- package/packages/keyword-broken-string/index.js +61 -0
- package/packages/keyword-import/index.js +2 -1
- package/packages/keyword-should/index.js +0 -2
- package/packages/keyword-try/index.js +0 -13
- package/packages/printer/visitors/if-statement.js +1 -6
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
2024.05.22, v5.8.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 2bd6e8c test: do not fail when update tests
|
|
5
|
+
- f4fb1d6 goldstein: broken strings
|
|
6
|
+
- e80d132 goldstein: check-dts v0.8.0
|
|
7
|
+
|
|
8
|
+
2024.05.11, v5.7.2
|
|
9
|
+
|
|
10
|
+
fix:
|
|
11
|
+
- 3fddd10 goldstein: rm unused
|
|
12
|
+
|
|
1
13
|
2024.05.11, v5.7.1
|
|
2
14
|
|
|
3
15
|
feature:
|
package/README.md
CHANGED
|
@@ -408,6 +408,23 @@ That absolutely fine, it will be converted to:
|
|
|
408
408
|
function hello() {}
|
|
409
409
|
```
|
|
410
410
|
|
|
411
|
+
### Broken String
|
|
412
|
+
|
|
413
|
+
When you accidentally broke string:
|
|
414
|
+
|
|
415
|
+
```gs
|
|
416
|
+
const a = 'hello
|
|
417
|
+
const b = 'world';
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
Golstein will fix it to:
|
|
421
|
+
|
|
422
|
+
```js
|
|
423
|
+
const a = 'hello';
|
|
424
|
+
const b = 'world';
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
|
|
411
428
|
## How to contribute?
|
|
412
429
|
|
|
413
430
|
Clone the registry, create a new keyword with a prefix `keyword-`, then create directory `fixture` and put there two files with extensions `.js` and `.gs`. Half way done 🥳!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goldstein",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "JavaScript with no limits",
|
|
@@ -45,10 +45,9 @@
|
|
|
45
45
|
"@putout/plugin-goldstein": "./rules/goldstein",
|
|
46
46
|
"@putout/test": "^9.0.1",
|
|
47
47
|
"c8": "^9.1.0",
|
|
48
|
-
"check-dts": "^0.
|
|
48
|
+
"check-dts": "^0.8.0",
|
|
49
49
|
"esbuild": "^0.21.1",
|
|
50
50
|
"esbuild-node-builtins": "^0.1.0",
|
|
51
|
-
"escover": "^4.0.1",
|
|
52
51
|
"eslint": "^9.2.0",
|
|
53
52
|
"eslint-plugin-putout": "^22.0.0",
|
|
54
53
|
"madrun": "^10.0.0",
|
|
@@ -12,6 +12,7 @@ import keywordIf from '../keyword-if/index.js';
|
|
|
12
12
|
import keywordImport from '../keyword-import/index.js';
|
|
13
13
|
import keywordArrow from '../keyword-arrow/index.js';
|
|
14
14
|
import keywordAddArray from '../keyword-add-array/index.js';
|
|
15
|
+
import keywordBrokenString from '../keyword-broken-string/index.js';
|
|
15
16
|
|
|
16
17
|
const {values} = Object;
|
|
17
18
|
|
|
@@ -27,6 +28,7 @@ const defaultKeywords = {
|
|
|
27
28
|
keywordImport,
|
|
28
29
|
keywordArrow,
|
|
29
30
|
keywordAddArray,
|
|
31
|
+
keywordBrokenString,
|
|
30
32
|
stringInterpolation,
|
|
31
33
|
};
|
|
32
34
|
|
|
@@ -14,6 +14,7 @@ const {
|
|
|
14
14
|
export default function keywordAddArray(Parser) {
|
|
15
15
|
return class extends Parser {
|
|
16
16
|
parseMaybeAssign(forInit, refDestructuringErrors, afterLeftParse) {
|
|
17
|
+
/* c8 ignore start */
|
|
17
18
|
if (this.isContextual('yield')) {
|
|
18
19
|
if (this.inGenerator)
|
|
19
20
|
return this.parseYield(forInit);
|
|
@@ -23,6 +24,7 @@ export default function keywordAddArray(Parser) {
|
|
|
23
24
|
this.exprAllowed = false;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
/* c8 ignore end */
|
|
26
28
|
let ownDestructuringErrors = false;
|
|
27
29
|
let oldParenAssign = -1;
|
|
28
30
|
let oldTrailingComma = -1;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {tokTypes as tt} from '../operator/index.js';
|
|
2
|
+
|
|
3
|
+
export default function keywordBrokenString(Parser) {
|
|
4
|
+
return class extends Parser {
|
|
5
|
+
parseVarStatement(node, kind, allowMissingInitializer) {
|
|
6
|
+
this.next();
|
|
7
|
+
this.parseVar(node, false, kind, allowMissingInitializer);
|
|
8
|
+
this.eat(tt.semi);
|
|
9
|
+
|
|
10
|
+
return this.finishNode(node, 'VariableDeclaration');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
readString(quote) {
|
|
14
|
+
let out = '';
|
|
15
|
+
let chunkStart = ++this.pos;
|
|
16
|
+
|
|
17
|
+
for (;;) {
|
|
18
|
+
const ch = this.input.charCodeAt(this.pos);
|
|
19
|
+
|
|
20
|
+
if (ch === quote)
|
|
21
|
+
break;
|
|
22
|
+
|
|
23
|
+
/* c8 ignore start */
|
|
24
|
+
if (ch === 92) {
|
|
25
|
+
// '\'
|
|
26
|
+
out += this.input.slice(chunkStart, this.pos);
|
|
27
|
+
out += this.readEscapedChar(false);
|
|
28
|
+
chunkStart = this.pos;
|
|
29
|
+
} else if (ch === 0x2028 || ch === 0x2029) {
|
|
30
|
+
if (this.options.ecmaVersion < 10)
|
|
31
|
+
this.raise(this.start, 'Unterminated string constant');
|
|
32
|
+
|
|
33
|
+
++this.pos;
|
|
34
|
+
|
|
35
|
+
if (this.options.locations) {
|
|
36
|
+
this.curLine++;
|
|
37
|
+
this.lineStart = this.pos;
|
|
38
|
+
}
|
|
39
|
+
/* c8 ignore end */
|
|
40
|
+
} else {
|
|
41
|
+
if (isNewLine(ch)) {
|
|
42
|
+
if (this.input[this.pos - 1] === ';')
|
|
43
|
+
--this.pos;
|
|
44
|
+
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
++this.pos;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
out += this.input.slice(chunkStart, this.pos++);
|
|
53
|
+
|
|
54
|
+
return this.finishToken(tt.string, out);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isNewLine(code) {
|
|
60
|
+
return code === 10 || code === 13 || code === 0x2028 || code === 0x2029;
|
|
61
|
+
}
|
|
@@ -8,9 +8,10 @@ export default function keywordImport(Parser) {
|
|
|
8
8
|
this.next();
|
|
9
9
|
|
|
10
10
|
// import '...'
|
|
11
|
+
/* c8 ignore start */
|
|
11
12
|
if (this.type === tokTypes.string) {
|
|
12
13
|
node.specifiers = empty;
|
|
13
|
-
node.source = this.parseExprAtom();
|
|
14
|
+
node.source = this.parseExprAtom(); /* c8 ignore end */
|
|
14
15
|
} else {
|
|
15
16
|
node.specifiers = this.parseImportSpecifiers();
|
|
16
17
|
this.expectContextual('from');
|
|
@@ -104,16 +104,3 @@ export default function keywordTry(Parser) {
|
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
export function createGoldsteinTry(args) {
|
|
109
|
-
return {
|
|
110
|
-
type: 'TryStatement',
|
|
111
|
-
expression: true,
|
|
112
|
-
await: args.await,
|
|
113
|
-
argument: {
|
|
114
|
-
type: 'CallExpression',
|
|
115
|
-
callee: args.callee,
|
|
116
|
-
arguments: args.args,
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const IfStatement = (path, printer, semantics) => {
|
|
1
|
+
export const IfStatement = (path, printer) => {
|
|
4
2
|
const {print, indent} = printer;
|
|
5
3
|
const {node} = path;
|
|
6
4
|
|
|
7
|
-
if (!node.goldsteinIf)
|
|
8
|
-
return v.IfStatement(path, printer, semantics);
|
|
9
|
-
|
|
10
5
|
indent();
|
|
11
6
|
print('if ');
|
|
12
7
|
|