Skip to content

Commit

Permalink
feature: goldstein: get rid of ability to parse no async code with await
Browse files Browse the repository at this point in the history
This reverts commit 98f3048.
  • Loading branch information
coderaiser committed May 7, 2024
1 parent 587f5ae commit 44dee08
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 109 deletions.
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,22 +407,6 @@ That absolutely fine, it will be converted to:
function hello() {}
```

### `asyn`-less `Function` with `await`

```gs
function hello() {
await world();
}
```

In js:

```js
async function hello() {
await world();
}
```

## How to contribute?

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 🥳!
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@putout/plugin-declare": "^4.0.0",
"@putout/plugin-logical-expressions": "^5.0.0",
"@putout/plugin-try-catch": "^3.0.0",
"@putout/plugin-promises": "^14.1.0",
"@putout/printer": "^8.0.1",
"acorn": "^8.7.1",
"esbuild": "^0.20.1",
Expand All @@ -45,7 +44,6 @@
"devDependencies": {
"@babel/core": "^8.0.0-alpha.5",
"@cloudcmd/stub": "^4.0.1",
"@putout/plugin-goldstein": "./rules/goldstein",
"@putout/test": "^9.0.1",
"c8": "^9.1.0",
"check-dts": "^0.7.1",
Expand All @@ -59,7 +57,8 @@
"redlint": "^3.14.1",
"runsome": "^1.0.0",
"supertape": "^10.1.0",
"typescript": "^5.0.3"
"typescript": "^5.0.3",
"@putout/plugin-goldstein": "./rules/goldstein"
},
"engines": {
"node": ">=18"
Expand Down
2 changes: 0 additions & 2 deletions packages/goldstein/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {print} from '@putout/printer';
import tryCatchPlugin from '@putout/plugin-try-catch';
import declarePlugin from '@putout/plugin-declare';
import logicalExpressionsPlugin from '@putout/plugin-logical-expressions';
import promisesPlugin from '@putout/plugin-promises';
import {parse} from './parser.js';

export * from './parser.js';
Expand All @@ -20,7 +19,6 @@ export const compile = (source, options = {}) => {
['try-catch', tryCatchPlugin],
['declare', declarePlugin],
['logical-expressions', logicalExpressionsPlugin],
['promises', promisesPlugin],
],
});

Expand Down
39 changes: 4 additions & 35 deletions packages/goldstein/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ import {
test('goldstein: compile', (t) => {
const result = compile(`
fn hello() {
return 'world'
}
`);

const expected = montag`
function hello() {
return 'world';
}\n
`;
const expected = 'function hello() {}\n';

t.equal(result, expected);
t.end();
Expand Down Expand Up @@ -120,15 +115,11 @@ test('goldstein: compile: freeze', (t) => {

test('goldstein: compile: sourceType', (t) => {
const result = compile(montag`
export fn hello() {
return 'world';
};
export fn hello() {};
`);

const expected = montag`
export function hello() {
return 'world';
};
export function hello() {};
`;

Expand Down Expand Up @@ -171,14 +162,11 @@ test('goldstein: compile: curry', (t) => {
test('goldstein: compile: arrow', (t) => {
const result = compile(montag`
function hello() => {
return 'world';
}
`);

const expected = montag`
function hello() {
return 'world';
}\n
function hello() {}\n
`;

t.equal(result, expected);
Expand Down Expand Up @@ -332,22 +320,3 @@ test('goldstein: convert', (t) => {
t.equal(result, expected);
t.end();
});

test('goldstein: convert: no-async', (t) => {
const source = montag`
function hello() {
await world();
}
`;

const result = convert(source);

const expected = montag`
async function hello() {
await world();
}\n
`;

t.equal(result, expected);
t.end();
});
2 changes: 0 additions & 2 deletions packages/goldstein/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import keywordIf from '../keyword-if/index.js';
import keywordImport from '../keyword-import/index.js';
import keywordArrow from '../keyword-arrow/index.js';
import keywordAddArray from '../keyword-add-array/index.js';
import keywordNoAsync from '../keyword-no-async/index.js';

const defaultKeywords = {
keywordFn,
Expand All @@ -27,7 +26,6 @@ const defaultKeywords = {
keywordArrow,
keywordAddArray,
stringInterpolation,
keywordNoAsync,
};

export const keywords = defaultKeywords;
Expand Down
3 changes: 0 additions & 3 deletions packages/keyword-no-async/fixture/no-async.gs

This file was deleted.

3 changes: 0 additions & 3 deletions packages/keyword-no-async/fixture/no-async.js

This file was deleted.

36 changes: 0 additions & 36 deletions packages/keyword-no-async/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions packages/keyword-no-async/index.spec.js

This file was deleted.

0 comments on commit 44dee08

Please sign in to comment.