diff --git a/README.md b/README.md index 9a8d4f9..b6ddbff 100644 --- a/README.md +++ b/README.md @@ -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 🥳! diff --git a/package.json b/package.json index 3063fe3..e68ee58 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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" diff --git a/packages/goldstein/index.js b/packages/goldstein/index.js index b93d1b1..3d59edb 100644 --- a/packages/goldstein/index.js +++ b/packages/goldstein/index.js @@ -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'; @@ -20,7 +19,6 @@ export const compile = (source, options = {}) => { ['try-catch', tryCatchPlugin], ['declare', declarePlugin], ['logical-expressions', logicalExpressionsPlugin], - ['promises', promisesPlugin], ], }); diff --git a/packages/goldstein/index.spec.js b/packages/goldstein/index.spec.js index eff63b1..b10e504 100644 --- a/packages/goldstein/index.spec.js +++ b/packages/goldstein/index.spec.js @@ -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(); @@ -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() {}; `; @@ -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); @@ -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(); -}); diff --git a/packages/goldstein/parser.js b/packages/goldstein/parser.js index 094a6c8..38b53ba 100644 --- a/packages/goldstein/parser.js +++ b/packages/goldstein/parser.js @@ -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, @@ -27,7 +26,6 @@ const defaultKeywords = { keywordArrow, keywordAddArray, stringInterpolation, - keywordNoAsync, }; export const keywords = defaultKeywords; diff --git a/packages/keyword-no-async/fixture/no-async.gs b/packages/keyword-no-async/fixture/no-async.gs deleted file mode 100644 index 4be35b3..0000000 --- a/packages/keyword-no-async/fixture/no-async.gs +++ /dev/null @@ -1,3 +0,0 @@ -function hello() { - await world(); -} \ No newline at end of file diff --git a/packages/keyword-no-async/fixture/no-async.js b/packages/keyword-no-async/fixture/no-async.js deleted file mode 100644 index 27e5836..0000000 --- a/packages/keyword-no-async/fixture/no-async.js +++ /dev/null @@ -1,3 +0,0 @@ -async function hello() { - await world(); -} diff --git a/packages/keyword-no-async/index.js b/packages/keyword-no-async/index.js deleted file mode 100644 index b8d7493..0000000 --- a/packages/keyword-no-async/index.js +++ /dev/null @@ -1,36 +0,0 @@ -const {defineProperty} = Object; - -export default function fn(Parser) { - return class extends Parser { - parseFunction(node, statement, allowExpressionBody, isAsync, forInit) { - return super.parseFunction(node, statement, allowExpressionBody, true, forInit); - } - - checkUnreserved({start, end, name}) { - if (this.inGenerator && name === 'yield') - this.raiseRecoverable(start, `Cannot use 'yield' as identifier inside a generator`); - - if (this.inAsync && name === 'await') - this.raiseRecoverable(start, `Cannot use 'await' as identifier inside an async function`); - - if (this.currentThisScope().inClassFieldInit && name === 'arguments') - this.raiseRecoverable(start, `Cannot use 'arguments' in class field initializer`); - - if (this.inClassStaticBlock && (name === 'arguments' || name === 'await')) - this.raise(start, `Cannot use ${name} in class static initialization block`); - - if (this.keywords.test(name)) - this.raise(start, `Unexpected keyword '` + name + `'`); - - if (this.options.ecmaVersion < 6 && this.input.slice(start, end).includes('\\')) - return; - - const re = this.strict ? this.reservedWordsStrict : this.reservedWords; - - if (re.test(name) && !this.inAsync && name === 'await') - defineProperty(this, 'inAsync', { - value: true, - }); - } - }; -} diff --git a/packages/keyword-no-async/index.spec.js b/packages/keyword-no-async/index.spec.js deleted file mode 100644 index 7a1c0aa..0000000 --- a/packages/keyword-no-async/index.spec.js +++ /dev/null @@ -1,9 +0,0 @@ -import {createTest} from '../test/index.js'; -import keywordFn from './index.js'; - -const test = createTest(import.meta.url, keywordFn); - -test('goldstein: keyword: no-async', (t) => { - t.compile('no-async'); - t.end(); -});