├── .eslintignore ├── .eslintrc.json ├── .github ├── eslint.json └── workflows │ └── nodejs.yml ├── .gitignore ├── LICENSE ├── README.md ├── package.json ├── rollup.config.js ├── src ├── features.js ├── globals.js ├── index.js ├── parse.js ├── peek.js ├── references.js └── walk.js ├── test ├── .eslintrc.json ├── input │ ├── anonymous-block-cell.js │ ├── anonymous-expression-cell.js │ ├── anonymous-function.js │ ├── arguments-name.js │ ├── await-block-cell.js │ ├── await-in-arrow-function-expression.js │ ├── await-in-arrow-function.js │ ├── await-in-class.js │ ├── await-in-function.js │ ├── await-in-markdown.md │ ├── await-yield.js │ ├── backslash-after-dollar-markdown.md │ ├── backslash-before-dollar-markdown.md │ ├── backslash-markdown.md │ ├── bare-dynamic-import.js │ ├── basic.db.sql │ ├── basic.html │ ├── basic.sql │ ├── basic.tex │ ├── bigint-zero.js │ ├── bigint.js │ ├── binary-expression.js │ ├── block-leading-comment.js │ ├── block-trailing-comment.js │ ├── catch-clause.js │ ├── comma-then-comment.js │ ├── comment.js │ ├── computed-property-name.js │ ├── database-client.js │ ├── destructured-array-assignment.js │ ├── destructured-array-rest-assignment.js │ ├── destructured-arrow-with-default.js │ ├── destructured-assignment-with-default-assignment.js │ ├── destructured-assignment-with-default.js │ ├── destructured-object-assignment.js │ ├── destructured-object-rest-assignment.js │ ├── destructured-object-with-default.js │ ├── dynamic-import.js │ ├── empty.js │ ├── empty.md │ ├── expression-extra.js │ ├── expression-trailing-comment.js │ ├── extra-semicolon.js │ ├── file-attachment-forbidden-1.js │ ├── file-attachment-forbidden.js │ ├── file-attachment-masked.js │ ├── file-attachment-nested.js │ ├── file-attachment.js │ ├── for-await-generator.js │ ├── for-await-in-function.js │ ├── for-await.js │ ├── function-unexpected-viewof.js │ ├── global-assignment.js │ ├── illegal-arguments.js │ ├── illegal-arrow-arguments.js │ ├── import-as-duplicate.js │ ├── import-default-as.js │ ├── import-default.js │ ├── import-duplicate.js │ ├── import-empty.js │ ├── import-extra.js │ ├── import-mutable-as.js │ ├── import-mutable.js │ ├── import-semicolon.js │ ├── import-side-effect.js │ ├── import-viewof-as.js │ ├── import-viewof.js │ ├── import-with-as-duplicate.js │ ├── import-with-default-as.js │ ├── import-with-default.js │ ├── import-with-duplicate.js │ ├── import-with-empty.js │ ├── import-with.js │ ├── import.js │ ├── leading-semicolon.js │ ├── legal-arguments.js │ ├── logical-assignment.js │ ├── markdown-interpolation.md │ ├── markdown.md │ ├── member-assignment.js │ ├── multiple-input-references.js │ ├── mutable-argument.js │ ├── mutable-as-property.js │ ├── mutable-assign-default.js │ ├── mutable-assignment.js │ ├── mutable-block-cell.js │ ├── mutable-constant.js │ ├── mutable-default-value.js │ ├── mutable-destructure-array.js │ ├── mutable-destructure-object.js │ ├── mutable-destructure-property.js │ ├── mutable-in-markdown.md │ ├── mutable-internal-comment.js │ ├── mutable-member.js │ ├── mutable-reference.js │ ├── mutable-var.js │ ├── named-async-function.js │ ├── named-block-cell.js │ ├── named-class-with-field.js │ ├── named-class-with-method.js │ ├── named-class-with-private-field.js │ ├── named-class-with-static-field.js │ ├── named-class.js │ ├── named-empty.js │ ├── named-expression-cell.js │ ├── named-function-in-named-cell.js │ ├── named-function.js │ ├── named-generator-function.js │ ├── notification-client.js │ ├── nullish-coalescing.js │ ├── object-literal.js │ ├── optional-chaining.js │ ├── reserved-function.js │ ├── reserved-import-as.js │ ├── reserved-import-view.js │ ├── reserved-import-with-as.js │ ├── reserved-import-with.js │ ├── reserved-import.js │ ├── reserved-name.js │ ├── reserved-view.js │ ├── secret.js │ ├── semicolon.js │ ├── sequence-expression.js │ ├── shadowed-view.js │ ├── simple-await-tagged-template.js │ ├── simple-await-template.js │ ├── simple-await-template.md │ ├── simple-identifier.js │ ├── spread-element.js │ ├── template-literal-semicolon.js │ ├── this-as-name.js │ ├── this.js │ ├── underline.tex │ ├── var-statement.js │ ├── viewof-argument.js │ ├── viewof-assignment.js │ ├── viewof-binding.js │ ├── viewof-block-cell.js │ ├── viewof-expression-cell.js │ ├── viewof-in-markdown.md │ ├── viewof-internal-comment.js │ ├── viewof-let.js │ ├── viewof-member-expression.js │ ├── viewof-member.js │ ├── viewof-orphan.js │ ├── viewof-property.js │ ├── viewof-reference-internal-comment.js │ ├── viewof-reference.js │ ├── yield-await.js │ ├── yield-block-cell.js │ ├── yield-expression-cell.js │ ├── yield-in-function.js │ └── yield-star-expression-cell.js ├── output │ ├── anonymous-block-cell.js.json │ ├── anonymous-expression-cell.js.json │ ├── anonymous-function.js.json │ ├── arguments-name.js.json │ ├── await-block-cell.js.json │ ├── await-in-arrow-function-expression.js.json │ ├── await-in-arrow-function.js.json │ ├── await-in-class.js.json │ ├── await-in-function.js.json │ ├── await-in-markdown.md.json │ ├── await-yield.js.json │ ├── backslash-after-dollar-markdown.md.json │ ├── backslash-before-dollar-markdown.md.json │ ├── backslash-markdown.md.json │ ├── bare-dynamic-import.js.json │ ├── basic.db.sql.json │ ├── basic.html.json │ ├── basic.sql.json │ ├── basic.tex.json │ ├── bigint-zero.js.json │ ├── bigint.js.json │ ├── binary-expression.js.json │ ├── block-leading-comment.js.json │ ├── block-trailing-comment.js.json │ ├── catch-clause.js.json │ ├── comma-then-comment.js.json │ ├── comment.js.json │ ├── computed-property-name.js.json │ ├── database-client.js.json │ ├── destructured-array-assignment.js.json │ ├── destructured-array-rest-assignment.js.json │ ├── destructured-arrow-with-default.js.json │ ├── destructured-assignment-with-default-assignment.js.json │ ├── destructured-assignment-with-default.js.json │ ├── destructured-object-assignment.js.json │ ├── destructured-object-rest-assignment.js.json │ ├── destructured-object-with-default.js.json │ ├── dynamic-import.js.json │ ├── empty.js.json │ ├── empty.md.json │ ├── expression-extra.js.json │ ├── expression-trailing-comment.js.json │ ├── extra-semicolon.js.json │ ├── file-attachment-forbidden-1.js.json │ ├── file-attachment-forbidden.js.json │ ├── file-attachment-masked.js.json │ ├── file-attachment-nested.js.json │ ├── file-attachment.js.json │ ├── for-await-generator.js.json │ ├── for-await-in-function.js.json │ ├── for-await.js.json │ ├── function-unexpected-viewof.js.json │ ├── global-assignment.js.json │ ├── illegal-arguments.js.json │ ├── illegal-arrow-arguments.js.json │ ├── import-as-duplicate.js.json │ ├── import-default-as.js.json │ ├── import-default.js.json │ ├── import-duplicate.js.json │ ├── import-empty.js.json │ ├── import-extra.js.json │ ├── import-mutable-as.js.json │ ├── import-mutable.js.json │ ├── import-semicolon.js.json │ ├── import-side-effect.js.json │ ├── import-viewof-as.js.json │ ├── import-viewof.js.json │ ├── import-with-as-duplicate.js.json │ ├── import-with-default-as.js.json │ ├── import-with-default.js.json │ ├── import-with-duplicate.js.json │ ├── import-with-empty.js.json │ ├── import-with.js.json │ ├── import.js.json │ ├── leading-semicolon.js.json │ ├── legal-arguments.js.json │ ├── logical-assignment.js.json │ ├── markdown-interpolation.md.json │ ├── markdown.md.json │ ├── member-assignment.js.json │ ├── multiple-input-references.js.json │ ├── mutable-argument.js.json │ ├── mutable-as-property.js.json │ ├── mutable-assign-default.js.json │ ├── mutable-assignment.js.json │ ├── mutable-block-cell.js.json │ ├── mutable-constant.js.json │ ├── mutable-default-value.js.json │ ├── mutable-destructure-array.js.json │ ├── mutable-destructure-object.js.json │ ├── mutable-destructure-property.js.json │ ├── mutable-in-markdown.md.json │ ├── mutable-internal-comment.js.json │ ├── mutable-member.js.json │ ├── mutable-reference.js.json │ ├── mutable-var.js.json │ ├── named-async-function.js.json │ ├── named-block-cell.js.json │ ├── named-class-with-field.js.json │ ├── named-class-with-method.js.json │ ├── named-class-with-private-field.js.json │ ├── named-class-with-static-field.js.json │ ├── named-class.js.json │ ├── named-empty.js.json │ ├── named-expression-cell.js.json │ ├── named-function-in-named-cell.js.json │ ├── named-function.js.json │ ├── named-generator-function.js.json │ ├── notification-client.js.json │ ├── nullish-coalescing.js.json │ ├── object-literal.js.json │ ├── optional-chaining.js.json │ ├── reserved-function.js.json │ ├── reserved-import-as.js.json │ ├── reserved-import-view.js.json │ ├── reserved-import-with-as.js.json │ ├── reserved-import-with.js.json │ ├── reserved-import.js.json │ ├── reserved-name.js.json │ ├── reserved-view.js.json │ ├── secret.js.json │ ├── semicolon.js.json │ ├── sequence-expression.js.json │ ├── shadowed-view.js.json │ ├── simple-await-tagged-template.js.json │ ├── simple-await-template.js.json │ ├── simple-await-template.md.json │ ├── simple-identifier.js.json │ ├── spread-element.js.json │ ├── template-literal-semicolon.js.json │ ├── this-as-name.js.json │ ├── this.js.json │ ├── underline.tex.json │ ├── var-statement.js.json │ ├── viewof-argument.js.json │ ├── viewof-assignment.js.json │ ├── viewof-binding.js.json │ ├── viewof-block-cell.js.json │ ├── viewof-expression-cell.js.json │ ├── viewof-in-markdown.md.json │ ├── viewof-internal-comment.js.json │ ├── viewof-let.js.json │ ├── viewof-member-expression.js.json │ ├── viewof-member.js.json │ ├── viewof-orphan.js.json │ ├── viewof-property.js.json │ ├── viewof-reference-internal-comment.js.json │ ├── viewof-reference.js.json │ ├── yield-await.js.json │ ├── yield-block-cell.js.json │ ├── yield-expression-cell.js.json │ ├── yield-in-function.js.json │ └── yield-star-expression-cell.js.json ├── parse-test.js ├── peek-test.js └── references-test.js └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | test/input/ 3 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "parserOptions": { 4 | "sourceType": "module", 5 | "ecmaVersion": 2020 6 | }, 7 | "env": { 8 | "es6": true, 9 | "node": true 10 | }, 11 | "rules": { 12 | "no-cond-assign": 0, 13 | "no-var": 2, 14 | "comma-dangle": ["error", "never"], 15 | "semi": [2, "always"], 16 | "quotes": ["error", "double", {"allowTemplateLiterals": true}] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.github/eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "problemMatcher": [ 3 | { 4 | "owner": "eslint-compact", 5 | "pattern": [ 6 | { 7 | "regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$", 8 | "file": 1, 9 | "line": 2, 10 | "column": 3, 11 | "severity": 4, 12 | "message": 5, 13 | "code": 6 14 | } 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | # https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 2 | 3 | name: Node.js CI 4 | 5 | on: 6 | push: 7 | branches: [ main ] 8 | pull_request: 9 | branches: [ main ] 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | strategy: 17 | matrix: 18 | node-version: [14.x] 19 | 20 | steps: 21 | - uses: actions/checkout@v2 22 | - name: Use Node.js ${{ matrix.node-version }} 23 | uses: actions/setup-node@v1 24 | with: 25 | node-version: ${{ matrix.node-version }} 26 | - run: yarn --frozen-lockfile 27 | - run: | 28 | echo ::add-matcher::.github/eslint.json 29 | yarn run eslint . --format=compact 30 | - run: yarn test 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | dist/ 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 Observable, Inc. 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose 4 | with or without fee is hereby granted, provided that the above copyright notice 5 | and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 9 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 11 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 12 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 13 | THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@observablehq/parser", 3 | "description": "An Acorn parser for Observable JavaScript", 4 | "version": "6.1.0", 5 | "author": { 6 | "name": "Observable, Inc.", 7 | "url": "https://observablehq.com" 8 | }, 9 | "license": "ISC", 10 | "type": "module", 11 | "main": "src/index.js", 12 | "module": "src/index.js", 13 | "jsdelivr": "dist/parser.min.js", 14 | "unpkg": "dist/parser.min.js", 15 | "exports": { 16 | "umd": "./dist/parser.min.js", 17 | "default": "./src/index.js" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/observablehq/parser.git" 22 | }, 23 | "files": [ 24 | "dist/**/*.js", 25 | "src/**/*.js" 26 | ], 27 | "engines": { 28 | "node": ">=14.5.0" 29 | }, 30 | "scripts": { 31 | "test": "mkdir -p test/output && mocha -r module-alias/register 'test/**/*-test.js' && eslint src test", 32 | "prepublishOnly": "rm -rf dist && rollup -c", 33 | "postpublish": "git push && git push --tags" 34 | }, 35 | "_moduleAliases": { 36 | "@observablehq/parser": "./src/index.js" 37 | }, 38 | "dependencies": { 39 | "acorn": "8", 40 | "acorn-walk": "8" 41 | }, 42 | "devDependencies": { 43 | "eslint": "8", 44 | "mocha": "9", 45 | "module-alias": "2", 46 | "rollup": "2", 47 | "rollup-plugin-terser": "7" 48 | }, 49 | "publishConfig": { 50 | "access": "public" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import {terser} from "rollup-plugin-terser"; 2 | import * as meta from "./package.json"; 3 | 4 | const copyright = `// @observablehq/parser v${meta.version} Copyright ${(new Date).getFullYear()} Observable, Inc.`; 5 | 6 | export default [ 7 | { 8 | input: "src/index.js", 9 | plugins: [ 10 | terser({ 11 | output: {preamble: copyright}, 12 | mangle: {reserved: ["RequireError"]} 13 | }) 14 | ], 15 | external: [ 16 | "acorn", 17 | "acorn-walk" 18 | ], 19 | output: { 20 | globals: { 21 | "acorn": "acorn", 22 | "acorn-walk": "acorn.walk" 23 | }, 24 | format: "umd", 25 | extend: true, 26 | name: "observablehq", 27 | file: "dist/parser.min.js" 28 | } 29 | } 30 | ]; 31 | -------------------------------------------------------------------------------- /src/features.js: -------------------------------------------------------------------------------- 1 | import {simple} from "acorn-walk"; 2 | import walk from "./walk.js"; 3 | 4 | export default function findFeatures(cell, featureName) { 5 | const ast = {type: "Program", body: [cell.body]}; 6 | const features = new Map(); 7 | const {references} = cell; 8 | 9 | simple( 10 | ast, 11 | { 12 | CallExpression: node => { 13 | const {callee, arguments: args} = node; 14 | 15 | // Ignore function calls that are not references to the feature. 16 | if ( 17 | callee.type !== "Identifier" || 18 | callee.name !== featureName || 19 | references.indexOf(callee) < 0 20 | ) return; 21 | 22 | // Forbid dynamic calls. 23 | if ( 24 | args.length !== 1 || 25 | !((args[0].type === "Literal" && /^['"]/.test(args[0].raw)) || 26 | (args[0].type === "TemplateLiteral" && args[0].expressions.length === 0)) 27 | ) { 28 | throw Object.assign(new SyntaxError(`${featureName} requires a single literal string argument`), {node}); 29 | } 30 | 31 | const [arg] = args; 32 | const name = arg.type === "Literal" ? arg.value : arg.quasis[0].value.cooked; 33 | const location = {start: arg.start, end: arg.end}; 34 | if (features.has(name)) features.get(name).push(location); 35 | else features.set(name, [location]); 36 | } 37 | }, 38 | walk 39 | ); 40 | 41 | return features; 42 | } 43 | -------------------------------------------------------------------------------- /src/globals.js: -------------------------------------------------------------------------------- 1 | export default new Set([ 2 | "Array", 3 | "ArrayBuffer", 4 | "atob", 5 | "AudioContext", 6 | "Blob", 7 | "Boolean", 8 | "BigInt", 9 | "btoa", 10 | "clearInterval", 11 | "clearTimeout", 12 | "console", 13 | "crypto", 14 | "CustomEvent", 15 | "DataView", 16 | "Date", 17 | "decodeURI", 18 | "decodeURIComponent", 19 | "devicePixelRatio", 20 | "document", 21 | "encodeURI", 22 | "encodeURIComponent", 23 | "Error", 24 | "escape", 25 | "eval", 26 | "fetch", 27 | "File", 28 | "FileList", 29 | "FileReader", 30 | "Float32Array", 31 | "Float64Array", 32 | "Function", 33 | "Headers", 34 | "Image", 35 | "ImageData", 36 | "Infinity", 37 | "Int16Array", 38 | "Int32Array", 39 | "Int8Array", 40 | "Intl", 41 | "isFinite", 42 | "isNaN", 43 | "JSON", 44 | "Map", 45 | "Math", 46 | "NaN", 47 | "Number", 48 | "navigator", 49 | "Object", 50 | "parseFloat", 51 | "parseInt", 52 | "performance", 53 | "Path2D", 54 | "Promise", 55 | "Proxy", 56 | "RangeError", 57 | "ReferenceError", 58 | "Reflect", 59 | "RegExp", 60 | "cancelAnimationFrame", 61 | "requestAnimationFrame", 62 | "Set", 63 | "setInterval", 64 | "setTimeout", 65 | "String", 66 | "Symbol", 67 | "SyntaxError", 68 | "TextDecoder", 69 | "TextEncoder", 70 | "this", 71 | "TypeError", 72 | "Uint16Array", 73 | "Uint32Array", 74 | "Uint8Array", 75 | "Uint8ClampedArray", 76 | "undefined", 77 | "unescape", 78 | "URIError", 79 | "URL", 80 | "WeakMap", 81 | "WeakSet", 82 | "WebSocket", 83 | "Worker", 84 | "window" 85 | ]); 86 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | export {parseCell, CellParser, TemplateCellParser} from "./parse.js"; 2 | export {peekId} from "./peek.js"; 3 | export {default as walk} from "./walk.js"; 4 | -------------------------------------------------------------------------------- /src/peek.js: -------------------------------------------------------------------------------- 1 | import {tokTypes as tt, Parser} from "acorn"; 2 | 3 | const STATE_START = Symbol("start"); 4 | const STATE_MODIFIER = Symbol("modifier"); 5 | const STATE_FUNCTION = Symbol("function"); 6 | const STATE_NAME = Symbol("name"); 7 | 8 | /* 9 | ┌─────┐ 10 | ┌───────────│START│─function|class 11 | │ └─────┘ │ 12 | viewof|mutable|async │ ▼ 13 | │ │ ┌────────┐ ┌─┐ 14 | ▼ │ │FUNCTION│◀───▶│*│ 15 | ┌────────┐ │ └────────┘ └─┘ 16 | │MODIFIER│ │ │ 17 | └────────┘ name name 18 | │ │ │ 19 | └──name─┐ │ ▼ 20 | ▼ │ ┌─────────────┐ 21 | ┌────────┐ │ │FUNCTION_NAME│ 22 | │ NAME │◀─┘ └─────────────┘ 23 | └────────┘ 24 | │ 25 | = 26 | ▼ 27 | ┌────────┐ 28 | │ EQ │ 29 | └────────┘ 30 | */ 31 | 32 | export function peekId(input) { 33 | let state = STATE_START; 34 | let name; 35 | try { 36 | for (const token of Parser.tokenizer(input, {ecmaVersion: 11})) { 37 | switch (state) { 38 | case STATE_START: 39 | case STATE_MODIFIER: { 40 | if (token.type === tt.name) { 41 | if ( 42 | state === STATE_START && 43 | (token.value === "viewof" || 44 | token.value === "mutable" || 45 | token.value === "async") 46 | ) { 47 | state = STATE_MODIFIER; 48 | continue; 49 | } 50 | state = STATE_NAME; 51 | name = token; 52 | continue; 53 | } 54 | if (token.type === tt._function || token.type === tt._class) { 55 | state = STATE_FUNCTION; 56 | continue; 57 | } 58 | break; 59 | } 60 | case STATE_NAME: { 61 | if (token.type === tt.eq) return name.value; 62 | break; 63 | } 64 | case STATE_FUNCTION: { 65 | if (token.type === tt.star) continue; 66 | if (token.type === tt.name && token.end < input.length) 67 | return token.value; 68 | break; 69 | } 70 | } 71 | return; 72 | } 73 | } catch (ignore) { 74 | return; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/walk.js: -------------------------------------------------------------------------------- 1 | import {make} from "acorn-walk"; 2 | 3 | export default make({ 4 | Import() {}, 5 | ViewExpression(node, st, c) { 6 | c(node.id, st, "Identifier"); 7 | }, 8 | MutableExpression(node, st, c) { 9 | c(node.id, st, "Identifier"); 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/input/anonymous-block-cell.js: -------------------------------------------------------------------------------- 1 | { 2 | return 42; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/anonymous-expression-cell.js: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/input/anonymous-function.js: -------------------------------------------------------------------------------- 1 | function() { return 42; } 2 | -------------------------------------------------------------------------------- /test/input/arguments-name.js: -------------------------------------------------------------------------------- 1 | arguments = false 2 | -------------------------------------------------------------------------------- /test/input/await-block-cell.js: -------------------------------------------------------------------------------- 1 | { 2 | await promise; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/await-in-arrow-function-expression.js: -------------------------------------------------------------------------------- 1 | async () => { 2 | await promise; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/await-in-arrow-function.js: -------------------------------------------------------------------------------- 1 | { 2 | const inner = async () => { 3 | await promise; 4 | }; 5 | } 6 | -------------------------------------------------------------------------------- /test/input/await-in-class.js: -------------------------------------------------------------------------------- 1 | { 2 | class Inner { 3 | async method() { 4 | await promise; 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/input/await-in-function.js: -------------------------------------------------------------------------------- 1 | { 2 | async function inner() { 3 | await promise; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/input/await-in-markdown.md: -------------------------------------------------------------------------------- 1 | **${await importantValue()}** 2 | -------------------------------------------------------------------------------- /test/input/await-yield.js: -------------------------------------------------------------------------------- 1 | { 2 | await promise; 3 | yield value; 4 | } 5 | -------------------------------------------------------------------------------- /test/input/backslash-after-dollar-markdown.md: -------------------------------------------------------------------------------- 1 | $\{foo} 2 | -------------------------------------------------------------------------------- /test/input/backslash-before-dollar-markdown.md: -------------------------------------------------------------------------------- 1 | \${foo} 2 | -------------------------------------------------------------------------------- /test/input/backslash-markdown.md: -------------------------------------------------------------------------------- 1 | \Slash before, slash after\ -------------------------------------------------------------------------------- /test/input/bare-dynamic-import.js: -------------------------------------------------------------------------------- 1 | import("bar") 2 | -------------------------------------------------------------------------------- /test/input/basic.db.sql: -------------------------------------------------------------------------------- 1 | SELECT * FROM my_table WHERE my_column = ${val} 2 | -------------------------------------------------------------------------------- /test/input/basic.html: -------------------------------------------------------------------------------- 1 |
${hello}
-------------------------------------------------------------------------------- /test/input/basic.sql: -------------------------------------------------------------------------------- 1 | SELECT * FROM my_table WHERE my_column = ${val} -------------------------------------------------------------------------------- /test/input/basic.tex: -------------------------------------------------------------------------------- 1 | ${numerator} \over ${denominator} -------------------------------------------------------------------------------- /test/input/bigint-zero.js: -------------------------------------------------------------------------------- 1 | 0n 2 | -------------------------------------------------------------------------------- /test/input/bigint.js: -------------------------------------------------------------------------------- 1 | foo + 42n 2 | -------------------------------------------------------------------------------- /test/input/binary-expression.js: -------------------------------------------------------------------------------- 1 | foo + 42 2 | -------------------------------------------------------------------------------- /test/input/block-leading-comment.js: -------------------------------------------------------------------------------- 1 | // Hello, comment. 2 | foo = { 3 | return 42; 4 | } 5 | -------------------------------------------------------------------------------- /test/input/block-trailing-comment.js: -------------------------------------------------------------------------------- 1 | foo = { 2 | return 42; 3 | } // Hello, comment. 4 | -------------------------------------------------------------------------------- /test/input/catch-clause.js: -------------------------------------------------------------------------------- 1 | { 2 | try { 3 | let [x] = y; 4 | x++; 5 | return x; 6 | } catch (e) { 7 | return e; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/input/comma-then-comment.js: -------------------------------------------------------------------------------- 1 | foo, // Oops, invalid syntax. 2 | -------------------------------------------------------------------------------- /test/input/comment.js: -------------------------------------------------------------------------------- 1 | // Hello, comment. 2 | -------------------------------------------------------------------------------- /test/input/computed-property-name.js: -------------------------------------------------------------------------------- 1 | ({[field]: value}) => value 2 | -------------------------------------------------------------------------------- /test/input/database-client.js: -------------------------------------------------------------------------------- 1 | { 2 | let a = DatabaseClient("a"); 3 | } 4 | -------------------------------------------------------------------------------- /test/input/destructured-array-assignment.js: -------------------------------------------------------------------------------- 1 | { 2 | ([md] = []); 3 | } 4 | -------------------------------------------------------------------------------- /test/input/destructured-array-rest-assignment.js: -------------------------------------------------------------------------------- 1 | { 2 | ([,,...md] = {}); 3 | } 4 | -------------------------------------------------------------------------------- /test/input/destructured-arrow-with-default.js: -------------------------------------------------------------------------------- 1 | fun = ({foo = "default"}) => {} 2 | -------------------------------------------------------------------------------- /test/input/destructured-assignment-with-default-assignment.js: -------------------------------------------------------------------------------- 1 | { 2 | let value; 3 | ({foo: value = (md = true)} = {}); 4 | } 5 | -------------------------------------------------------------------------------- /test/input/destructured-assignment-with-default.js: -------------------------------------------------------------------------------- 1 | { 2 | let value; 3 | ({foo: value = md} = {}); 4 | } 5 | -------------------------------------------------------------------------------- /test/input/destructured-object-assignment.js: -------------------------------------------------------------------------------- 1 | { 2 | ({md} = {}); 3 | } 4 | -------------------------------------------------------------------------------- /test/input/destructured-object-rest-assignment.js: -------------------------------------------------------------------------------- 1 | { 2 | ({...md} = {}); 3 | } 4 | -------------------------------------------------------------------------------- /test/input/destructured-object-with-default.js: -------------------------------------------------------------------------------- 1 | function fun({foo = "default"}) {} 2 | -------------------------------------------------------------------------------- /test/input/dynamic-import.js: -------------------------------------------------------------------------------- 1 | foo = import("bar") 2 | -------------------------------------------------------------------------------- /test/input/empty.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/observablehq/parser/b6ec1db139913493b39c9d0ccb02a1636570a64e/test/input/empty.js -------------------------------------------------------------------------------- /test/input/empty.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/observablehq/parser/b6ec1db139913493b39c9d0ccb02a1636570a64e/test/input/empty.md -------------------------------------------------------------------------------- /test/input/expression-extra.js: -------------------------------------------------------------------------------- 1 | foo bar 2 | -------------------------------------------------------------------------------- /test/input/expression-trailing-comment.js: -------------------------------------------------------------------------------- 1 | foo = 42 // Hello, comment. 2 | -------------------------------------------------------------------------------- /test/input/extra-semicolon.js: -------------------------------------------------------------------------------- 1 | foo = 42; 2 | -------------------------------------------------------------------------------- /test/input/file-attachment-forbidden-1.js: -------------------------------------------------------------------------------- 1 | x = FileAttachment(`hi ${1}`) 2 | -------------------------------------------------------------------------------- /test/input/file-attachment-forbidden.js: -------------------------------------------------------------------------------- 1 | x = FileAttachment("hi" + 1) 2 | -------------------------------------------------------------------------------- /test/input/file-attachment-masked.js: -------------------------------------------------------------------------------- 1 | { 2 | let FileAttachment = (a, b) => a + b; 3 | return FileAttachment(1, 2); 4 | } 5 | -------------------------------------------------------------------------------- /test/input/file-attachment-nested.js: -------------------------------------------------------------------------------- 1 | viewof slider = { 2 | while (count > 0) { 3 | let b, c; 4 | const a = FileAttachment("a"); 5 | if (condition) { 6 | b = defaultFile ? defaultFileValue : FileAttachment('b'); 7 | c = FileAttachment(`c`); 8 | } 9 | } 10 | return input(a, b, c); 11 | } 12 | -------------------------------------------------------------------------------- /test/input/file-attachment.js: -------------------------------------------------------------------------------- 1 | { 2 | let a = FileAttachment("a"); 3 | let b = FileAttachment('b'); 4 | let c = FileAttachment(`c`); 5 | let c2 = FileAttachment("c"); 6 | } 7 | -------------------------------------------------------------------------------- /test/input/for-await-generator.js: -------------------------------------------------------------------------------- 1 | { 2 | for await (const value of foo()) { 3 | yield value; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/input/for-await-in-function.js: -------------------------------------------------------------------------------- 1 | async function bar() { 2 | const values = []; 3 | for await (const value of foo()) { 4 | values.push(value); 5 | } 6 | return values; 7 | } 8 | -------------------------------------------------------------------------------- /test/input/for-await.js: -------------------------------------------------------------------------------- 1 | { 2 | const values = []; 3 | for await (const value of foo()) { 4 | values.push(value); 5 | } 6 | return values; 7 | } 8 | -------------------------------------------------------------------------------- /test/input/function-unexpected-viewof.js: -------------------------------------------------------------------------------- 1 | function viewof() {} 2 | -------------------------------------------------------------------------------- /test/input/global-assignment.js: -------------------------------------------------------------------------------- 1 | { 2 | foo = 42; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/illegal-arguments.js: -------------------------------------------------------------------------------- 1 | 1 + arguments.length 2 | -------------------------------------------------------------------------------- /test/input/illegal-arrow-arguments.js: -------------------------------------------------------------------------------- 1 | () => arguments.length 2 | -------------------------------------------------------------------------------- /test/input/import-as-duplicate.js: -------------------------------------------------------------------------------- 1 | import {foo, bar as foo} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-default-as.js: -------------------------------------------------------------------------------- 1 | import {default as foo} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-default.js: -------------------------------------------------------------------------------- 1 | import foo from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-duplicate.js: -------------------------------------------------------------------------------- 1 | import {foo, foo} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-empty.js: -------------------------------------------------------------------------------- 1 | import {} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-extra.js: -------------------------------------------------------------------------------- 1 | import {foo, bar as baz} from "module" foo 2 | -------------------------------------------------------------------------------- /test/input/import-mutable-as.js: -------------------------------------------------------------------------------- 1 | import {mutable foo as bar} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-mutable.js: -------------------------------------------------------------------------------- 1 | import {mutable foo} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-semicolon.js: -------------------------------------------------------------------------------- 1 | import {foo, bar as baz} from "module"; 2 | -------------------------------------------------------------------------------- /test/input/import-side-effect.js: -------------------------------------------------------------------------------- 1 | import "module" 2 | -------------------------------------------------------------------------------- /test/input/import-viewof-as.js: -------------------------------------------------------------------------------- 1 | import {viewof foo as bar} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-viewof.js: -------------------------------------------------------------------------------- 1 | import {viewof foo} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-with-as-duplicate.js: -------------------------------------------------------------------------------- 1 | import {} with {foo, bar as foo} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-with-default-as.js: -------------------------------------------------------------------------------- 1 | import {foo} with {baz as default} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-with-default.js: -------------------------------------------------------------------------------- 1 | import {foo} with {default as baz} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-with-duplicate.js: -------------------------------------------------------------------------------- 1 | import {} with {foo, foo} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-with-empty.js: -------------------------------------------------------------------------------- 1 | import {foo} with {} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import-with.js: -------------------------------------------------------------------------------- 1 | import {foo} with {bar as baz} from "module" 2 | -------------------------------------------------------------------------------- /test/input/import.js: -------------------------------------------------------------------------------- 1 | import {foo, bar as baz} from "module" 2 | -------------------------------------------------------------------------------- /test/input/leading-semicolon.js: -------------------------------------------------------------------------------- 1 | ;42 2 | -------------------------------------------------------------------------------- /test/input/legal-arguments.js: -------------------------------------------------------------------------------- 1 | function() { return arguments.length; } 2 | -------------------------------------------------------------------------------- /test/input/logical-assignment.js: -------------------------------------------------------------------------------- 1 | { 2 | let a = null; 3 | let b = false; 4 | a ||= b; 5 | return a; 6 | } 7 | -------------------------------------------------------------------------------- /test/input/markdown-interpolation.md: -------------------------------------------------------------------------------- 1 | Count: ${++mutable count} 2 | View: ${viewof Foo} 3 | Regular Value: ${value} 4 | -------------------------------------------------------------------------------- /test/input/markdown.md: -------------------------------------------------------------------------------- 1 | # Header 1 2 | 3 | ``` 4 | const codeBlock = true; 5 | ``` 6 | 7 | Paragraph that references `codeBlock`. Foo value: "${foo}". -------------------------------------------------------------------------------- /test/input/member-assignment.js: -------------------------------------------------------------------------------- 1 | window.foo = 2 2 | -------------------------------------------------------------------------------- /test/input/multiple-input-references.js: -------------------------------------------------------------------------------- 1 | cell = { 2 | const sum = a + b; 3 | const product = a * b; 4 | const difference = a - b; 5 | return {sum, product, difference}; 6 | } 7 | -------------------------------------------------------------------------------- /test/input/mutable-argument.js: -------------------------------------------------------------------------------- 1 | function fn(mutable) { 2 | return mutable; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/mutable-as-property.js: -------------------------------------------------------------------------------- 1 | object[mutable foo] + 1 2 | -------------------------------------------------------------------------------- /test/input/mutable-assign-default.js: -------------------------------------------------------------------------------- 1 | mutable state = await Service.fetch(config) 2 | -------------------------------------------------------------------------------- /test/input/mutable-assignment.js: -------------------------------------------------------------------------------- 1 | { 2 | mutable value = 101; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/mutable-block-cell.js: -------------------------------------------------------------------------------- 1 | mutable foo = { 2 | return {x: 0, y: 0}; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/mutable-constant.js: -------------------------------------------------------------------------------- 1 | mutable 101 2 | -------------------------------------------------------------------------------- /test/input/mutable-default-value.js: -------------------------------------------------------------------------------- 1 | function fn(y = mutable x) { 2 | return y; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/mutable-destructure-array.js: -------------------------------------------------------------------------------- 1 | ([mutable x] = [42]) 2 | -------------------------------------------------------------------------------- /test/input/mutable-destructure-object.js: -------------------------------------------------------------------------------- 1 | ({property: mutable x} = {property: value}) 2 | -------------------------------------------------------------------------------- /test/input/mutable-destructure-property.js: -------------------------------------------------------------------------------- 1 | ({mutable property} = {mutable property: 42}) 2 | -------------------------------------------------------------------------------- /test/input/mutable-in-markdown.md: -------------------------------------------------------------------------------- 1 | ${++mutable counter}. First item 2 | ${++mutable counter}. Second item 3 | ${++mutable counter}. Third item 4 | -------------------------------------------------------------------------------- /test/input/mutable-internal-comment.js: -------------------------------------------------------------------------------- 1 | mutable /* comment */ value 2 | -------------------------------------------------------------------------------- /test/input/mutable-member.js: -------------------------------------------------------------------------------- 1 | object.mutable foo + 1 2 | -------------------------------------------------------------------------------- /test/input/mutable-reference.js: -------------------------------------------------------------------------------- 1 | mutable value.property 2 | -------------------------------------------------------------------------------- /test/input/mutable-var.js: -------------------------------------------------------------------------------- 1 | { 2 | var mutable = 2; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/named-async-function.js: -------------------------------------------------------------------------------- 1 | async function foo() { await promise; } 2 | -------------------------------------------------------------------------------- /test/input/named-block-cell.js: -------------------------------------------------------------------------------- 1 | foo = { 2 | return 42; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/named-class-with-field.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | field = "field"; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/named-class-with-method.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | method() { 3 | return "foo"; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/input/named-class-with-private-field.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | #field = "field"; 3 | #method() {} 4 | } 5 | -------------------------------------------------------------------------------- /test/input/named-class-with-static-field.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static field = "field"; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/named-class.js: -------------------------------------------------------------------------------- 1 | class Foo {} 2 | -------------------------------------------------------------------------------- /test/input/named-empty.js: -------------------------------------------------------------------------------- 1 | foo = 2 | -------------------------------------------------------------------------------- /test/input/named-expression-cell.js: -------------------------------------------------------------------------------- 1 | foo = 42 2 | -------------------------------------------------------------------------------- /test/input/named-function-in-named-cell.js: -------------------------------------------------------------------------------- 1 | foo = function bar() { return 42; } 2 | -------------------------------------------------------------------------------- /test/input/named-function.js: -------------------------------------------------------------------------------- 1 | function foo() { return 42; } 2 | -------------------------------------------------------------------------------- /test/input/named-generator-function.js: -------------------------------------------------------------------------------- 1 | function* foo() { yield 42; } 2 | -------------------------------------------------------------------------------- /test/input/notification-client.js: -------------------------------------------------------------------------------- 1 | { 2 | let a = NotificationClient("slack:@claire"); 3 | } 4 | -------------------------------------------------------------------------------- /test/input/nullish-coalescing.js: -------------------------------------------------------------------------------- 1 | foo = null ?? 'default string' 2 | -------------------------------------------------------------------------------- /test/input/object-literal.js: -------------------------------------------------------------------------------- 1 | ({foo: 42}) 2 | -------------------------------------------------------------------------------- /test/input/optional-chaining.js: -------------------------------------------------------------------------------- 1 | dogName = adventurer.dog?.name 2 | -------------------------------------------------------------------------------- /test/input/reserved-function.js: -------------------------------------------------------------------------------- 1 | function Array() {} 2 | -------------------------------------------------------------------------------- /test/input/reserved-import-as.js: -------------------------------------------------------------------------------- 1 | import {foo as Array} from "module" 2 | -------------------------------------------------------------------------------- /test/input/reserved-import-view.js: -------------------------------------------------------------------------------- 1 | import {viewof Array} from "module" 2 | -------------------------------------------------------------------------------- /test/input/reserved-import-with-as.js: -------------------------------------------------------------------------------- 1 | import {foo} with {bar as Array} from "module" 2 | -------------------------------------------------------------------------------- /test/input/reserved-import-with.js: -------------------------------------------------------------------------------- 1 | import {foo} with {Array} from "module" 2 | -------------------------------------------------------------------------------- /test/input/reserved-import.js: -------------------------------------------------------------------------------- 1 | import {Array} from "module" 2 | -------------------------------------------------------------------------------- /test/input/reserved-name.js: -------------------------------------------------------------------------------- 1 | Array = false 2 | -------------------------------------------------------------------------------- /test/input/reserved-view.js: -------------------------------------------------------------------------------- 1 | viewof Array = false 2 | -------------------------------------------------------------------------------- /test/input/secret.js: -------------------------------------------------------------------------------- 1 | { 2 | let a = Secret("a"); 3 | } 4 | -------------------------------------------------------------------------------- /test/input/semicolon.js: -------------------------------------------------------------------------------- 1 | ; 2 | -------------------------------------------------------------------------------- /test/input/sequence-expression.js: -------------------------------------------------------------------------------- 1 | 1, 2, 3 2 | -------------------------------------------------------------------------------- /test/input/shadowed-view.js: -------------------------------------------------------------------------------- 1 | { 2 | let x = 2; 3 | x = 4; 4 | return viewof x; 5 | } 6 | -------------------------------------------------------------------------------- /test/input/simple-await-tagged-template.js: -------------------------------------------------------------------------------- 1 | md`${await promise}` 2 | -------------------------------------------------------------------------------- /test/input/simple-await-template.js: -------------------------------------------------------------------------------- 1 | `${await promise}` 2 | -------------------------------------------------------------------------------- /test/input/simple-await-template.md: -------------------------------------------------------------------------------- 1 | ${await promise} -------------------------------------------------------------------------------- /test/input/simple-identifier.js: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /test/input/spread-element.js: -------------------------------------------------------------------------------- 1 | ({foo, ...bar}) => bar 2 | -------------------------------------------------------------------------------- /test/input/template-literal-semicolon.js: -------------------------------------------------------------------------------- 1 | html`hello`; 2 | -------------------------------------------------------------------------------- /test/input/this-as-name.js: -------------------------------------------------------------------------------- 1 | this = 42 2 | -------------------------------------------------------------------------------- /test/input/this.js: -------------------------------------------------------------------------------- 1 | this 2 | -------------------------------------------------------------------------------- /test/input/underline.tex: -------------------------------------------------------------------------------- 1 | \text{This is some text \underline{with an underline}} -------------------------------------------------------------------------------- /test/input/var-statement.js: -------------------------------------------------------------------------------- 1 | var foo = 42 2 | -------------------------------------------------------------------------------- /test/input/viewof-argument.js: -------------------------------------------------------------------------------- 1 | function foo(viewof) { 2 | return viewof; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/viewof-assignment.js: -------------------------------------------------------------------------------- 1 | { 2 | viewof foo = 2; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/viewof-binding.js: -------------------------------------------------------------------------------- 1 | { 2 | let viewof foo = 2; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/viewof-block-cell.js: -------------------------------------------------------------------------------- 1 | viewof foo = { 2 | return DOM.input(); 3 | } 4 | -------------------------------------------------------------------------------- /test/input/viewof-expression-cell.js: -------------------------------------------------------------------------------- 1 | viewof foo = DOM.input() 2 | -------------------------------------------------------------------------------- /test/input/viewof-in-markdown.md: -------------------------------------------------------------------------------- 1 | # `Code Title ${object[viewof foo]}` 2 | -------------------------------------------------------------------------------- /test/input/viewof-internal-comment.js: -------------------------------------------------------------------------------- 1 | viewof /* comment */ bar = DOM.range() 2 | -------------------------------------------------------------------------------- /test/input/viewof-let.js: -------------------------------------------------------------------------------- 1 | { 2 | let viewof = 2; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/viewof-member-expression.js: -------------------------------------------------------------------------------- 1 | viewof foo.name 2 | -------------------------------------------------------------------------------- /test/input/viewof-member.js: -------------------------------------------------------------------------------- 1 | object.viewof foo + 2 2 | -------------------------------------------------------------------------------- /test/input/viewof-orphan.js: -------------------------------------------------------------------------------- 1 | viewof 42 2 | -------------------------------------------------------------------------------- /test/input/viewof-property.js: -------------------------------------------------------------------------------- 1 | object[viewof foo] + 2 2 | -------------------------------------------------------------------------------- /test/input/viewof-reference-internal-comment.js: -------------------------------------------------------------------------------- 1 | viewof /* comment */ bar 2 | -------------------------------------------------------------------------------- /test/input/viewof-reference.js: -------------------------------------------------------------------------------- 1 | viewof input.tagName 2 | -------------------------------------------------------------------------------- /test/input/yield-await.js: -------------------------------------------------------------------------------- 1 | { 2 | yield value; 3 | await promise; 4 | } 5 | -------------------------------------------------------------------------------- /test/input/yield-block-cell.js: -------------------------------------------------------------------------------- 1 | { 2 | yield value; 3 | } 4 | -------------------------------------------------------------------------------- /test/input/yield-expression-cell.js: -------------------------------------------------------------------------------- 1 | yield value 2 | -------------------------------------------------------------------------------- /test/input/yield-in-function.js: -------------------------------------------------------------------------------- 1 | { 2 | function* inner() { 3 | yield value; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/input/yield-star-expression-cell.js: -------------------------------------------------------------------------------- 1 | yield* values 2 | -------------------------------------------------------------------------------- /test/output/anonymous-block-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 17, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 16, 10 | "body": [ 11 | { 12 | "type": "ReturnStatement", 13 | "start": 4, 14 | "end": 14, 15 | "argument": { 16 | "type": "Literal", 17 | "start": 11, 18 | "end": 13, 19 | "value": 42, 20 | "raw": "42" 21 | } 22 | } 23 | ] 24 | }, 25 | "async": false, 26 | "generator": false, 27 | "references": [], 28 | "fileAttachments": [], 29 | "databaseClients": [], 30 | "secrets": [], 31 | "notificationClients": [] 32 | } -------------------------------------------------------------------------------- /test/output/anonymous-expression-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 3, 5 | "id": null, 6 | "body": { 7 | "type": "Literal", 8 | "start": 0, 9 | "end": 2, 10 | "value": 42, 11 | "raw": "42" 12 | }, 13 | "async": false, 14 | "generator": false, 15 | "references": [], 16 | "fileAttachments": [], 17 | "databaseClients": [], 18 | "secrets": [], 19 | "notificationClients": [] 20 | } -------------------------------------------------------------------------------- /test/output/anonymous-function.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 26, 5 | "id": null, 6 | "body": { 7 | "type": "FunctionExpression", 8 | "start": 0, 9 | "end": 25, 10 | "id": null, 11 | "expression": false, 12 | "generator": false, 13 | "async": false, 14 | "params": [], 15 | "body": { 16 | "type": "BlockStatement", 17 | "start": 11, 18 | "end": 25, 19 | "body": [ 20 | { 21 | "type": "ReturnStatement", 22 | "start": 13, 23 | "end": 23, 24 | "argument": { 25 | "type": "Literal", 26 | "start": 20, 27 | "end": 22, 28 | "value": 42, 29 | "raw": "42" 30 | } 31 | } 32 | ] 33 | } 34 | }, 35 | "async": false, 36 | "generator": false, 37 | "references": [], 38 | "fileAttachments": [], 39 | "databaseClients": [], 40 | "secrets": [], 41 | "notificationClients": [] 42 | } -------------------------------------------------------------------------------- /test/output/arguments-name.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'arguments' is reserved (1:0)", 5 | "pos": 0, 6 | "loc": { 7 | "line": 1, 8 | "column": 0 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/await-block-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 21, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 20, 10 | "body": [ 11 | { 12 | "type": "ExpressionStatement", 13 | "start": 4, 14 | "end": 18, 15 | "expression": { 16 | "type": "AwaitExpression", 17 | "start": 4, 18 | "end": 17, 19 | "argument": { 20 | "type": "Identifier", 21 | "start": 10, 22 | "end": 17, 23 | "name": "promise" 24 | } 25 | } 26 | } 27 | ] 28 | }, 29 | "async": true, 30 | "generator": false, 31 | "references": [ 32 | { 33 | "type": "Identifier", 34 | "start": 10, 35 | "end": 17, 36 | "name": "promise" 37 | } 38 | ], 39 | "fileAttachments": [], 40 | "databaseClients": [], 41 | "secrets": [], 42 | "notificationClients": [] 43 | } -------------------------------------------------------------------------------- /test/output/await-in-arrow-function-expression.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 33, 5 | "id": null, 6 | "body": { 7 | "type": "ArrowFunctionExpression", 8 | "start": 0, 9 | "end": 32, 10 | "id": null, 11 | "expression": false, 12 | "generator": false, 13 | "async": true, 14 | "params": [], 15 | "body": { 16 | "type": "BlockStatement", 17 | "start": 12, 18 | "end": 32, 19 | "body": [ 20 | { 21 | "type": "ExpressionStatement", 22 | "start": 16, 23 | "end": 30, 24 | "expression": { 25 | "type": "AwaitExpression", 26 | "start": 16, 27 | "end": 29, 28 | "argument": { 29 | "type": "Identifier", 30 | "start": 22, 31 | "end": 29, 32 | "name": "promise" 33 | } 34 | } 35 | } 36 | ] 37 | } 38 | }, 39 | "async": false, 40 | "generator": false, 41 | "references": [ 42 | { 43 | "type": "Identifier", 44 | "start": 22, 45 | "end": 29, 46 | "name": "promise" 47 | } 48 | ], 49 | "fileAttachments": [], 50 | "databaseClients": [], 51 | "secrets": [], 52 | "notificationClients": [] 53 | } -------------------------------------------------------------------------------- /test/output/await-in-arrow-function.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 58, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 57, 10 | "body": [ 11 | { 12 | "type": "VariableDeclaration", 13 | "start": 4, 14 | "end": 55, 15 | "declarations": [ 16 | { 17 | "type": "VariableDeclarator", 18 | "start": 10, 19 | "end": 54, 20 | "id": { 21 | "type": "Identifier", 22 | "start": 10, 23 | "end": 15, 24 | "name": "inner" 25 | }, 26 | "init": { 27 | "type": "ArrowFunctionExpression", 28 | "start": 18, 29 | "end": 54, 30 | "id": null, 31 | "expression": false, 32 | "generator": false, 33 | "async": true, 34 | "params": [], 35 | "body": { 36 | "type": "BlockStatement", 37 | "start": 30, 38 | "end": 54, 39 | "body": [ 40 | { 41 | "type": "ExpressionStatement", 42 | "start": 36, 43 | "end": 50, 44 | "expression": { 45 | "type": "AwaitExpression", 46 | "start": 36, 47 | "end": 49, 48 | "argument": { 49 | "type": "Identifier", 50 | "start": 42, 51 | "end": 49, 52 | "name": "promise" 53 | } 54 | } 55 | } 56 | ] 57 | } 58 | } 59 | } 60 | ], 61 | "kind": "const" 62 | } 63 | ] 64 | }, 65 | "async": false, 66 | "generator": false, 67 | "references": [ 68 | { 69 | "type": "Identifier", 70 | "start": 42, 71 | "end": 49, 72 | "name": "promise" 73 | } 74 | ], 75 | "fileAttachments": [], 76 | "databaseClients": [], 77 | "secrets": [], 78 | "notificationClients": [] 79 | } -------------------------------------------------------------------------------- /test/output/await-in-class.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 72, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 71, 10 | "body": [ 11 | { 12 | "type": "ClassDeclaration", 13 | "start": 4, 14 | "end": 69, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 10, 18 | "end": 15, 19 | "name": "Inner" 20 | }, 21 | "superClass": null, 22 | "body": { 23 | "type": "ClassBody", 24 | "start": 16, 25 | "end": 69, 26 | "body": [ 27 | { 28 | "type": "MethodDefinition", 29 | "start": 22, 30 | "end": 65, 31 | "static": false, 32 | "computed": false, 33 | "key": { 34 | "type": "Identifier", 35 | "start": 28, 36 | "end": 34, 37 | "name": "method" 38 | }, 39 | "kind": "method", 40 | "value": { 41 | "type": "FunctionExpression", 42 | "start": 34, 43 | "end": 65, 44 | "id": null, 45 | "expression": false, 46 | "generator": false, 47 | "async": true, 48 | "params": [], 49 | "body": { 50 | "type": "BlockStatement", 51 | "start": 37, 52 | "end": 65, 53 | "body": [ 54 | { 55 | "type": "ExpressionStatement", 56 | "start": 45, 57 | "end": 59, 58 | "expression": { 59 | "type": "AwaitExpression", 60 | "start": 45, 61 | "end": 58, 62 | "argument": { 63 | "type": "Identifier", 64 | "start": 51, 65 | "end": 58, 66 | "name": "promise" 67 | } 68 | } 69 | } 70 | ] 71 | } 72 | } 73 | } 74 | ] 75 | } 76 | } 77 | ] 78 | }, 79 | "async": false, 80 | "generator": false, 81 | "references": [ 82 | { 83 | "type": "Identifier", 84 | "start": 51, 85 | "end": 58, 86 | "name": "promise" 87 | } 88 | ], 89 | "fileAttachments": [], 90 | "databaseClients": [], 91 | "secrets": [], 92 | "notificationClients": [] 93 | } -------------------------------------------------------------------------------- /test/output/await-in-function.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 54, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 53, 10 | "body": [ 11 | { 12 | "type": "FunctionDeclaration", 13 | "start": 4, 14 | "end": 51, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 19, 18 | "end": 24, 19 | "name": "inner" 20 | }, 21 | "expression": false, 22 | "generator": false, 23 | "async": true, 24 | "params": [], 25 | "body": { 26 | "type": "BlockStatement", 27 | "start": 27, 28 | "end": 51, 29 | "body": [ 30 | { 31 | "type": "ExpressionStatement", 32 | "start": 33, 33 | "end": 47, 34 | "expression": { 35 | "type": "AwaitExpression", 36 | "start": 33, 37 | "end": 46, 38 | "argument": { 39 | "type": "Identifier", 40 | "start": 39, 41 | "end": 46, 42 | "name": "promise" 43 | } 44 | } 45 | } 46 | ] 47 | } 48 | } 49 | ] 50 | }, 51 | "async": false, 52 | "generator": false, 53 | "references": [ 54 | { 55 | "type": "Identifier", 56 | "start": 39, 57 | "end": 46, 58 | "name": "promise" 59 | } 60 | ], 61 | "fileAttachments": [], 62 | "databaseClients": [], 63 | "secrets": [], 64 | "notificationClients": [] 65 | } -------------------------------------------------------------------------------- /test/output/await-in-markdown.md.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 30, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 30, 10 | "expressions": [ 11 | { 12 | "type": "AwaitExpression", 13 | "start": 4, 14 | "end": 26, 15 | "argument": { 16 | "type": "CallExpression", 17 | "start": 10, 18 | "end": 26, 19 | "callee": { 20 | "type": "Identifier", 21 | "start": 10, 22 | "end": 24, 23 | "name": "importantValue" 24 | }, 25 | "arguments": [], 26 | "optional": false 27 | } 28 | } 29 | ], 30 | "quasis": [ 31 | { 32 | "type": "TemplateElement", 33 | "start": 0, 34 | "end": 2, 35 | "value": { 36 | "raw": "**", 37 | "cooked": null 38 | }, 39 | "tail": false 40 | }, 41 | { 42 | "type": "TemplateElement", 43 | "start": 27, 44 | "end": 30, 45 | "value": { 46 | "raw": "**\n", 47 | "cooked": null 48 | }, 49 | "tail": true 50 | } 51 | ] 52 | }, 53 | "async": true, 54 | "generator": false, 55 | "tag": { 56 | "type": "CellTag", 57 | "start": 0, 58 | "end": 2, 59 | "body": { 60 | "type": "Identifier", 61 | "start": 0, 62 | "end": 2, 63 | "name": "md" 64 | }, 65 | "input": "md", 66 | "async": false, 67 | "generator": false, 68 | "references": [ 69 | { 70 | "type": "Identifier", 71 | "start": 0, 72 | "end": 2, 73 | "name": "md" 74 | } 75 | ], 76 | "fileAttachments": [], 77 | "databaseClients": [], 78 | "secrets": [], 79 | "notificationClients": [] 80 | }, 81 | "raw": false, 82 | "references": [ 83 | { 84 | "type": "Identifier", 85 | "start": 10, 86 | "end": 24, 87 | "name": "importantValue" 88 | } 89 | ], 90 | "fileAttachments": [], 91 | "databaseClients": [], 92 | "secrets": [], 93 | "notificationClients": [] 94 | } -------------------------------------------------------------------------------- /test/output/await-yield.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 36, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 35, 10 | "body": [ 11 | { 12 | "type": "ExpressionStatement", 13 | "start": 4, 14 | "end": 18, 15 | "expression": { 16 | "type": "AwaitExpression", 17 | "start": 4, 18 | "end": 17, 19 | "argument": { 20 | "type": "Identifier", 21 | "start": 10, 22 | "end": 17, 23 | "name": "promise" 24 | } 25 | } 26 | }, 27 | { 28 | "type": "ExpressionStatement", 29 | "start": 21, 30 | "end": 33, 31 | "expression": { 32 | "type": "YieldExpression", 33 | "start": 21, 34 | "end": 32, 35 | "delegate": false, 36 | "argument": { 37 | "type": "Identifier", 38 | "start": 27, 39 | "end": 32, 40 | "name": "value" 41 | } 42 | } 43 | } 44 | ] 45 | }, 46 | "async": true, 47 | "generator": true, 48 | "references": [ 49 | { 50 | "type": "Identifier", 51 | "start": 10, 52 | "end": 17, 53 | "name": "promise" 54 | }, 55 | { 56 | "type": "Identifier", 57 | "start": 27, 58 | "end": 32, 59 | "name": "value" 60 | } 61 | ], 62 | "fileAttachments": [], 63 | "databaseClients": [], 64 | "secrets": [], 65 | "notificationClients": [] 66 | } -------------------------------------------------------------------------------- /test/output/backslash-after-dollar-markdown.md.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 8, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 8, 10 | "expressions": [], 11 | "quasis": [ 12 | { 13 | "type": "TemplateElement", 14 | "start": 0, 15 | "end": 8, 16 | "value": { 17 | "raw": "$\\{foo}\n", 18 | "cooked": null 19 | }, 20 | "tail": true 21 | } 22 | ] 23 | }, 24 | "async": false, 25 | "generator": false, 26 | "tag": { 27 | "type": "CellTag", 28 | "start": 0, 29 | "end": 2, 30 | "body": { 31 | "type": "Identifier", 32 | "start": 0, 33 | "end": 2, 34 | "name": "md" 35 | }, 36 | "input": "md", 37 | "async": false, 38 | "generator": false, 39 | "references": [ 40 | { 41 | "type": "Identifier", 42 | "start": 0, 43 | "end": 2, 44 | "name": "md" 45 | } 46 | ], 47 | "fileAttachments": [], 48 | "databaseClients": [], 49 | "secrets": [], 50 | "notificationClients": [] 51 | }, 52 | "raw": false, 53 | "references": [], 54 | "fileAttachments": [], 55 | "databaseClients": [], 56 | "secrets": [], 57 | "notificationClients": [] 58 | } -------------------------------------------------------------------------------- /test/output/backslash-before-dollar-markdown.md.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 8, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 8, 10 | "expressions": [], 11 | "quasis": [ 12 | { 13 | "type": "TemplateElement", 14 | "start": 0, 15 | "end": 8, 16 | "value": { 17 | "raw": "\\${foo}\n", 18 | "cooked": null 19 | }, 20 | "tail": true 21 | } 22 | ] 23 | }, 24 | "async": false, 25 | "generator": false, 26 | "tag": { 27 | "type": "CellTag", 28 | "start": 0, 29 | "end": 2, 30 | "body": { 31 | "type": "Identifier", 32 | "start": 0, 33 | "end": 2, 34 | "name": "md" 35 | }, 36 | "input": "md", 37 | "async": false, 38 | "generator": false, 39 | "references": [ 40 | { 41 | "type": "Identifier", 42 | "start": 0, 43 | "end": 2, 44 | "name": "md" 45 | } 46 | ], 47 | "fileAttachments": [], 48 | "databaseClients": [], 49 | "secrets": [], 50 | "notificationClients": [] 51 | }, 52 | "raw": false, 53 | "references": [], 54 | "fileAttachments": [], 55 | "databaseClients": [], 56 | "secrets": [], 57 | "notificationClients": [] 58 | } -------------------------------------------------------------------------------- /test/output/backslash-markdown.md.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 27, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 27, 10 | "expressions": [], 11 | "quasis": [ 12 | { 13 | "type": "TemplateElement", 14 | "start": 0, 15 | "end": 27, 16 | "value": { 17 | "raw": "\\Slash before, slash after\\", 18 | "cooked": null 19 | }, 20 | "tail": true 21 | } 22 | ] 23 | }, 24 | "async": false, 25 | "generator": false, 26 | "tag": { 27 | "type": "CellTag", 28 | "start": 0, 29 | "end": 2, 30 | "body": { 31 | "type": "Identifier", 32 | "start": 0, 33 | "end": 2, 34 | "name": "md" 35 | }, 36 | "input": "md", 37 | "async": false, 38 | "generator": false, 39 | "references": [ 40 | { 41 | "type": "Identifier", 42 | "start": 0, 43 | "end": 2, 44 | "name": "md" 45 | } 46 | ], 47 | "fileAttachments": [], 48 | "databaseClients": [], 49 | "secrets": [], 50 | "notificationClients": [] 51 | }, 52 | "raw": false, 53 | "references": [], 54 | "fileAttachments": [], 55 | "databaseClients": [], 56 | "secrets": [], 57 | "notificationClients": [] 58 | } -------------------------------------------------------------------------------- /test/output/bare-dynamic-import.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 14, 5 | "id": null, 6 | "body": { 7 | "type": "ImportExpression", 8 | "start": 0, 9 | "end": 13, 10 | "source": { 11 | "type": "Literal", 12 | "start": 7, 13 | "end": 12, 14 | "value": "bar", 15 | "raw": "\"bar\"" 16 | } 17 | }, 18 | "async": false, 19 | "generator": false, 20 | "references": [], 21 | "fileAttachments": [], 22 | "databaseClients": [], 23 | "secrets": [], 24 | "notificationClients": [] 25 | } -------------------------------------------------------------------------------- /test/output/basic.db.sql.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 48, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 48, 10 | "expressions": [ 11 | { 12 | "type": "Identifier", 13 | "start": 43, 14 | "end": 46, 15 | "name": "val" 16 | } 17 | ], 18 | "quasis": [ 19 | { 20 | "type": "TemplateElement", 21 | "start": 0, 22 | "end": 41, 23 | "value": { 24 | "raw": "SELECT * FROM my_table WHERE my_column = ", 25 | "cooked": null 26 | }, 27 | "tail": false 28 | }, 29 | { 30 | "type": "TemplateElement", 31 | "start": 47, 32 | "end": 48, 33 | "value": { 34 | "raw": "\n", 35 | "cooked": null 36 | }, 37 | "tail": true 38 | } 39 | ] 40 | }, 41 | "async": false, 42 | "generator": false, 43 | "tag": { 44 | "type": "CellTag", 45 | "start": 0, 46 | "end": 38, 47 | "body": { 48 | "type": "MemberExpression", 49 | "start": 0, 50 | "end": 38, 51 | "object": { 52 | "type": "AwaitExpression", 53 | "start": 1, 54 | "end": 33, 55 | "argument": { 56 | "type": "CallExpression", 57 | "start": 7, 58 | "end": 33, 59 | "callee": { 60 | "type": "Identifier", 61 | "start": 7, 62 | "end": 21, 63 | "name": "DatabaseClient" 64 | }, 65 | "arguments": [ 66 | { 67 | "type": "Literal", 68 | "start": 22, 69 | "end": 32, 70 | "value": "database", 71 | "raw": "\"database\"" 72 | } 73 | ], 74 | "optional": false 75 | } 76 | }, 77 | "property": { 78 | "type": "Identifier", 79 | "start": 35, 80 | "end": 38, 81 | "name": "sql" 82 | }, 83 | "computed": false, 84 | "optional": false 85 | }, 86 | "input": "(await DatabaseClient(\"database\")).sql", 87 | "async": true, 88 | "generator": false, 89 | "references": [ 90 | { 91 | "type": "Identifier", 92 | "start": 7, 93 | "end": 21, 94 | "name": "DatabaseClient" 95 | } 96 | ], 97 | "fileAttachments": [], 98 | "databaseClients": [ 99 | [ 100 | "database", 101 | [ 102 | { 103 | "start": 22, 104 | "end": 32 105 | } 106 | ] 107 | ] 108 | ], 109 | "secrets": [], 110 | "notificationClients": [] 111 | }, 112 | "raw": false, 113 | "references": [ 114 | { 115 | "type": "Identifier", 116 | "start": 43, 117 | "end": 46, 118 | "name": "val" 119 | } 120 | ], 121 | "fileAttachments": [], 122 | "databaseClients": [], 123 | "secrets": [], 124 | "notificationClients": [] 125 | } -------------------------------------------------------------------------------- /test/output/basic.html.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 19, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 19, 10 | "expressions": [ 11 | { 12 | "type": "Identifier", 13 | "start": 7, 14 | "end": 12, 15 | "name": "hello" 16 | } 17 | ], 18 | "quasis": [ 19 | { 20 | "type": "TemplateElement", 21 | "start": 0, 22 | "end": 5, 23 | "value": { 24 | "raw": "
", 25 | "cooked": null 26 | }, 27 | "tail": false 28 | }, 29 | { 30 | "type": "TemplateElement", 31 | "start": 13, 32 | "end": 19, 33 | "value": { 34 | "raw": "
", 35 | "cooked": null 36 | }, 37 | "tail": true 38 | } 39 | ] 40 | }, 41 | "async": false, 42 | "generator": false, 43 | "tag": { 44 | "type": "CellTag", 45 | "start": 0, 46 | "end": 8, 47 | "body": { 48 | "type": "MemberExpression", 49 | "start": 0, 50 | "end": 8, 51 | "object": { 52 | "type": "Identifier", 53 | "start": 0, 54 | "end": 3, 55 | "name": "htl" 56 | }, 57 | "property": { 58 | "type": "Identifier", 59 | "start": 4, 60 | "end": 8, 61 | "name": "html" 62 | }, 63 | "computed": false, 64 | "optional": false 65 | }, 66 | "input": "htl.html", 67 | "async": false, 68 | "generator": false, 69 | "references": [ 70 | { 71 | "type": "Identifier", 72 | "start": 0, 73 | "end": 3, 74 | "name": "htl" 75 | } 76 | ], 77 | "fileAttachments": [], 78 | "databaseClients": [], 79 | "secrets": [], 80 | "notificationClients": [] 81 | }, 82 | "raw": false, 83 | "references": [ 84 | { 85 | "type": "Identifier", 86 | "start": 7, 87 | "end": 12, 88 | "name": "hello" 89 | } 90 | ], 91 | "fileAttachments": [], 92 | "databaseClients": [], 93 | "secrets": [], 94 | "notificationClients": [] 95 | } -------------------------------------------------------------------------------- /test/output/basic.sql.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 47, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 47, 10 | "expressions": [ 11 | { 12 | "type": "Identifier", 13 | "start": 43, 14 | "end": 46, 15 | "name": "val" 16 | } 17 | ], 18 | "quasis": [ 19 | { 20 | "type": "TemplateElement", 21 | "start": 0, 22 | "end": 41, 23 | "value": { 24 | "raw": "SELECT * FROM my_table WHERE my_column = ", 25 | "cooked": null 26 | }, 27 | "tail": false 28 | }, 29 | { 30 | "type": "TemplateElement", 31 | "start": 47, 32 | "end": 47, 33 | "value": { 34 | "raw": "" 35 | }, 36 | "tail": true 37 | } 38 | ] 39 | }, 40 | "async": false, 41 | "generator": false, 42 | "tag": { 43 | "type": "CellTag", 44 | "start": 0, 45 | "end": 6, 46 | "body": { 47 | "type": "MemberExpression", 48 | "start": 0, 49 | "end": 6, 50 | "object": { 51 | "type": "Identifier", 52 | "start": 0, 53 | "end": 2, 54 | "name": "db" 55 | }, 56 | "property": { 57 | "type": "Identifier", 58 | "start": 3, 59 | "end": 6, 60 | "name": "sql" 61 | }, 62 | "computed": false, 63 | "optional": false 64 | }, 65 | "input": "db.sql", 66 | "async": false, 67 | "generator": false, 68 | "references": [ 69 | { 70 | "type": "Identifier", 71 | "start": 0, 72 | "end": 2, 73 | "name": "db" 74 | } 75 | ], 76 | "fileAttachments": [], 77 | "databaseClients": [], 78 | "secrets": [], 79 | "notificationClients": [] 80 | }, 81 | "raw": false, 82 | "references": [ 83 | { 84 | "type": "Identifier", 85 | "start": 43, 86 | "end": 46, 87 | "name": "val" 88 | } 89 | ], 90 | "fileAttachments": [], 91 | "databaseClients": [], 92 | "secrets": [], 93 | "notificationClients": [] 94 | } -------------------------------------------------------------------------------- /test/output/basic.tex.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 33, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 33, 10 | "expressions": [ 11 | { 12 | "type": "Identifier", 13 | "start": 2, 14 | "end": 11, 15 | "name": "numerator" 16 | }, 17 | { 18 | "type": "Identifier", 19 | "start": 21, 20 | "end": 32, 21 | "name": "denominator" 22 | } 23 | ], 24 | "quasis": [ 25 | { 26 | "type": "TemplateElement", 27 | "start": 0, 28 | "end": 0, 29 | "value": { 30 | "raw": "", 31 | "cooked": null 32 | }, 33 | "tail": false 34 | }, 35 | { 36 | "type": "TemplateElement", 37 | "start": 12, 38 | "end": 19, 39 | "value": { 40 | "raw": " \\over ", 41 | "cooked": null 42 | }, 43 | "tail": false 44 | }, 45 | { 46 | "type": "TemplateElement", 47 | "start": 33, 48 | "end": 33, 49 | "value": { 50 | "raw": "" 51 | }, 52 | "tail": true 53 | } 54 | ] 55 | }, 56 | "async": false, 57 | "generator": false, 58 | "tag": { 59 | "type": "CellTag", 60 | "start": 0, 61 | "end": 9, 62 | "body": { 63 | "type": "MemberExpression", 64 | "start": 0, 65 | "end": 9, 66 | "object": { 67 | "type": "Identifier", 68 | "start": 0, 69 | "end": 3, 70 | "name": "tex" 71 | }, 72 | "property": { 73 | "type": "Identifier", 74 | "start": 4, 75 | "end": 9, 76 | "name": "block" 77 | }, 78 | "computed": false, 79 | "optional": false 80 | }, 81 | "input": "tex.block", 82 | "async": false, 83 | "generator": false, 84 | "references": [ 85 | { 86 | "type": "Identifier", 87 | "start": 0, 88 | "end": 3, 89 | "name": "tex" 90 | } 91 | ], 92 | "fileAttachments": [], 93 | "databaseClients": [], 94 | "secrets": [], 95 | "notificationClients": [] 96 | }, 97 | "raw": true, 98 | "references": [ 99 | { 100 | "type": "Identifier", 101 | "start": 2, 102 | "end": 11, 103 | "name": "numerator" 104 | }, 105 | { 106 | "type": "Identifier", 107 | "start": 21, 108 | "end": 32, 109 | "name": "denominator" 110 | } 111 | ], 112 | "fileAttachments": [], 113 | "databaseClients": [], 114 | "secrets": [], 115 | "notificationClients": [] 116 | } -------------------------------------------------------------------------------- /test/output/bigint-zero.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 3, 5 | "id": null, 6 | "body": { 7 | "type": "Literal", 8 | "start": 0, 9 | "end": 2, 10 | "value": "0", 11 | "raw": "0n", 12 | "bigint": "0" 13 | }, 14 | "async": false, 15 | "generator": false, 16 | "references": [], 17 | "fileAttachments": [], 18 | "databaseClients": [], 19 | "secrets": [], 20 | "notificationClients": [] 21 | } -------------------------------------------------------------------------------- /test/output/bigint.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 10, 5 | "id": null, 6 | "body": { 7 | "type": "BinaryExpression", 8 | "start": 0, 9 | "end": 9, 10 | "left": { 11 | "type": "Identifier", 12 | "start": 0, 13 | "end": 3, 14 | "name": "foo" 15 | }, 16 | "operator": "+", 17 | "right": { 18 | "type": "Literal", 19 | "start": 6, 20 | "end": 9, 21 | "value": "42", 22 | "raw": "42n", 23 | "bigint": "42" 24 | } 25 | }, 26 | "async": false, 27 | "generator": false, 28 | "references": [ 29 | { 30 | "type": "Identifier", 31 | "start": 0, 32 | "end": 3, 33 | "name": "foo" 34 | } 35 | ], 36 | "fileAttachments": [], 37 | "databaseClients": [], 38 | "secrets": [], 39 | "notificationClients": [] 40 | } -------------------------------------------------------------------------------- /test/output/binary-expression.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 9, 5 | "id": null, 6 | "body": { 7 | "type": "BinaryExpression", 8 | "start": 0, 9 | "end": 8, 10 | "left": { 11 | "type": "Identifier", 12 | "start": 0, 13 | "end": 3, 14 | "name": "foo" 15 | }, 16 | "operator": "+", 17 | "right": { 18 | "type": "Literal", 19 | "start": 6, 20 | "end": 8, 21 | "value": 42, 22 | "raw": "42" 23 | } 24 | }, 25 | "async": false, 26 | "generator": false, 27 | "references": [ 28 | { 29 | "type": "Identifier", 30 | "start": 0, 31 | "end": 3, 32 | "name": "foo" 33 | } 34 | ], 35 | "fileAttachments": [], 36 | "databaseClients": [], 37 | "secrets": [], 38 | "notificationClients": [] 39 | } -------------------------------------------------------------------------------- /test/output/block-leading-comment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 44, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 21, 8 | "end": 24, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "BlockStatement", 13 | "start": 27, 14 | "end": 43, 15 | "body": [ 16 | { 17 | "type": "ReturnStatement", 18 | "start": 31, 19 | "end": 41, 20 | "argument": { 21 | "type": "Literal", 22 | "start": 38, 23 | "end": 40, 24 | "value": 42, 25 | "raw": "42" 26 | } 27 | } 28 | ] 29 | }, 30 | "async": false, 31 | "generator": false, 32 | "references": [], 33 | "fileAttachments": [], 34 | "databaseClients": [], 35 | "secrets": [], 36 | "notificationClients": [] 37 | } -------------------------------------------------------------------------------- /test/output/block-trailing-comment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 42, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 3, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "BlockStatement", 13 | "start": 6, 14 | "end": 22, 15 | "body": [ 16 | { 17 | "type": "ReturnStatement", 18 | "start": 10, 19 | "end": 20, 20 | "argument": { 21 | "type": "Literal", 22 | "start": 17, 23 | "end": 19, 24 | "value": 42, 25 | "raw": "42" 26 | } 27 | } 28 | ] 29 | }, 30 | "async": false, 31 | "generator": false, 32 | "references": [], 33 | "fileAttachments": [], 34 | "databaseClients": [], 35 | "secrets": [], 36 | "notificationClients": [] 37 | } -------------------------------------------------------------------------------- /test/output/catch-clause.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 86, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 85, 10 | "body": [ 11 | { 12 | "type": "TryStatement", 13 | "start": 4, 14 | "end": 83, 15 | "block": { 16 | "type": "BlockStatement", 17 | "start": 8, 18 | "end": 53, 19 | "body": [ 20 | { 21 | "type": "VariableDeclaration", 22 | "start": 14, 23 | "end": 26, 24 | "declarations": [ 25 | { 26 | "type": "VariableDeclarator", 27 | "start": 18, 28 | "end": 25, 29 | "id": { 30 | "type": "ArrayPattern", 31 | "start": 18, 32 | "end": 21, 33 | "elements": [ 34 | { 35 | "type": "Identifier", 36 | "start": 19, 37 | "end": 20, 38 | "name": "x" 39 | } 40 | ] 41 | }, 42 | "init": { 43 | "type": "Identifier", 44 | "start": 24, 45 | "end": 25, 46 | "name": "y" 47 | } 48 | } 49 | ], 50 | "kind": "let" 51 | }, 52 | { 53 | "type": "ExpressionStatement", 54 | "start": 31, 55 | "end": 35, 56 | "expression": { 57 | "type": "UpdateExpression", 58 | "start": 31, 59 | "end": 34, 60 | "operator": "++", 61 | "prefix": false, 62 | "argument": { 63 | "type": "Identifier", 64 | "start": 31, 65 | "end": 32, 66 | "name": "x" 67 | } 68 | } 69 | }, 70 | { 71 | "type": "ReturnStatement", 72 | "start": 40, 73 | "end": 49, 74 | "argument": { 75 | "type": "Identifier", 76 | "start": 47, 77 | "end": 48, 78 | "name": "x" 79 | } 80 | } 81 | ] 82 | }, 83 | "handler": { 84 | "type": "CatchClause", 85 | "start": 54, 86 | "end": 83, 87 | "param": { 88 | "type": "Identifier", 89 | "start": 61, 90 | "end": 62, 91 | "name": "e" 92 | }, 93 | "body": { 94 | "type": "BlockStatement", 95 | "start": 64, 96 | "end": 83, 97 | "body": [ 98 | { 99 | "type": "ReturnStatement", 100 | "start": 70, 101 | "end": 79, 102 | "argument": { 103 | "type": "Identifier", 104 | "start": 77, 105 | "end": 78, 106 | "name": "e" 107 | } 108 | } 109 | ] 110 | } 111 | }, 112 | "finalizer": null 113 | } 114 | ] 115 | }, 116 | "async": false, 117 | "generator": false, 118 | "references": [ 119 | { 120 | "type": "Identifier", 121 | "start": 24, 122 | "end": 25, 123 | "name": "y" 124 | } 125 | ], 126 | "fileAttachments": [], 127 | "databaseClients": [], 128 | "secrets": [], 129 | "notificationClients": [] 130 | } -------------------------------------------------------------------------------- /test/output/comma-then-comment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected end of input (2:0)", 5 | "pos": 30, 6 | "loc": { 7 | "line": 2, 8 | "column": 0 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/comment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 19, 5 | "id": null, 6 | "body": null, 7 | "async": false, 8 | "generator": false, 9 | "references": [], 10 | "fileAttachments": [], 11 | "databaseClients": [], 12 | "secrets": [], 13 | "notificationClients": [] 14 | } -------------------------------------------------------------------------------- /test/output/computed-property-name.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 28, 5 | "id": null, 6 | "body": { 7 | "type": "ArrowFunctionExpression", 8 | "start": 0, 9 | "end": 27, 10 | "id": null, 11 | "expression": true, 12 | "generator": false, 13 | "async": false, 14 | "params": [ 15 | { 16 | "type": "ObjectPattern", 17 | "start": 1, 18 | "end": 17, 19 | "properties": [ 20 | { 21 | "type": "Property", 22 | "start": 2, 23 | "end": 16, 24 | "method": false, 25 | "shorthand": false, 26 | "computed": true, 27 | "key": { 28 | "type": "Identifier", 29 | "start": 3, 30 | "end": 8, 31 | "name": "field" 32 | }, 33 | "value": { 34 | "type": "Identifier", 35 | "start": 11, 36 | "end": 16, 37 | "name": "value" 38 | }, 39 | "kind": "init" 40 | } 41 | ] 42 | } 43 | ], 44 | "body": { 45 | "type": "Identifier", 46 | "start": 22, 47 | "end": 27, 48 | "name": "value" 49 | } 50 | }, 51 | "async": false, 52 | "generator": false, 53 | "references": [ 54 | { 55 | "type": "Identifier", 56 | "start": 3, 57 | "end": 8, 58 | "name": "field" 59 | } 60 | ], 61 | "fileAttachments": [], 62 | "databaseClients": [], 63 | "secrets": [], 64 | "notificationClients": [] 65 | } -------------------------------------------------------------------------------- /test/output/database-client.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 35, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 34, 10 | "body": [ 11 | { 12 | "type": "VariableDeclaration", 13 | "start": 4, 14 | "end": 32, 15 | "declarations": [ 16 | { 17 | "type": "VariableDeclarator", 18 | "start": 8, 19 | "end": 31, 20 | "id": { 21 | "type": "Identifier", 22 | "start": 8, 23 | "end": 9, 24 | "name": "a" 25 | }, 26 | "init": { 27 | "type": "CallExpression", 28 | "start": 12, 29 | "end": 31, 30 | "callee": { 31 | "type": "Identifier", 32 | "start": 12, 33 | "end": 26, 34 | "name": "DatabaseClient" 35 | }, 36 | "arguments": [ 37 | { 38 | "type": "Literal", 39 | "start": 27, 40 | "end": 30, 41 | "value": "a", 42 | "raw": "\"a\"" 43 | } 44 | ], 45 | "optional": false 46 | } 47 | } 48 | ], 49 | "kind": "let" 50 | } 51 | ] 52 | }, 53 | "async": false, 54 | "generator": false, 55 | "references": [ 56 | { 57 | "type": "Identifier", 58 | "start": 12, 59 | "end": 26, 60 | "name": "DatabaseClient" 61 | } 62 | ], 63 | "fileAttachments": [], 64 | "databaseClients": [ 65 | [ 66 | "a", 67 | [ 68 | { 69 | "start": 27, 70 | "end": 30 71 | } 72 | ] 73 | ] 74 | ], 75 | "secrets": [], 76 | "notificationClients": [] 77 | } -------------------------------------------------------------------------------- /test/output/destructured-array-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Assignment to constant variable md (2:4)", 5 | "pos": 6, 6 | "loc": { 7 | "line": 2, 8 | "column": 4 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/destructured-array-rest-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Assignment to constant variable md (2:9)", 5 | "pos": 11, 6 | "loc": { 7 | "line": 2, 8 | "column": 9 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/destructured-arrow-with-default.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 32, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 3, 9 | "name": "fun" 10 | }, 11 | "body": { 12 | "type": "ArrowFunctionExpression", 13 | "start": 6, 14 | "end": 31, 15 | "id": null, 16 | "expression": false, 17 | "generator": false, 18 | "async": false, 19 | "params": [ 20 | { 21 | "type": "ObjectPattern", 22 | "start": 7, 23 | "end": 24, 24 | "properties": [ 25 | { 26 | "type": "Property", 27 | "start": 8, 28 | "end": 23, 29 | "method": false, 30 | "shorthand": true, 31 | "computed": false, 32 | "key": { 33 | "type": "Identifier", 34 | "start": 8, 35 | "end": 11, 36 | "name": "foo" 37 | }, 38 | "kind": "init", 39 | "value": { 40 | "type": "AssignmentPattern", 41 | "start": 8, 42 | "end": 23, 43 | "left": { 44 | "type": "Identifier", 45 | "start": 8, 46 | "end": 11, 47 | "name": "foo" 48 | }, 49 | "right": { 50 | "type": "Literal", 51 | "start": 14, 52 | "end": 23, 53 | "value": "default", 54 | "raw": "\"default\"" 55 | } 56 | } 57 | } 58 | ] 59 | } 60 | ], 61 | "body": { 62 | "type": "BlockStatement", 63 | "start": 29, 64 | "end": 31, 65 | "body": [] 66 | } 67 | }, 68 | "async": false, 69 | "generator": false, 70 | "references": [], 71 | "fileAttachments": [], 72 | "databaseClients": [], 73 | "secrets": [], 74 | "notificationClients": [] 75 | } -------------------------------------------------------------------------------- /test/output/destructured-assignment-with-default-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Assignment to constant variable md (3:18)", 5 | "pos": 33, 6 | "loc": { 7 | "line": 3, 8 | "column": 18 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/destructured-assignment-with-default.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 45, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 44, 10 | "body": [ 11 | { 12 | "type": "VariableDeclaration", 13 | "start": 4, 14 | "end": 14, 15 | "declarations": [ 16 | { 17 | "type": "VariableDeclarator", 18 | "start": 8, 19 | "end": 13, 20 | "id": { 21 | "type": "Identifier", 22 | "start": 8, 23 | "end": 13, 24 | "name": "value" 25 | }, 26 | "init": null 27 | } 28 | ], 29 | "kind": "let" 30 | }, 31 | { 32 | "type": "ExpressionStatement", 33 | "start": 17, 34 | "end": 42, 35 | "expression": { 36 | "type": "AssignmentExpression", 37 | "start": 18, 38 | "end": 40, 39 | "operator": "=", 40 | "left": { 41 | "type": "ObjectPattern", 42 | "start": 18, 43 | "end": 35, 44 | "properties": [ 45 | { 46 | "type": "Property", 47 | "start": 19, 48 | "end": 34, 49 | "method": false, 50 | "shorthand": false, 51 | "computed": false, 52 | "key": { 53 | "type": "Identifier", 54 | "start": 19, 55 | "end": 22, 56 | "name": "foo" 57 | }, 58 | "value": { 59 | "type": "AssignmentPattern", 60 | "start": 24, 61 | "end": 34, 62 | "left": { 63 | "type": "Identifier", 64 | "start": 24, 65 | "end": 29, 66 | "name": "value" 67 | }, 68 | "right": { 69 | "type": "Identifier", 70 | "start": 32, 71 | "end": 34, 72 | "name": "md" 73 | } 74 | }, 75 | "kind": "init" 76 | } 77 | ] 78 | }, 79 | "right": { 80 | "type": "ObjectExpression", 81 | "start": 38, 82 | "end": 40, 83 | "properties": [] 84 | } 85 | } 86 | } 87 | ] 88 | }, 89 | "async": false, 90 | "generator": false, 91 | "references": [ 92 | { 93 | "type": "Identifier", 94 | "start": 32, 95 | "end": 34, 96 | "name": "md" 97 | } 98 | ], 99 | "fileAttachments": [], 100 | "databaseClients": [], 101 | "secrets": [], 102 | "notificationClients": [] 103 | } -------------------------------------------------------------------------------- /test/output/destructured-object-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Assignment to constant variable md (2:4)", 5 | "pos": 6, 6 | "loc": { 7 | "line": 2, 8 | "column": 4 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/destructured-object-rest-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Assignment to constant variable md (2:7)", 5 | "pos": 9, 6 | "loc": { 7 | "line": 2, 8 | "column": 7 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/destructured-object-with-default.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 35, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 9, 8 | "end": 12, 9 | "name": "fun" 10 | }, 11 | "body": { 12 | "type": "FunctionExpression", 13 | "start": 0, 14 | "end": 34, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 9, 18 | "end": 12, 19 | "name": "fun" 20 | }, 21 | "expression": false, 22 | "generator": false, 23 | "async": false, 24 | "params": [ 25 | { 26 | "type": "ObjectPattern", 27 | "start": 13, 28 | "end": 30, 29 | "properties": [ 30 | { 31 | "type": "Property", 32 | "start": 14, 33 | "end": 29, 34 | "method": false, 35 | "shorthand": true, 36 | "computed": false, 37 | "key": { 38 | "type": "Identifier", 39 | "start": 14, 40 | "end": 17, 41 | "name": "foo" 42 | }, 43 | "kind": "init", 44 | "value": { 45 | "type": "AssignmentPattern", 46 | "start": 14, 47 | "end": 29, 48 | "left": { 49 | "type": "Identifier", 50 | "start": 14, 51 | "end": 17, 52 | "name": "foo" 53 | }, 54 | "right": { 55 | "type": "Literal", 56 | "start": 20, 57 | "end": 29, 58 | "value": "default", 59 | "raw": "\"default\"" 60 | } 61 | } 62 | } 63 | ] 64 | } 65 | ], 66 | "body": { 67 | "type": "BlockStatement", 68 | "start": 32, 69 | "end": 34, 70 | "body": [] 71 | } 72 | }, 73 | "async": false, 74 | "generator": false, 75 | "references": [], 76 | "fileAttachments": [], 77 | "databaseClients": [], 78 | "secrets": [], 79 | "notificationClients": [] 80 | } -------------------------------------------------------------------------------- /test/output/dynamic-import.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 20, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 3, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "ImportExpression", 13 | "start": 6, 14 | "end": 19, 15 | "source": { 16 | "type": "Literal", 17 | "start": 13, 18 | "end": 18, 19 | "value": "bar", 20 | "raw": "\"bar\"" 21 | } 22 | }, 23 | "async": false, 24 | "generator": false, 25 | "references": [], 26 | "fileAttachments": [], 27 | "databaseClients": [], 28 | "secrets": [], 29 | "notificationClients": [] 30 | } -------------------------------------------------------------------------------- /test/output/empty.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 0, 5 | "id": null, 6 | "body": null, 7 | "async": false, 8 | "generator": false, 9 | "references": [], 10 | "fileAttachments": [], 11 | "databaseClients": [], 12 | "secrets": [], 13 | "notificationClients": [] 14 | } -------------------------------------------------------------------------------- /test/output/empty.md.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 0, 5 | "id": null, 6 | "body": null, 7 | "async": false, 8 | "generator": false, 9 | "references": [], 10 | "fileAttachments": [], 11 | "databaseClients": [], 12 | "secrets": [], 13 | "notificationClients": [] 14 | } -------------------------------------------------------------------------------- /test/output/expression-extra.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:4)", 5 | "pos": 4, 6 | "loc": { 7 | "line": 1, 8 | "column": 4 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/expression-trailing-comment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 28, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 3, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "Literal", 13 | "start": 6, 14 | "end": 8, 15 | "value": 42, 16 | "raw": "42" 17 | }, 18 | "async": false, 19 | "generator": false, 20 | "references": [], 21 | "fileAttachments": [], 22 | "databaseClients": [], 23 | "secrets": [], 24 | "notificationClients": [] 25 | } -------------------------------------------------------------------------------- /test/output/extra-semicolon.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 10, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 3, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "Literal", 13 | "start": 6, 14 | "end": 8, 15 | "value": 42, 16 | "raw": "42" 17 | }, 18 | "async": false, 19 | "generator": false, 20 | "references": [], 21 | "fileAttachments": [], 22 | "databaseClients": [], 23 | "secrets": [], 24 | "notificationClients": [] 25 | } -------------------------------------------------------------------------------- /test/output/file-attachment-forbidden-1.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "FileAttachment requires a single literal string argument (1:4)", 5 | "pos": 4, 6 | "loc": { 7 | "line": 1, 8 | "column": 4 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/file-attachment-forbidden.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "FileAttachment requires a single literal string argument (1:4)", 5 | "pos": 4, 6 | "loc": { 7 | "line": 1, 8 | "column": 4 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/file-attachment-masked.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 75, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 74, 10 | "body": [ 11 | { 12 | "type": "VariableDeclaration", 13 | "start": 4, 14 | "end": 41, 15 | "declarations": [ 16 | { 17 | "type": "VariableDeclarator", 18 | "start": 8, 19 | "end": 40, 20 | "id": { 21 | "type": "Identifier", 22 | "start": 8, 23 | "end": 22, 24 | "name": "FileAttachment" 25 | }, 26 | "init": { 27 | "type": "ArrowFunctionExpression", 28 | "start": 25, 29 | "end": 40, 30 | "id": null, 31 | "expression": true, 32 | "generator": false, 33 | "async": false, 34 | "params": [ 35 | { 36 | "type": "Identifier", 37 | "start": 26, 38 | "end": 27, 39 | "name": "a" 40 | }, 41 | { 42 | "type": "Identifier", 43 | "start": 29, 44 | "end": 30, 45 | "name": "b" 46 | } 47 | ], 48 | "body": { 49 | "type": "BinaryExpression", 50 | "start": 35, 51 | "end": 40, 52 | "left": { 53 | "type": "Identifier", 54 | "start": 35, 55 | "end": 36, 56 | "name": "a" 57 | }, 58 | "operator": "+", 59 | "right": { 60 | "type": "Identifier", 61 | "start": 39, 62 | "end": 40, 63 | "name": "b" 64 | } 65 | } 66 | } 67 | } 68 | ], 69 | "kind": "let" 70 | }, 71 | { 72 | "type": "ReturnStatement", 73 | "start": 44, 74 | "end": 72, 75 | "argument": { 76 | "type": "CallExpression", 77 | "start": 51, 78 | "end": 71, 79 | "callee": { 80 | "type": "Identifier", 81 | "start": 51, 82 | "end": 65, 83 | "name": "FileAttachment" 84 | }, 85 | "arguments": [ 86 | { 87 | "type": "Literal", 88 | "start": 66, 89 | "end": 67, 90 | "value": 1, 91 | "raw": "1" 92 | }, 93 | { 94 | "type": "Literal", 95 | "start": 69, 96 | "end": 70, 97 | "value": 2, 98 | "raw": "2" 99 | } 100 | ], 101 | "optional": false 102 | } 103 | } 104 | ] 105 | }, 106 | "async": false, 107 | "generator": false, 108 | "references": [], 109 | "fileAttachments": [], 110 | "databaseClients": [], 111 | "secrets": [], 112 | "notificationClients": [] 113 | } -------------------------------------------------------------------------------- /test/output/for-await-generator.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 62, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 61, 10 | "body": [ 11 | { 12 | "type": "ForOfStatement", 13 | "start": 4, 14 | "end": 59, 15 | "await": true, 16 | "left": { 17 | "type": "VariableDeclaration", 18 | "start": 15, 19 | "end": 26, 20 | "declarations": [ 21 | { 22 | "type": "VariableDeclarator", 23 | "start": 21, 24 | "end": 26, 25 | "id": { 26 | "type": "Identifier", 27 | "start": 21, 28 | "end": 26, 29 | "name": "value" 30 | }, 31 | "init": null 32 | } 33 | ], 34 | "kind": "const" 35 | }, 36 | "right": { 37 | "type": "CallExpression", 38 | "start": 30, 39 | "end": 35, 40 | "callee": { 41 | "type": "Identifier", 42 | "start": 30, 43 | "end": 33, 44 | "name": "foo" 45 | }, 46 | "arguments": [], 47 | "optional": false 48 | }, 49 | "body": { 50 | "type": "BlockStatement", 51 | "start": 37, 52 | "end": 59, 53 | "body": [ 54 | { 55 | "type": "ExpressionStatement", 56 | "start": 43, 57 | "end": 55, 58 | "expression": { 59 | "type": "YieldExpression", 60 | "start": 43, 61 | "end": 54, 62 | "delegate": false, 63 | "argument": { 64 | "type": "Identifier", 65 | "start": 49, 66 | "end": 54, 67 | "name": "value" 68 | } 69 | } 70 | } 71 | ] 72 | } 73 | } 74 | ] 75 | }, 76 | "async": true, 77 | "generator": true, 78 | "references": [ 79 | { 80 | "type": "Identifier", 81 | "start": 30, 82 | "end": 33, 83 | "name": "foo" 84 | } 85 | ], 86 | "fileAttachments": [], 87 | "databaseClients": [], 88 | "secrets": [], 89 | "notificationClients": [] 90 | } -------------------------------------------------------------------------------- /test/output/function-unexpected-viewof.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'viewof' (1:9)", 5 | "pos": 9, 6 | "loc": { 7 | "line": 1, 8 | "column": 9 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/global-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Assignment to constant variable foo (2:2)", 5 | "pos": 4, 6 | "loc": { 7 | "line": 2, 8 | "column": 2 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/illegal-arguments.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "arguments is not allowed (1:4)", 5 | "pos": 4, 6 | "loc": { 7 | "line": 1, 8 | "column": 4 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/illegal-arrow-arguments.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "arguments is not allowed (1:6)", 5 | "pos": 6, 6 | "loc": { 7 | "line": 1, 8 | "column": 6 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-as-duplicate.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'foo' has already been declared (1:20)", 5 | "pos": 20, 6 | "loc": { 7 | "line": 1, 8 | "column": 20 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-default-as.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'default' (1:8)", 5 | "pos": 8, 6 | "loc": { 7 | "line": 1, 8 | "column": 8 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-default.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:7)", 5 | "pos": 7, 6 | "loc": { 7 | "line": 1, 8 | "column": 7 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-duplicate.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'foo' has already been declared (1:13)", 5 | "pos": 13, 6 | "loc": { 7 | "line": 1, 8 | "column": 13 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-empty.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 24, 5 | "id": null, 6 | "body": { 7 | "type": "ImportDeclaration", 8 | "start": 0, 9 | "end": 23, 10 | "specifiers": [], 11 | "source": { 12 | "type": "Literal", 13 | "start": 15, 14 | "end": 23, 15 | "value": "module", 16 | "raw": "\"module\"" 17 | } 18 | }, 19 | "async": false, 20 | "generator": false, 21 | "references": [], 22 | "fileAttachments": [], 23 | "databaseClients": [], 24 | "secrets": [], 25 | "notificationClients": [] 26 | } -------------------------------------------------------------------------------- /test/output/import-extra.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:39)", 5 | "pos": 39, 6 | "loc": { 7 | "line": 1, 8 | "column": 39 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-mutable-as.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 42, 5 | "id": null, 6 | "body": { 7 | "type": "ImportDeclaration", 8 | "start": 0, 9 | "end": 41, 10 | "specifiers": [ 11 | { 12 | "type": "ImportSpecifier", 13 | "start": 8, 14 | "end": 26, 15 | "view": false, 16 | "mutable": true, 17 | "imported": { 18 | "type": "Identifier", 19 | "start": 16, 20 | "end": 19, 21 | "name": "foo" 22 | }, 23 | "local": { 24 | "type": "Identifier", 25 | "start": 23, 26 | "end": 26, 27 | "name": "bar" 28 | } 29 | } 30 | ], 31 | "source": { 32 | "type": "Literal", 33 | "start": 33, 34 | "end": 41, 35 | "value": "module", 36 | "raw": "\"module\"" 37 | } 38 | }, 39 | "async": false, 40 | "generator": false, 41 | "references": [], 42 | "fileAttachments": [], 43 | "databaseClients": [], 44 | "secrets": [], 45 | "notificationClients": [] 46 | } -------------------------------------------------------------------------------- /test/output/import-mutable.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 35, 5 | "id": null, 6 | "body": { 7 | "type": "ImportDeclaration", 8 | "start": 0, 9 | "end": 34, 10 | "specifiers": [ 11 | { 12 | "type": "ImportSpecifier", 13 | "start": 8, 14 | "end": 19, 15 | "view": false, 16 | "mutable": true, 17 | "imported": { 18 | "type": "Identifier", 19 | "start": 16, 20 | "end": 19, 21 | "name": "foo" 22 | }, 23 | "local": { 24 | "type": "Identifier", 25 | "start": 16, 26 | "end": 19, 27 | "name": "foo" 28 | } 29 | } 30 | ], 31 | "source": { 32 | "type": "Literal", 33 | "start": 26, 34 | "end": 34, 35 | "value": "module", 36 | "raw": "\"module\"" 37 | } 38 | }, 39 | "async": false, 40 | "generator": false, 41 | "references": [], 42 | "fileAttachments": [], 43 | "databaseClients": [], 44 | "secrets": [], 45 | "notificationClients": [] 46 | } -------------------------------------------------------------------------------- /test/output/import-semicolon.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 40, 5 | "id": null, 6 | "body": { 7 | "type": "ImportDeclaration", 8 | "start": 0, 9 | "end": 38, 10 | "specifiers": [ 11 | { 12 | "type": "ImportSpecifier", 13 | "start": 8, 14 | "end": 11, 15 | "view": false, 16 | "mutable": false, 17 | "imported": { 18 | "type": "Identifier", 19 | "start": 8, 20 | "end": 11, 21 | "name": "foo" 22 | }, 23 | "local": { 24 | "type": "Identifier", 25 | "start": 8, 26 | "end": 11, 27 | "name": "foo" 28 | } 29 | }, 30 | { 31 | "type": "ImportSpecifier", 32 | "start": 13, 33 | "end": 23, 34 | "view": false, 35 | "mutable": false, 36 | "imported": { 37 | "type": "Identifier", 38 | "start": 13, 39 | "end": 16, 40 | "name": "bar" 41 | }, 42 | "local": { 43 | "type": "Identifier", 44 | "start": 20, 45 | "end": 23, 46 | "name": "baz" 47 | } 48 | } 49 | ], 50 | "source": { 51 | "type": "Literal", 52 | "start": 30, 53 | "end": 38, 54 | "value": "module", 55 | "raw": "\"module\"" 56 | } 57 | }, 58 | "async": false, 59 | "generator": false, 60 | "references": [], 61 | "fileAttachments": [], 62 | "databaseClients": [], 63 | "secrets": [], 64 | "notificationClients": [] 65 | } -------------------------------------------------------------------------------- /test/output/import-side-effect.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:7)", 5 | "pos": 7, 6 | "loc": { 7 | "line": 1, 8 | "column": 7 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-viewof-as.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 41, 5 | "id": null, 6 | "body": { 7 | "type": "ImportDeclaration", 8 | "start": 0, 9 | "end": 40, 10 | "specifiers": [ 11 | { 12 | "type": "ImportSpecifier", 13 | "start": 8, 14 | "end": 25, 15 | "view": true, 16 | "mutable": false, 17 | "imported": { 18 | "type": "Identifier", 19 | "start": 15, 20 | "end": 18, 21 | "name": "foo" 22 | }, 23 | "local": { 24 | "type": "Identifier", 25 | "start": 22, 26 | "end": 25, 27 | "name": "bar" 28 | } 29 | } 30 | ], 31 | "source": { 32 | "type": "Literal", 33 | "start": 32, 34 | "end": 40, 35 | "value": "module", 36 | "raw": "\"module\"" 37 | } 38 | }, 39 | "async": false, 40 | "generator": false, 41 | "references": [], 42 | "fileAttachments": [], 43 | "databaseClients": [], 44 | "secrets": [], 45 | "notificationClients": [] 46 | } -------------------------------------------------------------------------------- /test/output/import-viewof.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 34, 5 | "id": null, 6 | "body": { 7 | "type": "ImportDeclaration", 8 | "start": 0, 9 | "end": 33, 10 | "specifiers": [ 11 | { 12 | "type": "ImportSpecifier", 13 | "start": 8, 14 | "end": 18, 15 | "view": true, 16 | "mutable": false, 17 | "imported": { 18 | "type": "Identifier", 19 | "start": 15, 20 | "end": 18, 21 | "name": "foo" 22 | }, 23 | "local": { 24 | "type": "Identifier", 25 | "start": 15, 26 | "end": 18, 27 | "name": "foo" 28 | } 29 | } 30 | ], 31 | "source": { 32 | "type": "Literal", 33 | "start": 25, 34 | "end": 33, 35 | "value": "module", 36 | "raw": "\"module\"" 37 | } 38 | }, 39 | "async": false, 40 | "generator": false, 41 | "references": [], 42 | "fileAttachments": [], 43 | "databaseClients": [], 44 | "secrets": [], 45 | "notificationClients": [] 46 | } -------------------------------------------------------------------------------- /test/output/import-with-as-duplicate.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'foo' has already been declared (1:28)", 5 | "pos": 28, 6 | "loc": { 7 | "line": 1, 8 | "column": 28 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-with-default-as.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'default' (1:26)", 5 | "pos": 26, 6 | "loc": { 7 | "line": 1, 8 | "column": 26 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-with-default.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'default' (1:19)", 5 | "pos": 19, 6 | "loc": { 7 | "line": 1, 8 | "column": 19 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-with-duplicate.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'foo' has already been declared (1:21)", 5 | "pos": 21, 6 | "loc": { 7 | "line": 1, 8 | "column": 21 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/import-with-empty.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 35, 5 | "id": null, 6 | "body": { 7 | "type": "ImportDeclaration", 8 | "start": 0, 9 | "end": 34, 10 | "specifiers": [ 11 | { 12 | "type": "ImportSpecifier", 13 | "start": 8, 14 | "end": 11, 15 | "view": false, 16 | "mutable": false, 17 | "imported": { 18 | "type": "Identifier", 19 | "start": 8, 20 | "end": 11, 21 | "name": "foo" 22 | }, 23 | "local": { 24 | "type": "Identifier", 25 | "start": 8, 26 | "end": 11, 27 | "name": "foo" 28 | } 29 | } 30 | ], 31 | "injections": [], 32 | "source": { 33 | "type": "Literal", 34 | "start": 26, 35 | "end": 34, 36 | "value": "module", 37 | "raw": "\"module\"" 38 | } 39 | }, 40 | "async": false, 41 | "generator": false, 42 | "references": [], 43 | "fileAttachments": [], 44 | "databaseClients": [], 45 | "secrets": [], 46 | "notificationClients": [] 47 | } -------------------------------------------------------------------------------- /test/output/import-with.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 45, 5 | "id": null, 6 | "body": { 7 | "type": "ImportDeclaration", 8 | "start": 0, 9 | "end": 44, 10 | "specifiers": [ 11 | { 12 | "type": "ImportSpecifier", 13 | "start": 8, 14 | "end": 11, 15 | "view": false, 16 | "mutable": false, 17 | "imported": { 18 | "type": "Identifier", 19 | "start": 8, 20 | "end": 11, 21 | "name": "foo" 22 | }, 23 | "local": { 24 | "type": "Identifier", 25 | "start": 8, 26 | "end": 11, 27 | "name": "foo" 28 | } 29 | } 30 | ], 31 | "injections": [ 32 | { 33 | "type": "ImportSpecifier", 34 | "start": 19, 35 | "end": 29, 36 | "view": false, 37 | "mutable": false, 38 | "imported": { 39 | "type": "Identifier", 40 | "start": 19, 41 | "end": 22, 42 | "name": "bar" 43 | }, 44 | "local": { 45 | "type": "Identifier", 46 | "start": 26, 47 | "end": 29, 48 | "name": "baz" 49 | } 50 | } 51 | ], 52 | "source": { 53 | "type": "Literal", 54 | "start": 36, 55 | "end": 44, 56 | "value": "module", 57 | "raw": "\"module\"" 58 | } 59 | }, 60 | "async": false, 61 | "generator": false, 62 | "references": [ 63 | { 64 | "type": "Identifier", 65 | "start": 19, 66 | "end": 22, 67 | "name": "bar" 68 | } 69 | ], 70 | "fileAttachments": [], 71 | "databaseClients": [], 72 | "secrets": [], 73 | "notificationClients": [] 74 | } -------------------------------------------------------------------------------- /test/output/import.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 39, 5 | "id": null, 6 | "body": { 7 | "type": "ImportDeclaration", 8 | "start": 0, 9 | "end": 38, 10 | "specifiers": [ 11 | { 12 | "type": "ImportSpecifier", 13 | "start": 8, 14 | "end": 11, 15 | "view": false, 16 | "mutable": false, 17 | "imported": { 18 | "type": "Identifier", 19 | "start": 8, 20 | "end": 11, 21 | "name": "foo" 22 | }, 23 | "local": { 24 | "type": "Identifier", 25 | "start": 8, 26 | "end": 11, 27 | "name": "foo" 28 | } 29 | }, 30 | { 31 | "type": "ImportSpecifier", 32 | "start": 13, 33 | "end": 23, 34 | "view": false, 35 | "mutable": false, 36 | "imported": { 37 | "type": "Identifier", 38 | "start": 13, 39 | "end": 16, 40 | "name": "bar" 41 | }, 42 | "local": { 43 | "type": "Identifier", 44 | "start": 20, 45 | "end": 23, 46 | "name": "baz" 47 | } 48 | } 49 | ], 50 | "source": { 51 | "type": "Literal", 52 | "start": 30, 53 | "end": 38, 54 | "value": "module", 55 | "raw": "\"module\"" 56 | } 57 | }, 58 | "async": false, 59 | "generator": false, 60 | "references": [], 61 | "fileAttachments": [], 62 | "databaseClients": [], 63 | "secrets": [], 64 | "notificationClients": [] 65 | } -------------------------------------------------------------------------------- /test/output/leading-semicolon.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:1)", 5 | "pos": 1, 6 | "loc": { 7 | "line": 1, 8 | "column": 1 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/legal-arguments.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 40, 5 | "id": null, 6 | "body": { 7 | "type": "FunctionExpression", 8 | "start": 0, 9 | "end": 39, 10 | "id": null, 11 | "expression": false, 12 | "generator": false, 13 | "async": false, 14 | "params": [], 15 | "body": { 16 | "type": "BlockStatement", 17 | "start": 11, 18 | "end": 39, 19 | "body": [ 20 | { 21 | "type": "ReturnStatement", 22 | "start": 13, 23 | "end": 37, 24 | "argument": { 25 | "type": "MemberExpression", 26 | "start": 20, 27 | "end": 36, 28 | "object": { 29 | "type": "Identifier", 30 | "start": 20, 31 | "end": 29, 32 | "name": "arguments" 33 | }, 34 | "property": { 35 | "type": "Identifier", 36 | "start": 30, 37 | "end": 36, 38 | "name": "length" 39 | }, 40 | "computed": false, 41 | "optional": false 42 | } 43 | } 44 | ] 45 | } 46 | }, 47 | "async": false, 48 | "generator": false, 49 | "references": [], 50 | "fileAttachments": [], 51 | "databaseClients": [], 52 | "secrets": [], 53 | "notificationClients": [] 54 | } -------------------------------------------------------------------------------- /test/output/logical-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 60, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 59, 10 | "body": [ 11 | { 12 | "type": "VariableDeclaration", 13 | "start": 4, 14 | "end": 17, 15 | "declarations": [ 16 | { 17 | "type": "VariableDeclarator", 18 | "start": 8, 19 | "end": 16, 20 | "id": { 21 | "type": "Identifier", 22 | "start": 8, 23 | "end": 9, 24 | "name": "a" 25 | }, 26 | "init": { 27 | "type": "Literal", 28 | "start": 12, 29 | "end": 16, 30 | "value": null, 31 | "raw": "null" 32 | } 33 | } 34 | ], 35 | "kind": "let" 36 | }, 37 | { 38 | "type": "VariableDeclaration", 39 | "start": 20, 40 | "end": 34, 41 | "declarations": [ 42 | { 43 | "type": "VariableDeclarator", 44 | "start": 24, 45 | "end": 33, 46 | "id": { 47 | "type": "Identifier", 48 | "start": 24, 49 | "end": 25, 50 | "name": "b" 51 | }, 52 | "init": { 53 | "type": "Literal", 54 | "start": 28, 55 | "end": 33, 56 | "value": false, 57 | "raw": "false" 58 | } 59 | } 60 | ], 61 | "kind": "let" 62 | }, 63 | { 64 | "type": "ExpressionStatement", 65 | "start": 37, 66 | "end": 45, 67 | "expression": { 68 | "type": "AssignmentExpression", 69 | "start": 37, 70 | "end": 44, 71 | "operator": "||=", 72 | "left": { 73 | "type": "Identifier", 74 | "start": 37, 75 | "end": 38, 76 | "name": "a" 77 | }, 78 | "right": { 79 | "type": "Identifier", 80 | "start": 43, 81 | "end": 44, 82 | "name": "b" 83 | } 84 | } 85 | }, 86 | { 87 | "type": "ReturnStatement", 88 | "start": 48, 89 | "end": 57, 90 | "argument": { 91 | "type": "Identifier", 92 | "start": 55, 93 | "end": 56, 94 | "name": "a" 95 | } 96 | } 97 | ] 98 | }, 99 | "async": false, 100 | "generator": false, 101 | "references": [], 102 | "fileAttachments": [], 103 | "databaseClients": [], 104 | "secrets": [], 105 | "notificationClients": [] 106 | } -------------------------------------------------------------------------------- /test/output/markdown-interpolation.md.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 70, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 70, 10 | "expressions": [ 11 | { 12 | "type": "UpdateExpression", 13 | "start": 9, 14 | "end": 24, 15 | "operator": "++", 16 | "prefix": true, 17 | "argument": { 18 | "type": "MutableExpression", 19 | "start": 11, 20 | "end": 24, 21 | "id": { 22 | "type": "Identifier", 23 | "start": 19, 24 | "end": 24, 25 | "name": "count" 26 | } 27 | } 28 | }, 29 | { 30 | "type": "ViewExpression", 31 | "start": 34, 32 | "end": 44, 33 | "id": { 34 | "type": "Identifier", 35 | "start": 41, 36 | "end": 44, 37 | "name": "Foo" 38 | } 39 | }, 40 | { 41 | "type": "Identifier", 42 | "start": 63, 43 | "end": 68, 44 | "name": "value" 45 | } 46 | ], 47 | "quasis": [ 48 | { 49 | "type": "TemplateElement", 50 | "start": 0, 51 | "end": 7, 52 | "value": { 53 | "raw": "Count: ", 54 | "cooked": null 55 | }, 56 | "tail": false 57 | }, 58 | { 59 | "type": "TemplateElement", 60 | "start": 25, 61 | "end": 32, 62 | "value": { 63 | "raw": "\nView: ", 64 | "cooked": null 65 | }, 66 | "tail": false 67 | }, 68 | { 69 | "type": "TemplateElement", 70 | "start": 45, 71 | "end": 61, 72 | "value": { 73 | "raw": "\nRegular Value: ", 74 | "cooked": null 75 | }, 76 | "tail": false 77 | }, 78 | { 79 | "type": "TemplateElement", 80 | "start": 69, 81 | "end": 70, 82 | "value": { 83 | "raw": "\n", 84 | "cooked": null 85 | }, 86 | "tail": true 87 | } 88 | ] 89 | }, 90 | "async": false, 91 | "generator": false, 92 | "tag": { 93 | "type": "CellTag", 94 | "start": 0, 95 | "end": 2, 96 | "body": { 97 | "type": "Identifier", 98 | "start": 0, 99 | "end": 2, 100 | "name": "md" 101 | }, 102 | "input": "md", 103 | "async": false, 104 | "generator": false, 105 | "references": [ 106 | { 107 | "type": "Identifier", 108 | "start": 0, 109 | "end": 2, 110 | "name": "md" 111 | } 112 | ], 113 | "fileAttachments": [], 114 | "databaseClients": [], 115 | "secrets": [], 116 | "notificationClients": [] 117 | }, 118 | "raw": false, 119 | "references": [ 120 | { 121 | "type": "MutableExpression", 122 | "start": 11, 123 | "end": 24, 124 | "id": { 125 | "type": "Identifier", 126 | "start": 19, 127 | "end": 24, 128 | "name": "count" 129 | } 130 | }, 131 | { 132 | "type": "ViewExpression", 133 | "start": 34, 134 | "end": 44, 135 | "id": { 136 | "type": "Identifier", 137 | "start": 41, 138 | "end": 44, 139 | "name": "Foo" 140 | } 141 | }, 142 | { 143 | "type": "Identifier", 144 | "start": 63, 145 | "end": 68, 146 | "name": "value" 147 | } 148 | ], 149 | "fileAttachments": [], 150 | "databaseClients": [], 151 | "secrets": [], 152 | "notificationClients": [] 153 | } -------------------------------------------------------------------------------- /test/output/markdown.md.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 104, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 104, 10 | "expressions": [ 11 | { 12 | "type": "Identifier", 13 | "start": 98, 14 | "end": 101, 15 | "name": "foo" 16 | } 17 | ], 18 | "quasis": [ 19 | { 20 | "type": "TemplateElement", 21 | "start": 0, 22 | "end": 96, 23 | "value": { 24 | "raw": "# Header 1\n\n```\nconst codeBlock = true;\n```\n\nParagraph that references `codeBlock`. Foo value: \"", 25 | "cooked": null 26 | }, 27 | "tail": false 28 | }, 29 | { 30 | "type": "TemplateElement", 31 | "start": 102, 32 | "end": 104, 33 | "value": { 34 | "raw": "\".", 35 | "cooked": null 36 | }, 37 | "tail": true 38 | } 39 | ] 40 | }, 41 | "async": false, 42 | "generator": false, 43 | "tag": { 44 | "type": "CellTag", 45 | "start": 0, 46 | "end": 2, 47 | "body": { 48 | "type": "Identifier", 49 | "start": 0, 50 | "end": 2, 51 | "name": "md" 52 | }, 53 | "input": "md", 54 | "async": false, 55 | "generator": false, 56 | "references": [ 57 | { 58 | "type": "Identifier", 59 | "start": 0, 60 | "end": 2, 61 | "name": "md" 62 | } 63 | ], 64 | "fileAttachments": [], 65 | "databaseClients": [], 66 | "secrets": [], 67 | "notificationClients": [] 68 | }, 69 | "raw": false, 70 | "references": [ 71 | { 72 | "type": "Identifier", 73 | "start": 98, 74 | "end": 101, 75 | "name": "foo" 76 | } 77 | ], 78 | "fileAttachments": [], 79 | "databaseClients": [], 80 | "secrets": [], 81 | "notificationClients": [] 82 | } -------------------------------------------------------------------------------- /test/output/member-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 15, 5 | "id": null, 6 | "body": { 7 | "type": "AssignmentExpression", 8 | "start": 0, 9 | "end": 14, 10 | "operator": "=", 11 | "left": { 12 | "type": "MemberExpression", 13 | "start": 0, 14 | "end": 10, 15 | "object": { 16 | "type": "Identifier", 17 | "start": 0, 18 | "end": 6, 19 | "name": "window" 20 | }, 21 | "property": { 22 | "type": "Identifier", 23 | "start": 7, 24 | "end": 10, 25 | "name": "foo" 26 | }, 27 | "computed": false, 28 | "optional": false 29 | }, 30 | "right": { 31 | "type": "Literal", 32 | "start": 13, 33 | "end": 14, 34 | "value": 2, 35 | "raw": "2" 36 | } 37 | }, 38 | "async": false, 39 | "generator": false, 40 | "references": [ 41 | { 42 | "type": "Identifier", 43 | "start": 0, 44 | "end": 6, 45 | "name": "window" 46 | } 47 | ], 48 | "fileAttachments": [], 49 | "databaseClients": [], 50 | "secrets": [], 51 | "notificationClients": [] 52 | } -------------------------------------------------------------------------------- /test/output/mutable-argument.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'mutable' (1:12)", 5 | "pos": 12, 6 | "loc": { 7 | "line": 1, 8 | "column": 12 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/mutable-as-property.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 24, 5 | "id": null, 6 | "body": { 7 | "type": "BinaryExpression", 8 | "start": 0, 9 | "end": 23, 10 | "left": { 11 | "type": "MemberExpression", 12 | "start": 0, 13 | "end": 19, 14 | "object": { 15 | "type": "Identifier", 16 | "start": 0, 17 | "end": 6, 18 | "name": "object" 19 | }, 20 | "property": { 21 | "type": "MutableExpression", 22 | "start": 7, 23 | "end": 18, 24 | "id": { 25 | "type": "Identifier", 26 | "start": 15, 27 | "end": 18, 28 | "name": "foo" 29 | } 30 | }, 31 | "computed": true, 32 | "optional": false 33 | }, 34 | "operator": "+", 35 | "right": { 36 | "type": "Literal", 37 | "start": 22, 38 | "end": 23, 39 | "value": 1, 40 | "raw": "1" 41 | } 42 | }, 43 | "async": false, 44 | "generator": false, 45 | "references": [ 46 | { 47 | "type": "Identifier", 48 | "start": 0, 49 | "end": 6, 50 | "name": "object" 51 | }, 52 | { 53 | "type": "MutableExpression", 54 | "start": 7, 55 | "end": 18, 56 | "id": { 57 | "type": "Identifier", 58 | "start": 15, 59 | "end": 18, 60 | "name": "foo" 61 | } 62 | } 63 | ], 64 | "fileAttachments": [], 65 | "databaseClients": [], 66 | "secrets": [], 67 | "notificationClients": [] 68 | } -------------------------------------------------------------------------------- /test/output/mutable-assign-default.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 44, 5 | "id": { 6 | "type": "MutableExpression", 7 | "start": 0, 8 | "end": 13, 9 | "id": { 10 | "type": "Identifier", 11 | "start": 8, 12 | "end": 13, 13 | "name": "state" 14 | } 15 | }, 16 | "body": { 17 | "type": "AwaitExpression", 18 | "start": 16, 19 | "end": 43, 20 | "argument": { 21 | "type": "CallExpression", 22 | "start": 22, 23 | "end": 43, 24 | "callee": { 25 | "type": "MemberExpression", 26 | "start": 22, 27 | "end": 35, 28 | "object": { 29 | "type": "Identifier", 30 | "start": 22, 31 | "end": 29, 32 | "name": "Service" 33 | }, 34 | "property": { 35 | "type": "Identifier", 36 | "start": 30, 37 | "end": 35, 38 | "name": "fetch" 39 | }, 40 | "computed": false, 41 | "optional": false 42 | }, 43 | "arguments": [ 44 | { 45 | "type": "Identifier", 46 | "start": 36, 47 | "end": 42, 48 | "name": "config" 49 | } 50 | ], 51 | "optional": false 52 | } 53 | }, 54 | "async": true, 55 | "generator": false, 56 | "references": [ 57 | { 58 | "type": "Identifier", 59 | "start": 22, 60 | "end": 29, 61 | "name": "Service" 62 | }, 63 | { 64 | "type": "Identifier", 65 | "start": 36, 66 | "end": 42, 67 | "name": "config" 68 | } 69 | ], 70 | "fileAttachments": [], 71 | "databaseClients": [], 72 | "secrets": [], 73 | "notificationClients": [] 74 | } -------------------------------------------------------------------------------- /test/output/mutable-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 27, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 26, 10 | "body": [ 11 | { 12 | "type": "ExpressionStatement", 13 | "start": 4, 14 | "end": 24, 15 | "expression": { 16 | "type": "AssignmentExpression", 17 | "start": 4, 18 | "end": 23, 19 | "operator": "=", 20 | "left": { 21 | "type": "MutableExpression", 22 | "start": 4, 23 | "end": 17, 24 | "id": { 25 | "type": "Identifier", 26 | "start": 12, 27 | "end": 17, 28 | "name": "value" 29 | } 30 | }, 31 | "right": { 32 | "type": "Literal", 33 | "start": 20, 34 | "end": 23, 35 | "value": 101, 36 | "raw": "101" 37 | } 38 | } 39 | } 40 | ] 41 | }, 42 | "async": false, 43 | "generator": false, 44 | "references": [ 45 | { 46 | "type": "MutableExpression", 47 | "start": 4, 48 | "end": 17, 49 | "id": { 50 | "type": "Identifier", 51 | "start": 12, 52 | "end": 17, 53 | "name": "value" 54 | } 55 | } 56 | ], 57 | "fileAttachments": [], 58 | "databaseClients": [], 59 | "secrets": [], 60 | "notificationClients": [] 61 | } -------------------------------------------------------------------------------- /test/output/mutable-block-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 41, 5 | "id": { 6 | "type": "MutableExpression", 7 | "start": 0, 8 | "end": 11, 9 | "id": { 10 | "type": "Identifier", 11 | "start": 8, 12 | "end": 11, 13 | "name": "foo" 14 | } 15 | }, 16 | "body": { 17 | "type": "BlockStatement", 18 | "start": 14, 19 | "end": 40, 20 | "body": [ 21 | { 22 | "type": "ReturnStatement", 23 | "start": 18, 24 | "end": 38, 25 | "argument": { 26 | "type": "ObjectExpression", 27 | "start": 25, 28 | "end": 37, 29 | "properties": [ 30 | { 31 | "type": "Property", 32 | "start": 26, 33 | "end": 30, 34 | "method": false, 35 | "shorthand": false, 36 | "computed": false, 37 | "key": { 38 | "type": "Identifier", 39 | "start": 26, 40 | "end": 27, 41 | "name": "x" 42 | }, 43 | "value": { 44 | "type": "Literal", 45 | "start": 29, 46 | "end": 30, 47 | "value": 0, 48 | "raw": "0" 49 | }, 50 | "kind": "init" 51 | }, 52 | { 53 | "type": "Property", 54 | "start": 32, 55 | "end": 36, 56 | "method": false, 57 | "shorthand": false, 58 | "computed": false, 59 | "key": { 60 | "type": "Identifier", 61 | "start": 32, 62 | "end": 33, 63 | "name": "y" 64 | }, 65 | "value": { 66 | "type": "Literal", 67 | "start": 35, 68 | "end": 36, 69 | "value": 0, 70 | "raw": "0" 71 | }, 72 | "kind": "init" 73 | } 74 | ] 75 | } 76 | } 77 | ] 78 | }, 79 | "async": false, 80 | "generator": false, 81 | "references": [], 82 | "fileAttachments": [], 83 | "databaseClients": [], 84 | "secrets": [], 85 | "notificationClients": [] 86 | } -------------------------------------------------------------------------------- /test/output/mutable-constant.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:8)", 5 | "pos": 8, 6 | "loc": { 7 | "line": 1, 8 | "column": 8 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/mutable-default-value.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 43, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 9, 8 | "end": 11, 9 | "name": "fn" 10 | }, 11 | "body": { 12 | "type": "FunctionExpression", 13 | "start": 0, 14 | "end": 42, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 9, 18 | "end": 11, 19 | "name": "fn" 20 | }, 21 | "expression": false, 22 | "generator": false, 23 | "async": false, 24 | "params": [ 25 | { 26 | "type": "AssignmentPattern", 27 | "start": 12, 28 | "end": 25, 29 | "left": { 30 | "type": "Identifier", 31 | "start": 12, 32 | "end": 13, 33 | "name": "y" 34 | }, 35 | "right": { 36 | "type": "MutableExpression", 37 | "start": 16, 38 | "end": 25, 39 | "id": { 40 | "type": "Identifier", 41 | "start": 24, 42 | "end": 25, 43 | "name": "x" 44 | } 45 | } 46 | } 47 | ], 48 | "body": { 49 | "type": "BlockStatement", 50 | "start": 27, 51 | "end": 42, 52 | "body": [ 53 | { 54 | "type": "ReturnStatement", 55 | "start": 31, 56 | "end": 40, 57 | "argument": { 58 | "type": "Identifier", 59 | "start": 38, 60 | "end": 39, 61 | "name": "y" 62 | } 63 | } 64 | ] 65 | } 66 | }, 67 | "async": false, 68 | "generator": false, 69 | "references": [ 70 | { 71 | "type": "MutableExpression", 72 | "start": 16, 73 | "end": 25, 74 | "id": { 75 | "type": "Identifier", 76 | "start": 24, 77 | "end": 25, 78 | "name": "x" 79 | } 80 | } 81 | ], 82 | "fileAttachments": [], 83 | "databaseClients": [], 84 | "secrets": [], 85 | "notificationClients": [] 86 | } -------------------------------------------------------------------------------- /test/output/mutable-destructure-array.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 21, 5 | "id": null, 6 | "body": { 7 | "type": "AssignmentExpression", 8 | "start": 1, 9 | "end": 19, 10 | "operator": "=", 11 | "left": { 12 | "type": "ArrayPattern", 13 | "start": 1, 14 | "end": 12, 15 | "elements": [ 16 | { 17 | "type": "MutableExpression", 18 | "start": 2, 19 | "end": 11, 20 | "id": { 21 | "type": "Identifier", 22 | "start": 10, 23 | "end": 11, 24 | "name": "x" 25 | } 26 | } 27 | ] 28 | }, 29 | "right": { 30 | "type": "ArrayExpression", 31 | "start": 15, 32 | "end": 19, 33 | "elements": [ 34 | { 35 | "type": "Literal", 36 | "start": 16, 37 | "end": 18, 38 | "value": 42, 39 | "raw": "42" 40 | } 41 | ] 42 | } 43 | }, 44 | "async": false, 45 | "generator": false, 46 | "references": [ 47 | { 48 | "type": "MutableExpression", 49 | "start": 2, 50 | "end": 11, 51 | "id": { 52 | "type": "Identifier", 53 | "start": 10, 54 | "end": 11, 55 | "name": "x" 56 | } 57 | } 58 | ], 59 | "fileAttachments": [], 60 | "databaseClients": [], 61 | "secrets": [], 62 | "notificationClients": [] 63 | } -------------------------------------------------------------------------------- /test/output/mutable-destructure-object.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 44, 5 | "id": null, 6 | "body": { 7 | "type": "AssignmentExpression", 8 | "start": 1, 9 | "end": 42, 10 | "operator": "=", 11 | "left": { 12 | "type": "ObjectPattern", 13 | "start": 1, 14 | "end": 22, 15 | "properties": [ 16 | { 17 | "type": "Property", 18 | "start": 2, 19 | "end": 21, 20 | "method": false, 21 | "shorthand": false, 22 | "computed": false, 23 | "key": { 24 | "type": "Identifier", 25 | "start": 2, 26 | "end": 10, 27 | "name": "property" 28 | }, 29 | "value": { 30 | "type": "MutableExpression", 31 | "start": 12, 32 | "end": 21, 33 | "id": { 34 | "type": "Identifier", 35 | "start": 20, 36 | "end": 21, 37 | "name": "x" 38 | } 39 | }, 40 | "kind": "init" 41 | } 42 | ] 43 | }, 44 | "right": { 45 | "type": "ObjectExpression", 46 | "start": 25, 47 | "end": 42, 48 | "properties": [ 49 | { 50 | "type": "Property", 51 | "start": 26, 52 | "end": 41, 53 | "method": false, 54 | "shorthand": false, 55 | "computed": false, 56 | "key": { 57 | "type": "Identifier", 58 | "start": 26, 59 | "end": 34, 60 | "name": "property" 61 | }, 62 | "value": { 63 | "type": "Identifier", 64 | "start": 36, 65 | "end": 41, 66 | "name": "value" 67 | }, 68 | "kind": "init" 69 | } 70 | ] 71 | } 72 | }, 73 | "async": false, 74 | "generator": false, 75 | "references": [ 76 | { 77 | "type": "MutableExpression", 78 | "start": 12, 79 | "end": 21, 80 | "id": { 81 | "type": "Identifier", 82 | "start": 20, 83 | "end": 21, 84 | "name": "x" 85 | } 86 | }, 87 | { 88 | "type": "Identifier", 89 | "start": 36, 90 | "end": 41, 91 | "name": "value" 92 | } 93 | ], 94 | "fileAttachments": [], 95 | "databaseClients": [], 96 | "secrets": [], 97 | "notificationClients": [] 98 | } -------------------------------------------------------------------------------- /test/output/mutable-destructure-property.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'mutable' (1:2)", 5 | "pos": 2, 6 | "loc": { 7 | "line": 1, 8 | "column": 2 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/mutable-internal-comment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 28, 5 | "id": null, 6 | "body": { 7 | "type": "MutableExpression", 8 | "start": 0, 9 | "end": 27, 10 | "id": { 11 | "type": "Identifier", 12 | "start": 22, 13 | "end": 27, 14 | "name": "value" 15 | } 16 | }, 17 | "async": false, 18 | "generator": false, 19 | "references": [ 20 | { 21 | "type": "MutableExpression", 22 | "start": 0, 23 | "end": 27, 24 | "id": { 25 | "type": "Identifier", 26 | "start": 22, 27 | "end": 27, 28 | "name": "value" 29 | } 30 | } 31 | ], 32 | "fileAttachments": [], 33 | "databaseClients": [], 34 | "secrets": [], 35 | "notificationClients": [] 36 | } -------------------------------------------------------------------------------- /test/output/mutable-member.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:15)", 5 | "pos": 15, 6 | "loc": { 7 | "line": 1, 8 | "column": 15 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/mutable-reference.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 23, 5 | "id": null, 6 | "body": { 7 | "type": "MemberExpression", 8 | "start": 0, 9 | "end": 22, 10 | "object": { 11 | "type": "MutableExpression", 12 | "start": 0, 13 | "end": 13, 14 | "id": { 15 | "type": "Identifier", 16 | "start": 8, 17 | "end": 13, 18 | "name": "value" 19 | } 20 | }, 21 | "property": { 22 | "type": "Identifier", 23 | "start": 14, 24 | "end": 22, 25 | "name": "property" 26 | }, 27 | "computed": false, 28 | "optional": false 29 | }, 30 | "async": false, 31 | "generator": false, 32 | "references": [ 33 | { 34 | "type": "MutableExpression", 35 | "start": 0, 36 | "end": 13, 37 | "id": { 38 | "type": "Identifier", 39 | "start": 8, 40 | "end": 13, 41 | "name": "value" 42 | } 43 | } 44 | ], 45 | "fileAttachments": [], 46 | "databaseClients": [], 47 | "secrets": [], 48 | "notificationClients": [] 49 | } -------------------------------------------------------------------------------- /test/output/mutable-var.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'mutable' (2:6)", 5 | "pos": 8, 6 | "loc": { 7 | "line": 2, 8 | "column": 6 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/named-async-function.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 40, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 15, 8 | "end": 18, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "FunctionExpression", 13 | "start": 0, 14 | "end": 39, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 15, 18 | "end": 18, 19 | "name": "foo" 20 | }, 21 | "expression": false, 22 | "generator": false, 23 | "async": true, 24 | "params": [], 25 | "body": { 26 | "type": "BlockStatement", 27 | "start": 21, 28 | "end": 39, 29 | "body": [ 30 | { 31 | "type": "ExpressionStatement", 32 | "start": 23, 33 | "end": 37, 34 | "expression": { 35 | "type": "AwaitExpression", 36 | "start": 23, 37 | "end": 36, 38 | "argument": { 39 | "type": "Identifier", 40 | "start": 29, 41 | "end": 36, 42 | "name": "promise" 43 | } 44 | } 45 | } 46 | ] 47 | } 48 | }, 49 | "async": false, 50 | "generator": false, 51 | "references": [ 52 | { 53 | "type": "Identifier", 54 | "start": 29, 55 | "end": 36, 56 | "name": "promise" 57 | } 58 | ], 59 | "fileAttachments": [], 60 | "databaseClients": [], 61 | "secrets": [], 62 | "notificationClients": [] 63 | } -------------------------------------------------------------------------------- /test/output/named-block-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 23, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 3, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "BlockStatement", 13 | "start": 6, 14 | "end": 22, 15 | "body": [ 16 | { 17 | "type": "ReturnStatement", 18 | "start": 10, 19 | "end": 20, 20 | "argument": { 21 | "type": "Literal", 22 | "start": 17, 23 | "end": 19, 24 | "value": 42, 25 | "raw": "42" 26 | } 27 | } 28 | ] 29 | }, 30 | "async": false, 31 | "generator": false, 32 | "references": [], 33 | "fileAttachments": [], 34 | "databaseClients": [], 35 | "secrets": [], 36 | "notificationClients": [] 37 | } -------------------------------------------------------------------------------- /test/output/named-class-with-field.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 33, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 6, 8 | "end": 9, 9 | "name": "Foo" 10 | }, 11 | "body": { 12 | "type": "ClassExpression", 13 | "start": 0, 14 | "end": 32, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 6, 18 | "end": 9, 19 | "name": "Foo" 20 | }, 21 | "superClass": null, 22 | "body": { 23 | "type": "ClassBody", 24 | "start": 10, 25 | "end": 32, 26 | "body": [ 27 | { 28 | "type": "PropertyDefinition", 29 | "start": 14, 30 | "end": 30, 31 | "static": false, 32 | "computed": false, 33 | "key": { 34 | "type": "Identifier", 35 | "start": 14, 36 | "end": 19, 37 | "name": "field" 38 | }, 39 | "value": { 40 | "type": "Literal", 41 | "start": 22, 42 | "end": 29, 43 | "value": "field", 44 | "raw": "\"field\"" 45 | } 46 | } 47 | ] 48 | } 49 | }, 50 | "async": false, 51 | "generator": false, 52 | "references": [], 53 | "fileAttachments": [], 54 | "databaseClients": [], 55 | "secrets": [], 56 | "notificationClients": [] 57 | } -------------------------------------------------------------------------------- /test/output/named-class-with-method.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 49, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 6, 8 | "end": 9, 9 | "name": "Foo" 10 | }, 11 | "body": { 12 | "type": "ClassExpression", 13 | "start": 0, 14 | "end": 48, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 6, 18 | "end": 9, 19 | "name": "Foo" 20 | }, 21 | "superClass": null, 22 | "body": { 23 | "type": "ClassBody", 24 | "start": 10, 25 | "end": 48, 26 | "body": [ 27 | { 28 | "type": "MethodDefinition", 29 | "start": 14, 30 | "end": 46, 31 | "static": false, 32 | "computed": false, 33 | "key": { 34 | "type": "Identifier", 35 | "start": 14, 36 | "end": 20, 37 | "name": "method" 38 | }, 39 | "kind": "method", 40 | "value": { 41 | "type": "FunctionExpression", 42 | "start": 20, 43 | "end": 46, 44 | "id": null, 45 | "expression": false, 46 | "generator": false, 47 | "async": false, 48 | "params": [], 49 | "body": { 50 | "type": "BlockStatement", 51 | "start": 23, 52 | "end": 46, 53 | "body": [ 54 | { 55 | "type": "ReturnStatement", 56 | "start": 29, 57 | "end": 42, 58 | "argument": { 59 | "type": "Literal", 60 | "start": 36, 61 | "end": 41, 62 | "value": "foo", 63 | "raw": "\"foo\"" 64 | } 65 | } 66 | ] 67 | } 68 | } 69 | } 70 | ] 71 | } 72 | }, 73 | "async": false, 74 | "generator": false, 75 | "references": [], 76 | "fileAttachments": [], 77 | "databaseClients": [], 78 | "secrets": [], 79 | "notificationClients": [] 80 | } -------------------------------------------------------------------------------- /test/output/named-class-with-private-field.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 49, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 6, 8 | "end": 9, 9 | "name": "Foo" 10 | }, 11 | "body": { 12 | "type": "ClassExpression", 13 | "start": 0, 14 | "end": 48, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 6, 18 | "end": 9, 19 | "name": "Foo" 20 | }, 21 | "superClass": null, 22 | "body": { 23 | "type": "ClassBody", 24 | "start": 10, 25 | "end": 48, 26 | "body": [ 27 | { 28 | "type": "PropertyDefinition", 29 | "start": 14, 30 | "end": 31, 31 | "static": false, 32 | "computed": false, 33 | "key": { 34 | "type": "PrivateIdentifier", 35 | "start": 14, 36 | "end": 20, 37 | "name": "field" 38 | }, 39 | "value": { 40 | "type": "Literal", 41 | "start": 23, 42 | "end": 30, 43 | "value": "field", 44 | "raw": "\"field\"" 45 | } 46 | }, 47 | { 48 | "type": "MethodDefinition", 49 | "start": 34, 50 | "end": 46, 51 | "static": false, 52 | "computed": false, 53 | "key": { 54 | "type": "PrivateIdentifier", 55 | "start": 34, 56 | "end": 41, 57 | "name": "method" 58 | }, 59 | "kind": "method", 60 | "value": { 61 | "type": "FunctionExpression", 62 | "start": 41, 63 | "end": 46, 64 | "id": null, 65 | "expression": false, 66 | "generator": false, 67 | "async": false, 68 | "params": [], 69 | "body": { 70 | "type": "BlockStatement", 71 | "start": 44, 72 | "end": 46, 73 | "body": [] 74 | } 75 | } 76 | } 77 | ] 78 | } 79 | }, 80 | "async": false, 81 | "generator": false, 82 | "references": [], 83 | "fileAttachments": [], 84 | "databaseClients": [], 85 | "secrets": [], 86 | "notificationClients": [] 87 | } -------------------------------------------------------------------------------- /test/output/named-class-with-static-field.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 40, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 6, 8 | "end": 9, 9 | "name": "Foo" 10 | }, 11 | "body": { 12 | "type": "ClassExpression", 13 | "start": 0, 14 | "end": 39, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 6, 18 | "end": 9, 19 | "name": "Foo" 20 | }, 21 | "superClass": null, 22 | "body": { 23 | "type": "ClassBody", 24 | "start": 10, 25 | "end": 39, 26 | "body": [ 27 | { 28 | "type": "PropertyDefinition", 29 | "start": 14, 30 | "end": 37, 31 | "static": true, 32 | "computed": false, 33 | "key": { 34 | "type": "Identifier", 35 | "start": 21, 36 | "end": 26, 37 | "name": "field" 38 | }, 39 | "value": { 40 | "type": "Literal", 41 | "start": 29, 42 | "end": 36, 43 | "value": "field", 44 | "raw": "\"field\"" 45 | } 46 | } 47 | ] 48 | } 49 | }, 50 | "async": false, 51 | "generator": false, 52 | "references": [], 53 | "fileAttachments": [], 54 | "databaseClients": [], 55 | "secrets": [], 56 | "notificationClients": [] 57 | } -------------------------------------------------------------------------------- /test/output/named-class.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 13, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 6, 8 | "end": 9, 9 | "name": "Foo" 10 | }, 11 | "body": { 12 | "type": "ClassExpression", 13 | "start": 0, 14 | "end": 12, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 6, 18 | "end": 9, 19 | "name": "Foo" 20 | }, 21 | "superClass": null, 22 | "body": { 23 | "type": "ClassBody", 24 | "start": 10, 25 | "end": 12, 26 | "body": [] 27 | } 28 | }, 29 | "async": false, 30 | "generator": false, 31 | "references": [], 32 | "fileAttachments": [], 33 | "databaseClients": [], 34 | "secrets": [], 35 | "notificationClients": [] 36 | } -------------------------------------------------------------------------------- /test/output/named-empty.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected end of input (2:0)", 5 | "pos": 6, 6 | "loc": { 7 | "line": 2, 8 | "column": 0 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/named-expression-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 9, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 3, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "Literal", 13 | "start": 6, 14 | "end": 8, 15 | "value": 42, 16 | "raw": "42" 17 | }, 18 | "async": false, 19 | "generator": false, 20 | "references": [], 21 | "fileAttachments": [], 22 | "databaseClients": [], 23 | "secrets": [], 24 | "notificationClients": [] 25 | } -------------------------------------------------------------------------------- /test/output/named-function-in-named-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 36, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 3, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "FunctionExpression", 13 | "start": 6, 14 | "end": 35, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 15, 18 | "end": 18, 19 | "name": "bar" 20 | }, 21 | "expression": false, 22 | "generator": false, 23 | "async": false, 24 | "params": [], 25 | "body": { 26 | "type": "BlockStatement", 27 | "start": 21, 28 | "end": 35, 29 | "body": [ 30 | { 31 | "type": "ReturnStatement", 32 | "start": 23, 33 | "end": 33, 34 | "argument": { 35 | "type": "Literal", 36 | "start": 30, 37 | "end": 32, 38 | "value": 42, 39 | "raw": "42" 40 | } 41 | } 42 | ] 43 | } 44 | }, 45 | "async": false, 46 | "generator": false, 47 | "references": [], 48 | "fileAttachments": [], 49 | "databaseClients": [], 50 | "secrets": [], 51 | "notificationClients": [] 52 | } -------------------------------------------------------------------------------- /test/output/named-function.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 30, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 9, 8 | "end": 12, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "FunctionExpression", 13 | "start": 0, 14 | "end": 29, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 9, 18 | "end": 12, 19 | "name": "foo" 20 | }, 21 | "expression": false, 22 | "generator": false, 23 | "async": false, 24 | "params": [], 25 | "body": { 26 | "type": "BlockStatement", 27 | "start": 15, 28 | "end": 29, 29 | "body": [ 30 | { 31 | "type": "ReturnStatement", 32 | "start": 17, 33 | "end": 27, 34 | "argument": { 35 | "type": "Literal", 36 | "start": 24, 37 | "end": 26, 38 | "value": 42, 39 | "raw": "42" 40 | } 41 | } 42 | ] 43 | } 44 | }, 45 | "async": false, 46 | "generator": false, 47 | "references": [], 48 | "fileAttachments": [], 49 | "databaseClients": [], 50 | "secrets": [], 51 | "notificationClients": [] 52 | } -------------------------------------------------------------------------------- /test/output/named-generator-function.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 30, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 10, 8 | "end": 13, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "FunctionExpression", 13 | "start": 0, 14 | "end": 29, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 10, 18 | "end": 13, 19 | "name": "foo" 20 | }, 21 | "expression": false, 22 | "generator": true, 23 | "async": false, 24 | "params": [], 25 | "body": { 26 | "type": "BlockStatement", 27 | "start": 16, 28 | "end": 29, 29 | "body": [ 30 | { 31 | "type": "ExpressionStatement", 32 | "start": 18, 33 | "end": 27, 34 | "expression": { 35 | "type": "YieldExpression", 36 | "start": 18, 37 | "end": 26, 38 | "delegate": false, 39 | "argument": { 40 | "type": "Literal", 41 | "start": 24, 42 | "end": 26, 43 | "value": 42, 44 | "raw": "42" 45 | } 46 | } 47 | } 48 | ] 49 | } 50 | }, 51 | "async": false, 52 | "generator": false, 53 | "references": [], 54 | "fileAttachments": [], 55 | "databaseClients": [], 56 | "secrets": [], 57 | "notificationClients": [] 58 | } -------------------------------------------------------------------------------- /test/output/notification-client.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 53, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 52, 10 | "body": [ 11 | { 12 | "type": "VariableDeclaration", 13 | "start": 6, 14 | "end": 50, 15 | "declarations": [ 16 | { 17 | "type": "VariableDeclarator", 18 | "start": 10, 19 | "end": 49, 20 | "id": { 21 | "type": "Identifier", 22 | "start": 10, 23 | "end": 11, 24 | "name": "a" 25 | }, 26 | "init": { 27 | "type": "CallExpression", 28 | "start": 14, 29 | "end": 49, 30 | "callee": { 31 | "type": "Identifier", 32 | "start": 14, 33 | "end": 32, 34 | "name": "NotificationClient" 35 | }, 36 | "arguments": [ 37 | { 38 | "type": "Literal", 39 | "start": 33, 40 | "end": 48, 41 | "value": "slack:@claire", 42 | "raw": "\"slack:@claire\"" 43 | } 44 | ], 45 | "optional": false 46 | } 47 | } 48 | ], 49 | "kind": "let" 50 | } 51 | ] 52 | }, 53 | "async": false, 54 | "generator": false, 55 | "references": [ 56 | { 57 | "type": "Identifier", 58 | "start": 14, 59 | "end": 32, 60 | "name": "NotificationClient" 61 | } 62 | ], 63 | "fileAttachments": [], 64 | "databaseClients": [], 65 | "secrets": [], 66 | "notificationClients": [ 67 | [ 68 | "slack:@claire", 69 | [ 70 | { 71 | "start": 33, 72 | "end": 48 73 | } 74 | ] 75 | ] 76 | ] 77 | } -------------------------------------------------------------------------------- /test/output/nullish-coalescing.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 31, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 3, 9 | "name": "foo" 10 | }, 11 | "body": { 12 | "type": "LogicalExpression", 13 | "start": 6, 14 | "end": 30, 15 | "left": { 16 | "type": "Literal", 17 | "start": 6, 18 | "end": 10, 19 | "value": null, 20 | "raw": "null" 21 | }, 22 | "operator": "??", 23 | "right": { 24 | "type": "Literal", 25 | "start": 14, 26 | "end": 30, 27 | "value": "default string", 28 | "raw": "'default string'" 29 | } 30 | }, 31 | "async": false, 32 | "generator": false, 33 | "references": [], 34 | "fileAttachments": [], 35 | "databaseClients": [], 36 | "secrets": [], 37 | "notificationClients": [] 38 | } -------------------------------------------------------------------------------- /test/output/object-literal.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 12, 5 | "id": null, 6 | "body": { 7 | "type": "ObjectExpression", 8 | "start": 1, 9 | "end": 10, 10 | "properties": [ 11 | { 12 | "type": "Property", 13 | "start": 2, 14 | "end": 9, 15 | "method": false, 16 | "shorthand": false, 17 | "computed": false, 18 | "key": { 19 | "type": "Identifier", 20 | "start": 2, 21 | "end": 5, 22 | "name": "foo" 23 | }, 24 | "value": { 25 | "type": "Literal", 26 | "start": 7, 27 | "end": 9, 28 | "value": 42, 29 | "raw": "42" 30 | }, 31 | "kind": "init" 32 | } 33 | ] 34 | }, 35 | "async": false, 36 | "generator": false, 37 | "references": [], 38 | "fileAttachments": [], 39 | "databaseClients": [], 40 | "secrets": [], 41 | "notificationClients": [] 42 | } -------------------------------------------------------------------------------- /test/output/optional-chaining.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 31, 5 | "id": { 6 | "type": "Identifier", 7 | "start": 0, 8 | "end": 7, 9 | "name": "dogName" 10 | }, 11 | "body": { 12 | "type": "ChainExpression", 13 | "start": 10, 14 | "end": 30, 15 | "expression": { 16 | "type": "MemberExpression", 17 | "start": 10, 18 | "end": 30, 19 | "object": { 20 | "type": "MemberExpression", 21 | "start": 10, 22 | "end": 24, 23 | "object": { 24 | "type": "Identifier", 25 | "start": 10, 26 | "end": 20, 27 | "name": "adventurer" 28 | }, 29 | "property": { 30 | "type": "Identifier", 31 | "start": 21, 32 | "end": 24, 33 | "name": "dog" 34 | }, 35 | "computed": false, 36 | "optional": false 37 | }, 38 | "property": { 39 | "type": "Identifier", 40 | "start": 26, 41 | "end": 30, 42 | "name": "name" 43 | }, 44 | "computed": false, 45 | "optional": true 46 | } 47 | }, 48 | "async": false, 49 | "generator": false, 50 | "references": [ 51 | { 52 | "type": "Identifier", 53 | "start": 10, 54 | "end": 20, 55 | "name": "adventurer" 56 | } 57 | ], 58 | "fileAttachments": [], 59 | "databaseClients": [], 60 | "secrets": [], 61 | "notificationClients": [] 62 | } -------------------------------------------------------------------------------- /test/output/reserved-function.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'Array' is reserved (1:9)", 5 | "pos": 9, 6 | "loc": { 7 | "line": 1, 8 | "column": 9 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/reserved-import-as.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'Array' is reserved (1:15)", 5 | "pos": 15, 6 | "loc": { 7 | "line": 1, 8 | "column": 15 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/reserved-import-view.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'Array' is reserved (1:15)", 5 | "pos": 15, 6 | "loc": { 7 | "line": 1, 8 | "column": 15 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/reserved-import-with-as.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'Array' is reserved (1:26)", 5 | "pos": 26, 6 | "loc": { 7 | "line": 1, 8 | "column": 26 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/reserved-import-with.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'Array' is reserved (1:19)", 5 | "pos": 19, 6 | "loc": { 7 | "line": 1, 8 | "column": 19 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/reserved-import.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'Array' is reserved (1:8)", 5 | "pos": 8, 6 | "loc": { 7 | "line": 1, 8 | "column": 8 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/reserved-name.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'Array' is reserved (1:0)", 5 | "pos": 0, 6 | "loc": { 7 | "line": 1, 8 | "column": 0 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/reserved-view.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Identifier 'Array' is reserved (1:7)", 5 | "pos": 7, 6 | "loc": { 7 | "line": 1, 8 | "column": 7 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/secret.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 27, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 26, 10 | "body": [ 11 | { 12 | "type": "VariableDeclaration", 13 | "start": 4, 14 | "end": 24, 15 | "declarations": [ 16 | { 17 | "type": "VariableDeclarator", 18 | "start": 8, 19 | "end": 23, 20 | "id": { 21 | "type": "Identifier", 22 | "start": 8, 23 | "end": 9, 24 | "name": "a" 25 | }, 26 | "init": { 27 | "type": "CallExpression", 28 | "start": 12, 29 | "end": 23, 30 | "callee": { 31 | "type": "Identifier", 32 | "start": 12, 33 | "end": 18, 34 | "name": "Secret" 35 | }, 36 | "arguments": [ 37 | { 38 | "type": "Literal", 39 | "start": 19, 40 | "end": 22, 41 | "value": "a", 42 | "raw": "\"a\"" 43 | } 44 | ], 45 | "optional": false 46 | } 47 | } 48 | ], 49 | "kind": "let" 50 | } 51 | ] 52 | }, 53 | "async": false, 54 | "generator": false, 55 | "references": [ 56 | { 57 | "type": "Identifier", 58 | "start": 12, 59 | "end": 18, 60 | "name": "Secret" 61 | } 62 | ], 63 | "fileAttachments": [], 64 | "databaseClients": [], 65 | "secrets": [ 66 | [ 67 | "a", 68 | [ 69 | { 70 | "start": 19, 71 | "end": 22 72 | } 73 | ] 74 | ] 75 | ], 76 | "notificationClients": [] 77 | } -------------------------------------------------------------------------------- /test/output/semicolon.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 2, 5 | "id": null, 6 | "body": null, 7 | "async": false, 8 | "generator": false, 9 | "references": [], 10 | "fileAttachments": [], 11 | "databaseClients": [], 12 | "secrets": [], 13 | "notificationClients": [] 14 | } -------------------------------------------------------------------------------- /test/output/sequence-expression.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 8, 5 | "id": null, 6 | "body": { 7 | "type": "SequenceExpression", 8 | "start": 0, 9 | "end": 7, 10 | "expressions": [ 11 | { 12 | "type": "Literal", 13 | "start": 0, 14 | "end": 1, 15 | "value": 1, 16 | "raw": "1" 17 | }, 18 | { 19 | "type": "Literal", 20 | "start": 3, 21 | "end": 4, 22 | "value": 2, 23 | "raw": "2" 24 | }, 25 | { 26 | "type": "Literal", 27 | "start": 6, 28 | "end": 7, 29 | "value": 3, 30 | "raw": "3" 31 | } 32 | ] 33 | }, 34 | "async": false, 35 | "generator": false, 36 | "references": [], 37 | "fileAttachments": [], 38 | "databaseClients": [], 39 | "secrets": [], 40 | "notificationClients": [] 41 | } -------------------------------------------------------------------------------- /test/output/shadowed-view.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 45, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 44, 10 | "body": [ 11 | { 12 | "type": "VariableDeclaration", 13 | "start": 4, 14 | "end": 14, 15 | "declarations": [ 16 | { 17 | "type": "VariableDeclarator", 18 | "start": 8, 19 | "end": 13, 20 | "id": { 21 | "type": "Identifier", 22 | "start": 8, 23 | "end": 9, 24 | "name": "x" 25 | }, 26 | "init": { 27 | "type": "Literal", 28 | "start": 12, 29 | "end": 13, 30 | "value": 2, 31 | "raw": "2" 32 | } 33 | } 34 | ], 35 | "kind": "let" 36 | }, 37 | { 38 | "type": "ExpressionStatement", 39 | "start": 17, 40 | "end": 23, 41 | "expression": { 42 | "type": "AssignmentExpression", 43 | "start": 17, 44 | "end": 22, 45 | "operator": "=", 46 | "left": { 47 | "type": "Identifier", 48 | "start": 17, 49 | "end": 18, 50 | "name": "x" 51 | }, 52 | "right": { 53 | "type": "Literal", 54 | "start": 21, 55 | "end": 22, 56 | "value": 4, 57 | "raw": "4" 58 | } 59 | } 60 | }, 61 | { 62 | "type": "ReturnStatement", 63 | "start": 26, 64 | "end": 42, 65 | "argument": { 66 | "type": "ViewExpression", 67 | "start": 33, 68 | "end": 41, 69 | "id": { 70 | "type": "Identifier", 71 | "start": 40, 72 | "end": 41, 73 | "name": "x" 74 | } 75 | } 76 | } 77 | ] 78 | }, 79 | "async": false, 80 | "generator": false, 81 | "references": [ 82 | { 83 | "type": "ViewExpression", 84 | "start": 33, 85 | "end": 41, 86 | "id": { 87 | "type": "Identifier", 88 | "start": 40, 89 | "end": 41, 90 | "name": "x" 91 | } 92 | } 93 | ], 94 | "fileAttachments": [], 95 | "databaseClients": [], 96 | "secrets": [], 97 | "notificationClients": [] 98 | } -------------------------------------------------------------------------------- /test/output/simple-await-tagged-template.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 21, 5 | "id": null, 6 | "body": { 7 | "type": "TaggedTemplateExpression", 8 | "start": 0, 9 | "end": 20, 10 | "tag": { 11 | "type": "Identifier", 12 | "start": 0, 13 | "end": 2, 14 | "name": "md" 15 | }, 16 | "quasi": { 17 | "type": "TemplateLiteral", 18 | "start": 2, 19 | "end": 20, 20 | "expressions": [ 21 | { 22 | "type": "AwaitExpression", 23 | "start": 5, 24 | "end": 18, 25 | "argument": { 26 | "type": "Identifier", 27 | "start": 11, 28 | "end": 18, 29 | "name": "promise" 30 | } 31 | } 32 | ], 33 | "quasis": [ 34 | { 35 | "type": "TemplateElement", 36 | "start": 3, 37 | "end": 3, 38 | "value": { 39 | "raw": "", 40 | "cooked": "" 41 | }, 42 | "tail": false 43 | }, 44 | { 45 | "type": "TemplateElement", 46 | "start": 19, 47 | "end": 19, 48 | "value": { 49 | "raw": "", 50 | "cooked": "" 51 | }, 52 | "tail": true 53 | } 54 | ] 55 | } 56 | }, 57 | "async": true, 58 | "generator": false, 59 | "references": [ 60 | { 61 | "type": "Identifier", 62 | "start": 0, 63 | "end": 2, 64 | "name": "md" 65 | }, 66 | { 67 | "type": "Identifier", 68 | "start": 11, 69 | "end": 18, 70 | "name": "promise" 71 | } 72 | ], 73 | "fileAttachments": [], 74 | "databaseClients": [], 75 | "secrets": [], 76 | "notificationClients": [] 77 | } -------------------------------------------------------------------------------- /test/output/simple-await-template.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 19, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 18, 10 | "expressions": [ 11 | { 12 | "type": "AwaitExpression", 13 | "start": 3, 14 | "end": 16, 15 | "argument": { 16 | "type": "Identifier", 17 | "start": 9, 18 | "end": 16, 19 | "name": "promise" 20 | } 21 | } 22 | ], 23 | "quasis": [ 24 | { 25 | "type": "TemplateElement", 26 | "start": 1, 27 | "end": 1, 28 | "value": { 29 | "raw": "", 30 | "cooked": "" 31 | }, 32 | "tail": false 33 | }, 34 | { 35 | "type": "TemplateElement", 36 | "start": 17, 37 | "end": 17, 38 | "value": { 39 | "raw": "", 40 | "cooked": "" 41 | }, 42 | "tail": true 43 | } 44 | ] 45 | }, 46 | "async": true, 47 | "generator": false, 48 | "references": [ 49 | { 50 | "type": "Identifier", 51 | "start": 9, 52 | "end": 16, 53 | "name": "promise" 54 | } 55 | ], 56 | "fileAttachments": [], 57 | "databaseClients": [], 58 | "secrets": [], 59 | "notificationClients": [] 60 | } -------------------------------------------------------------------------------- /test/output/simple-await-template.md.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 16, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 16, 10 | "expressions": [ 11 | { 12 | "type": "AwaitExpression", 13 | "start": 2, 14 | "end": 15, 15 | "argument": { 16 | "type": "Identifier", 17 | "start": 8, 18 | "end": 15, 19 | "name": "promise" 20 | } 21 | } 22 | ], 23 | "quasis": [ 24 | { 25 | "type": "TemplateElement", 26 | "start": 0, 27 | "end": 0, 28 | "value": { 29 | "raw": "", 30 | "cooked": null 31 | }, 32 | "tail": false 33 | }, 34 | { 35 | "type": "TemplateElement", 36 | "start": 16, 37 | "end": 16, 38 | "value": { 39 | "raw": "" 40 | }, 41 | "tail": true 42 | } 43 | ] 44 | }, 45 | "async": true, 46 | "generator": false, 47 | "tag": { 48 | "type": "CellTag", 49 | "start": 0, 50 | "end": 2, 51 | "body": { 52 | "type": "Identifier", 53 | "start": 0, 54 | "end": 2, 55 | "name": "md" 56 | }, 57 | "input": "md", 58 | "async": false, 59 | "generator": false, 60 | "references": [ 61 | { 62 | "type": "Identifier", 63 | "start": 0, 64 | "end": 2, 65 | "name": "md" 66 | } 67 | ], 68 | "fileAttachments": [], 69 | "databaseClients": [], 70 | "secrets": [], 71 | "notificationClients": [] 72 | }, 73 | "raw": false, 74 | "references": [ 75 | { 76 | "type": "Identifier", 77 | "start": 8, 78 | "end": 15, 79 | "name": "promise" 80 | } 81 | ], 82 | "fileAttachments": [], 83 | "databaseClients": [], 84 | "secrets": [], 85 | "notificationClients": [] 86 | } -------------------------------------------------------------------------------- /test/output/simple-identifier.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 4, 5 | "id": null, 6 | "body": { 7 | "type": "Identifier", 8 | "start": 0, 9 | "end": 3, 10 | "name": "foo" 11 | }, 12 | "async": false, 13 | "generator": false, 14 | "references": [ 15 | { 16 | "type": "Identifier", 17 | "start": 0, 18 | "end": 3, 19 | "name": "foo" 20 | } 21 | ], 22 | "fileAttachments": [], 23 | "databaseClients": [], 24 | "secrets": [], 25 | "notificationClients": [] 26 | } -------------------------------------------------------------------------------- /test/output/spread-element.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 23, 5 | "id": null, 6 | "body": { 7 | "type": "ArrowFunctionExpression", 8 | "start": 0, 9 | "end": 22, 10 | "id": null, 11 | "expression": true, 12 | "generator": false, 13 | "async": false, 14 | "params": [ 15 | { 16 | "type": "ObjectPattern", 17 | "start": 1, 18 | "end": 14, 19 | "properties": [ 20 | { 21 | "type": "Property", 22 | "start": 2, 23 | "end": 5, 24 | "method": false, 25 | "shorthand": true, 26 | "computed": false, 27 | "key": { 28 | "type": "Identifier", 29 | "start": 2, 30 | "end": 5, 31 | "name": "foo" 32 | }, 33 | "kind": "init", 34 | "value": { 35 | "type": "Identifier", 36 | "start": 2, 37 | "end": 5, 38 | "name": "foo" 39 | } 40 | }, 41 | { 42 | "type": "RestElement", 43 | "start": 7, 44 | "end": 13, 45 | "argument": { 46 | "type": "Identifier", 47 | "start": 10, 48 | "end": 13, 49 | "name": "bar" 50 | } 51 | } 52 | ] 53 | } 54 | ], 55 | "body": { 56 | "type": "Identifier", 57 | "start": 19, 58 | "end": 22, 59 | "name": "bar" 60 | } 61 | }, 62 | "async": false, 63 | "generator": false, 64 | "references": [], 65 | "fileAttachments": [], 66 | "databaseClients": [], 67 | "secrets": [], 68 | "notificationClients": [] 69 | } -------------------------------------------------------------------------------- /test/output/template-literal-semicolon.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 13, 5 | "id": null, 6 | "body": { 7 | "type": "TaggedTemplateExpression", 8 | "start": 0, 9 | "end": 11, 10 | "tag": { 11 | "type": "Identifier", 12 | "start": 0, 13 | "end": 4, 14 | "name": "html" 15 | }, 16 | "quasi": { 17 | "type": "TemplateLiteral", 18 | "start": 4, 19 | "end": 11, 20 | "expressions": [], 21 | "quasis": [ 22 | { 23 | "type": "TemplateElement", 24 | "start": 5, 25 | "end": 10, 26 | "value": { 27 | "raw": "hello", 28 | "cooked": "hello" 29 | }, 30 | "tail": true 31 | } 32 | ] 33 | } 34 | }, 35 | "async": false, 36 | "generator": false, 37 | "references": [ 38 | { 39 | "type": "Identifier", 40 | "start": 0, 41 | "end": 4, 42 | "name": "html" 43 | } 44 | ], 45 | "fileAttachments": [], 46 | "databaseClients": [], 47 | "secrets": [], 48 | "notificationClients": [] 49 | } -------------------------------------------------------------------------------- /test/output/this-as-name.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Assigning to rvalue (1:0)", 5 | "pos": 0, 6 | "loc": { 7 | "line": 1, 8 | "column": 0 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/this.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 5, 5 | "id": null, 6 | "body": { 7 | "type": "ThisExpression", 8 | "start": 0, 9 | "end": 4 10 | }, 11 | "async": false, 12 | "generator": false, 13 | "references": [], 14 | "fileAttachments": [], 15 | "databaseClients": [], 16 | "secrets": [], 17 | "notificationClients": [] 18 | } -------------------------------------------------------------------------------- /test/output/underline.tex.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 54, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 54, 10 | "expressions": [], 11 | "quasis": [ 12 | { 13 | "type": "TemplateElement", 14 | "start": 0, 15 | "end": 54, 16 | "value": { 17 | "raw": "\\text{This is some text \\underline{with an underline}}", 18 | "cooked": null 19 | }, 20 | "tail": true 21 | } 22 | ] 23 | }, 24 | "async": false, 25 | "generator": false, 26 | "tag": { 27 | "type": "CellTag", 28 | "start": 0, 29 | "end": 9, 30 | "body": { 31 | "type": "MemberExpression", 32 | "start": 0, 33 | "end": 9, 34 | "object": { 35 | "type": "Identifier", 36 | "start": 0, 37 | "end": 3, 38 | "name": "tex" 39 | }, 40 | "property": { 41 | "type": "Identifier", 42 | "start": 4, 43 | "end": 9, 44 | "name": "block" 45 | }, 46 | "computed": false, 47 | "optional": false 48 | }, 49 | "input": "tex.block", 50 | "async": false, 51 | "generator": false, 52 | "references": [ 53 | { 54 | "type": "Identifier", 55 | "start": 0, 56 | "end": 3, 57 | "name": "tex" 58 | } 59 | ], 60 | "fileAttachments": [], 61 | "databaseClients": [], 62 | "secrets": [], 63 | "notificationClients": [] 64 | }, 65 | "raw": true, 66 | "references": [], 67 | "fileAttachments": [], 68 | "databaseClients": [], 69 | "secrets": [], 70 | "notificationClients": [] 71 | } -------------------------------------------------------------------------------- /test/output/var-statement.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:0)", 5 | "pos": 0, 6 | "loc": { 7 | "line": 1, 8 | "column": 0 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/viewof-argument.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'viewof' (1:13)", 5 | "pos": 13, 6 | "loc": { 7 | "line": 1, 8 | "column": 13 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/viewof-assignment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Assigning to rvalue (2:2)", 5 | "pos": 4, 6 | "loc": { 7 | "line": 2, 8 | "column": 2 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/viewof-binding.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'viewof' (2:6)", 5 | "pos": 8, 6 | "loc": { 7 | "line": 2, 8 | "column": 6 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/viewof-block-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 39, 5 | "id": { 6 | "type": "ViewExpression", 7 | "start": 0, 8 | "end": 10, 9 | "id": { 10 | "type": "Identifier", 11 | "start": 7, 12 | "end": 10, 13 | "name": "foo" 14 | } 15 | }, 16 | "body": { 17 | "type": "BlockStatement", 18 | "start": 13, 19 | "end": 38, 20 | "body": [ 21 | { 22 | "type": "ReturnStatement", 23 | "start": 17, 24 | "end": 36, 25 | "argument": { 26 | "type": "CallExpression", 27 | "start": 24, 28 | "end": 35, 29 | "callee": { 30 | "type": "MemberExpression", 31 | "start": 24, 32 | "end": 33, 33 | "object": { 34 | "type": "Identifier", 35 | "start": 24, 36 | "end": 27, 37 | "name": "DOM" 38 | }, 39 | "property": { 40 | "type": "Identifier", 41 | "start": 28, 42 | "end": 33, 43 | "name": "input" 44 | }, 45 | "computed": false, 46 | "optional": false 47 | }, 48 | "arguments": [], 49 | "optional": false 50 | } 51 | } 52 | ] 53 | }, 54 | "async": false, 55 | "generator": false, 56 | "references": [ 57 | { 58 | "type": "Identifier", 59 | "start": 24, 60 | "end": 27, 61 | "name": "DOM" 62 | } 63 | ], 64 | "fileAttachments": [], 65 | "databaseClients": [], 66 | "secrets": [], 67 | "notificationClients": [] 68 | } -------------------------------------------------------------------------------- /test/output/viewof-expression-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 25, 5 | "id": { 6 | "type": "ViewExpression", 7 | "start": 0, 8 | "end": 10, 9 | "id": { 10 | "type": "Identifier", 11 | "start": 7, 12 | "end": 10, 13 | "name": "foo" 14 | } 15 | }, 16 | "body": { 17 | "type": "CallExpression", 18 | "start": 13, 19 | "end": 24, 20 | "callee": { 21 | "type": "MemberExpression", 22 | "start": 13, 23 | "end": 22, 24 | "object": { 25 | "type": "Identifier", 26 | "start": 13, 27 | "end": 16, 28 | "name": "DOM" 29 | }, 30 | "property": { 31 | "type": "Identifier", 32 | "start": 17, 33 | "end": 22, 34 | "name": "input" 35 | }, 36 | "computed": false, 37 | "optional": false 38 | }, 39 | "arguments": [], 40 | "optional": false 41 | }, 42 | "async": false, 43 | "generator": false, 44 | "references": [ 45 | { 46 | "type": "Identifier", 47 | "start": 13, 48 | "end": 16, 49 | "name": "DOM" 50 | } 51 | ], 52 | "fileAttachments": [], 53 | "databaseClients": [], 54 | "secrets": [], 55 | "notificationClients": [] 56 | } -------------------------------------------------------------------------------- /test/output/viewof-in-markdown.md.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 37, 5 | "id": null, 6 | "body": { 7 | "type": "TemplateLiteral", 8 | "start": 0, 9 | "end": 37, 10 | "expressions": [ 11 | { 12 | "type": "MemberExpression", 13 | "start": 16, 14 | "end": 34, 15 | "object": { 16 | "type": "Identifier", 17 | "start": 16, 18 | "end": 22, 19 | "name": "object" 20 | }, 21 | "property": { 22 | "type": "ViewExpression", 23 | "start": 23, 24 | "end": 33, 25 | "id": { 26 | "type": "Identifier", 27 | "start": 30, 28 | "end": 33, 29 | "name": "foo" 30 | } 31 | }, 32 | "computed": true, 33 | "optional": false 34 | } 35 | ], 36 | "quasis": [ 37 | { 38 | "type": "TemplateElement", 39 | "start": 0, 40 | "end": 14, 41 | "value": { 42 | "raw": "# `Code Title ", 43 | "cooked": null 44 | }, 45 | "tail": false 46 | }, 47 | { 48 | "type": "TemplateElement", 49 | "start": 35, 50 | "end": 37, 51 | "value": { 52 | "raw": "`\n", 53 | "cooked": null 54 | }, 55 | "tail": true 56 | } 57 | ] 58 | }, 59 | "async": false, 60 | "generator": false, 61 | "tag": { 62 | "type": "CellTag", 63 | "start": 0, 64 | "end": 2, 65 | "body": { 66 | "type": "Identifier", 67 | "start": 0, 68 | "end": 2, 69 | "name": "md" 70 | }, 71 | "input": "md", 72 | "async": false, 73 | "generator": false, 74 | "references": [ 75 | { 76 | "type": "Identifier", 77 | "start": 0, 78 | "end": 2, 79 | "name": "md" 80 | } 81 | ], 82 | "fileAttachments": [], 83 | "databaseClients": [], 84 | "secrets": [], 85 | "notificationClients": [] 86 | }, 87 | "raw": false, 88 | "references": [ 89 | { 90 | "type": "Identifier", 91 | "start": 16, 92 | "end": 22, 93 | "name": "object" 94 | }, 95 | { 96 | "type": "ViewExpression", 97 | "start": 23, 98 | "end": 33, 99 | "id": { 100 | "type": "Identifier", 101 | "start": 30, 102 | "end": 33, 103 | "name": "foo" 104 | } 105 | } 106 | ], 107 | "fileAttachments": [], 108 | "databaseClients": [], 109 | "secrets": [], 110 | "notificationClients": [] 111 | } -------------------------------------------------------------------------------- /test/output/viewof-internal-comment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 39, 5 | "id": { 6 | "type": "ViewExpression", 7 | "start": 0, 8 | "end": 24, 9 | "id": { 10 | "type": "Identifier", 11 | "start": 21, 12 | "end": 24, 13 | "name": "bar" 14 | } 15 | }, 16 | "body": { 17 | "type": "CallExpression", 18 | "start": 27, 19 | "end": 38, 20 | "callee": { 21 | "type": "MemberExpression", 22 | "start": 27, 23 | "end": 36, 24 | "object": { 25 | "type": "Identifier", 26 | "start": 27, 27 | "end": 30, 28 | "name": "DOM" 29 | }, 30 | "property": { 31 | "type": "Identifier", 32 | "start": 31, 33 | "end": 36, 34 | "name": "range" 35 | }, 36 | "computed": false, 37 | "optional": false 38 | }, 39 | "arguments": [], 40 | "optional": false 41 | }, 42 | "async": false, 43 | "generator": false, 44 | "references": [ 45 | { 46 | "type": "Identifier", 47 | "start": 27, 48 | "end": 30, 49 | "name": "DOM" 50 | } 51 | ], 52 | "fileAttachments": [], 53 | "databaseClients": [], 54 | "secrets": [], 55 | "notificationClients": [] 56 | } -------------------------------------------------------------------------------- /test/output/viewof-let.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected keyword 'viewof' (2:6)", 5 | "pos": 8, 6 | "loc": { 7 | "line": 2, 8 | "column": 6 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/viewof-member-expression.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 16, 5 | "id": null, 6 | "body": { 7 | "type": "MemberExpression", 8 | "start": 0, 9 | "end": 15, 10 | "object": { 11 | "type": "ViewExpression", 12 | "start": 0, 13 | "end": 10, 14 | "id": { 15 | "type": "Identifier", 16 | "start": 7, 17 | "end": 10, 18 | "name": "foo" 19 | } 20 | }, 21 | "property": { 22 | "type": "Identifier", 23 | "start": 11, 24 | "end": 15, 25 | "name": "name" 26 | }, 27 | "computed": false, 28 | "optional": false 29 | }, 30 | "async": false, 31 | "generator": false, 32 | "references": [ 33 | { 34 | "type": "ViewExpression", 35 | "start": 0, 36 | "end": 10, 37 | "id": { 38 | "type": "Identifier", 39 | "start": 7, 40 | "end": 10, 41 | "name": "foo" 42 | } 43 | } 44 | ], 45 | "fileAttachments": [], 46 | "databaseClients": [], 47 | "secrets": [], 48 | "notificationClients": [] 49 | } -------------------------------------------------------------------------------- /test/output/viewof-member.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:14)", 5 | "pos": 14, 6 | "loc": { 7 | "line": 1, 8 | "column": 14 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/viewof-orphan.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "type": "SyntaxError", 4 | "message": "Unexpected token (1:7)", 5 | "pos": 7, 6 | "loc": { 7 | "line": 1, 8 | "column": 7 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /test/output/viewof-property.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 23, 5 | "id": null, 6 | "body": { 7 | "type": "BinaryExpression", 8 | "start": 0, 9 | "end": 22, 10 | "left": { 11 | "type": "MemberExpression", 12 | "start": 0, 13 | "end": 18, 14 | "object": { 15 | "type": "Identifier", 16 | "start": 0, 17 | "end": 6, 18 | "name": "object" 19 | }, 20 | "property": { 21 | "type": "ViewExpression", 22 | "start": 7, 23 | "end": 17, 24 | "id": { 25 | "type": "Identifier", 26 | "start": 14, 27 | "end": 17, 28 | "name": "foo" 29 | } 30 | }, 31 | "computed": true, 32 | "optional": false 33 | }, 34 | "operator": "+", 35 | "right": { 36 | "type": "Literal", 37 | "start": 21, 38 | "end": 22, 39 | "value": 2, 40 | "raw": "2" 41 | } 42 | }, 43 | "async": false, 44 | "generator": false, 45 | "references": [ 46 | { 47 | "type": "Identifier", 48 | "start": 0, 49 | "end": 6, 50 | "name": "object" 51 | }, 52 | { 53 | "type": "ViewExpression", 54 | "start": 7, 55 | "end": 17, 56 | "id": { 57 | "type": "Identifier", 58 | "start": 14, 59 | "end": 17, 60 | "name": "foo" 61 | } 62 | } 63 | ], 64 | "fileAttachments": [], 65 | "databaseClients": [], 66 | "secrets": [], 67 | "notificationClients": [] 68 | } -------------------------------------------------------------------------------- /test/output/viewof-reference-internal-comment.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 25, 5 | "id": null, 6 | "body": { 7 | "type": "ViewExpression", 8 | "start": 0, 9 | "end": 24, 10 | "id": { 11 | "type": "Identifier", 12 | "start": 21, 13 | "end": 24, 14 | "name": "bar" 15 | } 16 | }, 17 | "async": false, 18 | "generator": false, 19 | "references": [ 20 | { 21 | "type": "ViewExpression", 22 | "start": 0, 23 | "end": 24, 24 | "id": { 25 | "type": "Identifier", 26 | "start": 21, 27 | "end": 24, 28 | "name": "bar" 29 | } 30 | } 31 | ], 32 | "fileAttachments": [], 33 | "databaseClients": [], 34 | "secrets": [], 35 | "notificationClients": [] 36 | } -------------------------------------------------------------------------------- /test/output/viewof-reference.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 21, 5 | "id": null, 6 | "body": { 7 | "type": "MemberExpression", 8 | "start": 0, 9 | "end": 20, 10 | "object": { 11 | "type": "ViewExpression", 12 | "start": 0, 13 | "end": 12, 14 | "id": { 15 | "type": "Identifier", 16 | "start": 7, 17 | "end": 12, 18 | "name": "input" 19 | } 20 | }, 21 | "property": { 22 | "type": "Identifier", 23 | "start": 13, 24 | "end": 20, 25 | "name": "tagName" 26 | }, 27 | "computed": false, 28 | "optional": false 29 | }, 30 | "async": false, 31 | "generator": false, 32 | "references": [ 33 | { 34 | "type": "ViewExpression", 35 | "start": 0, 36 | "end": 12, 37 | "id": { 38 | "type": "Identifier", 39 | "start": 7, 40 | "end": 12, 41 | "name": "input" 42 | } 43 | } 44 | ], 45 | "fileAttachments": [], 46 | "databaseClients": [], 47 | "secrets": [], 48 | "notificationClients": [] 49 | } -------------------------------------------------------------------------------- /test/output/yield-await.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 36, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 35, 10 | "body": [ 11 | { 12 | "type": "ExpressionStatement", 13 | "start": 4, 14 | "end": 16, 15 | "expression": { 16 | "type": "YieldExpression", 17 | "start": 4, 18 | "end": 15, 19 | "delegate": false, 20 | "argument": { 21 | "type": "Identifier", 22 | "start": 10, 23 | "end": 15, 24 | "name": "value" 25 | } 26 | } 27 | }, 28 | { 29 | "type": "ExpressionStatement", 30 | "start": 19, 31 | "end": 33, 32 | "expression": { 33 | "type": "AwaitExpression", 34 | "start": 19, 35 | "end": 32, 36 | "argument": { 37 | "type": "Identifier", 38 | "start": 25, 39 | "end": 32, 40 | "name": "promise" 41 | } 42 | } 43 | } 44 | ] 45 | }, 46 | "async": true, 47 | "generator": true, 48 | "references": [ 49 | { 50 | "type": "Identifier", 51 | "start": 10, 52 | "end": 15, 53 | "name": "value" 54 | }, 55 | { 56 | "type": "Identifier", 57 | "start": 25, 58 | "end": 32, 59 | "name": "promise" 60 | } 61 | ], 62 | "fileAttachments": [], 63 | "databaseClients": [], 64 | "secrets": [], 65 | "notificationClients": [] 66 | } -------------------------------------------------------------------------------- /test/output/yield-block-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 19, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 18, 10 | "body": [ 11 | { 12 | "type": "ExpressionStatement", 13 | "start": 4, 14 | "end": 16, 15 | "expression": { 16 | "type": "YieldExpression", 17 | "start": 4, 18 | "end": 15, 19 | "delegate": false, 20 | "argument": { 21 | "type": "Identifier", 22 | "start": 10, 23 | "end": 15, 24 | "name": "value" 25 | } 26 | } 27 | } 28 | ] 29 | }, 30 | "async": false, 31 | "generator": true, 32 | "references": [ 33 | { 34 | "type": "Identifier", 35 | "start": 10, 36 | "end": 15, 37 | "name": "value" 38 | } 39 | ], 40 | "fileAttachments": [], 41 | "databaseClients": [], 42 | "secrets": [], 43 | "notificationClients": [] 44 | } -------------------------------------------------------------------------------- /test/output/yield-expression-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 12, 5 | "id": null, 6 | "body": { 7 | "type": "YieldExpression", 8 | "start": 0, 9 | "end": 11, 10 | "delegate": false, 11 | "argument": { 12 | "type": "Identifier", 13 | "start": 6, 14 | "end": 11, 15 | "name": "value" 16 | } 17 | }, 18 | "async": false, 19 | "generator": true, 20 | "references": [ 21 | { 22 | "type": "Identifier", 23 | "start": 6, 24 | "end": 11, 25 | "name": "value" 26 | } 27 | ], 28 | "fileAttachments": [], 29 | "databaseClients": [], 30 | "secrets": [], 31 | "notificationClients": [] 32 | } -------------------------------------------------------------------------------- /test/output/yield-in-function.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 47, 5 | "id": null, 6 | "body": { 7 | "type": "BlockStatement", 8 | "start": 0, 9 | "end": 46, 10 | "body": [ 11 | { 12 | "type": "FunctionDeclaration", 13 | "start": 4, 14 | "end": 44, 15 | "id": { 16 | "type": "Identifier", 17 | "start": 14, 18 | "end": 19, 19 | "name": "inner" 20 | }, 21 | "expression": false, 22 | "generator": true, 23 | "async": false, 24 | "params": [], 25 | "body": { 26 | "type": "BlockStatement", 27 | "start": 22, 28 | "end": 44, 29 | "body": [ 30 | { 31 | "type": "ExpressionStatement", 32 | "start": 28, 33 | "end": 40, 34 | "expression": { 35 | "type": "YieldExpression", 36 | "start": 28, 37 | "end": 39, 38 | "delegate": false, 39 | "argument": { 40 | "type": "Identifier", 41 | "start": 34, 42 | "end": 39, 43 | "name": "value" 44 | } 45 | } 46 | } 47 | ] 48 | } 49 | } 50 | ] 51 | }, 52 | "async": false, 53 | "generator": false, 54 | "references": [ 55 | { 56 | "type": "Identifier", 57 | "start": 34, 58 | "end": 39, 59 | "name": "value" 60 | } 61 | ], 62 | "fileAttachments": [], 63 | "databaseClients": [], 64 | "secrets": [], 65 | "notificationClients": [] 66 | } -------------------------------------------------------------------------------- /test/output/yield-star-expression-cell.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Cell", 3 | "start": 0, 4 | "end": 14, 5 | "id": null, 6 | "body": { 7 | "type": "YieldExpression", 8 | "start": 0, 9 | "end": 13, 10 | "delegate": true, 11 | "argument": { 12 | "type": "Identifier", 13 | "start": 7, 14 | "end": 13, 15 | "name": "values" 16 | } 17 | }, 18 | "async": false, 19 | "generator": true, 20 | "references": [ 21 | { 22 | "type": "Identifier", 23 | "start": 7, 24 | "end": 13, 25 | "name": "values" 26 | } 27 | ], 28 | "fileAttachments": [], 29 | "databaseClients": [], 30 | "secrets": [], 31 | "notificationClients": [] 32 | } -------------------------------------------------------------------------------- /test/parse-test.js: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import * as fs from "fs"; 3 | import * as path from "path"; 4 | import {parseCell} from "@observablehq/parser"; 5 | 6 | (async () => { 7 | for (const file of fs.readdirSync(path.join("test", "input"))) { 8 | it(`parse ${file}`, () => { 9 | const extension = file.substring(file.indexOf(".")); // path.extname, but taking the first dot 10 | const infile = path.join("test", "input", file); 11 | const outfile = path.resolve(path.join("test", "output"), `${file}.json`); 12 | 13 | const input = fs.readFileSync(infile, "utf8"); 14 | let cell; 15 | try { 16 | cell = parseCell(input, { 17 | globals: null, 18 | tag: 19 | extension === ".sql" 20 | ? "db.sql" 21 | : extension === ".db.sql" 22 | ? `(await DatabaseClient("database")).sql` 23 | : extension === ".html" 24 | ? "htl.html" 25 | : extension === ".tex" 26 | ? "tex.block" 27 | : extension === ".md" 28 | ? "md" 29 | : undefined, 30 | raw: extension == ".tex" 31 | }); 32 | } catch (error) { 33 | if ( 34 | error instanceof ReferenceError || 35 | error instanceof SyntaxError || 36 | error instanceof TypeError 37 | ) { 38 | if (!error.loc) throw error; // internal unexpected error 39 | cell = { 40 | error: { 41 | type: error.constructor.name, 42 | message: error.message, 43 | pos: error.pos, 44 | loc: { 45 | line: error.loc.line, 46 | column: error.loc.column 47 | } 48 | } 49 | }; 50 | } else { 51 | throw error; 52 | } 53 | } 54 | 55 | const actual = JSON.stringify(cell, stringify, 2); 56 | 57 | let expected; 58 | try { 59 | expected = fs.readFileSync(outfile, "utf8"); 60 | } catch (error) { 61 | if (error.code === "ENOENT" && process.env.CI !== "true") { 62 | console.warn(`! generating ${outfile}`); 63 | fs.writeFileSync(outfile, actual, "utf8"); 64 | return; 65 | } else { 66 | throw error; 67 | } 68 | } 69 | 70 | assert.strictEqual(actual, expected, `${file} must match snapshot`); 71 | }); 72 | } 73 | })(); 74 | 75 | // Convert to a serializable representation. 76 | function stringify(key, value) { 77 | return typeof value === "bigint" ? value.toString() 78 | : value instanceof Map ? [...value] 79 | : value; 80 | } 81 | -------------------------------------------------------------------------------- /test/peek-test.js: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import {peekId} from "@observablehq/parser"; 3 | 4 | it("peekId", () => { 5 | assert.strictEqual(peekId("a = 1"), "a"); 6 | assert.strictEqual(peekId("viewof a = 1"), "a"); 7 | assert.strictEqual(peekId("mutable a = 1"), "a"); 8 | assert.strictEqual(peekId("mutable async = 1"), "async"); 9 | assert.strictEqual(peekId("class A {"), "A"); 10 | assert.strictEqual(peekId("class Z"), undefined); 11 | assert.strictEqual(peekId("class Z "), "Z"); 12 | assert.strictEqual(peekId("function a"), undefined); 13 | assert.strictEqual(peekId("function a()"), "a"); 14 | assert.strictEqual(peekId("async function a()"), "a"); 15 | assert.strictEqual(peekId("async function* a()"), "a"); 16 | assert.strictEqual(peekId("function* a"), undefined); 17 | assert.strictEqual(peekId("function /* yeah */ a()"), "a"); 18 | assert.strictEqual(peekId("function"), undefined); 19 | assert.strictEqual(peekId("1"), undefined); 20 | assert.strictEqual(peekId("#"), undefined, "Ignores syntax errors"); 21 | assert.strictEqual(peekId("abc /"), undefined, "Needs a = for a name to be identified"); 22 | assert.strictEqual(peekId("({ a: 1 })"), undefined); 23 | assert.strictEqual( 24 | peekId(`function queryAll(text, values) { 25 | return fetch("https://api.observable.localh`), 26 | "queryAll" 27 | ); 28 | }); 29 | -------------------------------------------------------------------------------- /test/references-test.js: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import {parseCell} from "@observablehq/parser"; 3 | import {Node} from "acorn"; 4 | 5 | function node(fields) { 6 | return Object.assign(Object.create(Node.prototype), fields); 7 | } 8 | 9 | it("finds references in expressions", () => { 10 | assert.deepStrictEqual(parseCell(`foo + bar`).references, [ 11 | node({type: "Identifier", start: 0, end: 3, name: "foo"}), 12 | node({type: "Identifier", start: 6, end: 9, name: "bar"}) 13 | ]); 14 | }); 15 | 16 | it("finds references in blocks", () => { 17 | assert.deepStrictEqual(parseCell(`{ foo + bar; }`).references, [ 18 | node({type: "Identifier", start: 2, end: 5, name: "foo"}), 19 | node({type: "Identifier", start: 8, end: 11, name: "bar"}) 20 | ]); 21 | }); 22 | 23 | it("finds viewof references", () => { 24 | assert.deepStrictEqual(parseCell(`viewof foo + bar`).references, [ 25 | node({ 26 | type: "ViewExpression", 27 | start: 0, 28 | end: 10, 29 | id: node({type: "Identifier", start: 7, end: 10, name: "foo"}) 30 | }), 31 | node({type: "Identifier", start: 13, end: 16, name: "bar"}) 32 | ]); 33 | }); 34 | 35 | it("finds mutable references", () => { 36 | assert.deepStrictEqual(parseCell(`mutable foo + bar`).references, [ 37 | node({ 38 | type: "MutableExpression", 39 | start: 0, 40 | end: 11, 41 | id: node({type: "Identifier", start: 8, end: 11, name: "foo"}) 42 | }), 43 | node({type: "Identifier", start: 14, end: 17, name: "bar"}) 44 | ]); 45 | }); 46 | 47 | it("finds multiple references", () => { 48 | assert.deepStrictEqual(parseCell(`cell = { 49 | const a = b + c; 50 | const d = c - b; 51 | }`).references, [ 52 | node({type: "Identifier", start: 21, end: 22, name: "b"}), 53 | node({type: "Identifier", start: 25, end: 26, name: "c"}), 54 | node({type: "Identifier", start: 40, end: 41, name: "c"}), 55 | node({type: "Identifier", start: 44, end: 45, name: "b"}) 56 | ]); 57 | }); 58 | 59 | it("doesn’t consider the identifier a reference", () => { 60 | assert.deepStrictEqual(parseCell(`foo = bar`).references, [ 61 | node({type: "Identifier", start: 6, end: 9, name: "bar"}) 62 | ]); 63 | }); 64 | 65 | it("local variables can mask references", () => { 66 | assert.deepStrictEqual(parseCell(`{ let foo; foo + bar; }`).references, [ 67 | node({type: "Identifier", start: 17, end: 20, name: "bar"}) 68 | ]); 69 | }); 70 | 71 | it("local variables can not mask references", () => { 72 | assert.deepStrictEqual(parseCell(`{ foo + bar; { let foo; } }`).references, [ 73 | node({type: "Identifier", start: 2, end: 5, name: "foo"}), 74 | node({type: "Identifier", start: 8, end: 11, name: "bar"}) 75 | ]); 76 | }); 77 | 78 | it("function parameters can mask references", () => { 79 | assert.deepStrictEqual(parseCell(`foo => foo + bar`).references, [ 80 | node({type: "Identifier", start: 13, end: 16, name: "bar"}) 81 | ]); 82 | }); 83 | 84 | it("function rest parameters can mask references", () => { 85 | assert.deepStrictEqual(parseCell(`(...foo) => foo + bar`).references, [ 86 | node({type: "Identifier", start: 18, end: 21, name: "bar"}) 87 | ]); 88 | }); 89 | 90 | it("destructured variables can mask references", () => { 91 | assert.deepStrictEqual(parseCell(`{ let {foo} = null; foo + bar; }`).references, [ 92 | node({type: "Identifier", start: 26, end: 29, name: "bar"}) 93 | ]); 94 | }); 95 | 96 | it("destructured rest variables can mask references", () => { 97 | assert.deepStrictEqual(parseCell(`{ let {...foo} = null; foo + bar; }`).references, [ 98 | node({type: "Identifier", start: 29, end: 32, name: "bar"}) 99 | ]); 100 | }); 101 | 102 | it("ignores globals", () => { 103 | assert.deepStrictEqual(parseCell(`foo + bar`, {globals: ["foo"]}).references, [ 104 | node({type: "Identifier", start: 6, end: 9, name: "bar"}) 105 | ]); 106 | }); 107 | --------------------------------------------------------------------------------