Skip to content

Commit 23025bc

Browse files
authored
acorn 8, esm, mocha (#205)
* remove husky * adopt esm, mocha * acorn 8 * restore .db.sql test * simpler serialization * re-enable reference tests * add private field test * restore peekId * yarn upgrade * remove unused rollup plugins * remove sublime project * test Markdown interpolation
1 parent a9da65a commit 23025bc

File tree

179 files changed

+8598
-10741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+8598
-10741
lines changed

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
dist/
2-
test/
3-
tap-snapshots/
2+
test/input/

.eslintrc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
"extends": "eslint:recommended",
33
"parserOptions": {
44
"sourceType": "module",
5-
"ecmaVersion": 2018
5+
"ecmaVersion": 2020
66
},
77
"env": {
88
"es6": true,
99
"node": true
1010
},
1111
"rules": {
12-
"semi": 2,
1312
"no-cond-assign": 0,
14-
"no-process-env": 2,
1513
"no-var": 2,
14+
"comma-dangle": ["error", "never"],
15+
"semi": [2, "always"],
1616
"quotes": ["error", "double", {"allowTemplateLiterals": true}]
1717
}
1818
}

.github/eslint.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

.github/workflows/nodejs.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
name: Node CI
1+
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
22

3-
on: [push]
3+
name: Node.js CI
4+
5+
on:
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
410

511
jobs:
612
build:
713

14+
runs-on: ubuntu-latest
15+
816
strategy:
917
matrix:
10-
os: [ubuntu-latest]
11-
node-version: [10.x, 12.x]
12-
13-
runs-on: ${{ matrix.os }}
18+
node-version: [14.x]
1419

1520
steps:
16-
- uses: actions/checkout@v1
21+
- uses: actions/checkout@v2
1722
- name: Use Node.js ${{ matrix.node-version }}
1823
uses: actions/setup-node@v1
1924
with:
2025
node-version: ${{ matrix.node-version }}
21-
- name: yarn install and test
22-
run: |
23-
yarn install --frozen-lockfile
24-
yarn test
25-
env:
26-
CI: true
26+
- run: yarn --frozen-lockfile
27+
- run: |
28+
echo ::add-matcher::.github/eslint.json
29+
yarn run eslint . --format=compact
30+
- run: yarn test

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
*.sublime-workspace
21
.DS_Store
3-
.nyc_output
42
dist/
5-
node_modules
6-
npm-debug.log
7-
.idea
3+
node_modules/

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# @observablehq/parser
22

3-
[![Node CI](https://github.com/observablehq/parser/workflows/Node%20CI/badge.svg)](https://github.com/observablehq/parser/actions?workflow=Node+CI)
4-
53
To parse a cell:
64

75
```js
@@ -423,15 +421,11 @@ Injecting a view injects both the view symbol (`viewof foo`) and the value symbo
423421

424422
## API Reference
425423

426-
<a href="#parseCell" name="parseCell">#</a> <b>parseCell</b>(<i>input</i>[, <i>options</i>]) [<>](https://github.com/observablehq/parser/blob/master/src/parse.js "Source")
424+
<a href="#parseCell" name="parseCell">#</a> <b>parseCell</b>(<i>input</i>[, <i>options</i>]) [<>](https://github.com/observablehq/parser/blob/main/src/parse.js "Source")
427425

428426
Returns a [cell](#cell).
429427

430-
<a href="#parseModule" name="parseModule">#</a> <b>parseModule</b>(<i>input</i>[, <i>options</i>]) [<>](https://github.com/observablehq/parser/blob/master/src/parse.js "Source")
431-
432-
Returns a [program](#program).
433-
434-
<a href="#peekId" name="peekId">#</a> <b>peekId</b>(<i>input</i>) [<>](https://github.com/observablehq/parser/blob/master/src/parse.js "Source")
428+
<a href="#peekId" name="peekId">#</a> <b>peekId</b>(<i>input</i>) [<>](https://github.com/observablehq/parser/blob/main/src/peek.js "Source")
435429

436430
Tries to find the ID of a cell given a snippet of its contents, and returns it as a string if found.
437431

package.json

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,52 @@
11
{
22
"name": "@observablehq/parser",
3+
"description": "An Acorn parser for Observable JavaScript",
34
"version": "5.0.0",
4-
"license": "ISC",
5-
"main": "dist/parser.min.js",
6-
"module": "src/index.js",
75
"author": {
86
"name": "Observable, Inc.",
97
"url": "https://observablehq.com"
108
},
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+
},
1119
"repository": {
1220
"type": "git",
1321
"url": "https://github.com/observablehq/parser.git"
1422
},
23+
"files": [
24+
"dist/**/*.js",
25+
"src/**/*.js"
26+
],
27+
"engines": {
28+
"node": ">=14.5.0"
29+
},
1530
"scripts": {
16-
"test": "eslint . && tap 'test/**/*-test.js'",
17-
"snapshot": "TAP_SNAPSHOT=1 tap 'test/**/*-test.js'",
31+
"test": "mkdir -p test/output && mocha -r module-alias/register 'test/**/*-test.js' && eslint src test",
1832
"prepublishOnly": "rm -rf dist && rollup -c",
1933
"postpublish": "git push && git push --tags"
2034
},
21-
"husky": {
22-
"hooks": {
23-
"pre-commit": "yarn test"
24-
}
35+
"_moduleAliases": {
36+
"@observablehq/parser": "./src/index.js"
2537
},
2638
"dependencies": {
27-
"acorn": "^7.1.1",
28-
"acorn-walk": "^7.0.0"
39+
"acorn": "8",
40+
"acorn-walk": "8"
2941
},
3042
"devDependencies": {
31-
"eslint": "^6.7.2",
32-
"esm": "^3.0.84",
33-
"rollup": "^2.26.11",
34-
"rollup-plugin-commonjs": "^10.1.0",
35-
"rollup-plugin-node-resolve": "^5.0.0",
36-
"rollup-plugin-terser": "^7.0.2",
37-
"tap": "^14.10.2",
38-
"husky": "^3.1.0"
43+
"eslint": "8",
44+
"mocha": "9",
45+
"module-alias": "2",
46+
"rollup": "2",
47+
"rollup-plugin-terser": "7"
3948
},
40-
"files": [
41-
"dist/**/*.js",
42-
"src/**/*.js"
43-
]
49+
"publishConfig": {
50+
"access": "public"
51+
}
4452
}

parser.sublime-project

Lines changed: 0 additions & 24 deletions
This file was deleted.

rollup.config.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import commonjs from "rollup-plugin-commonjs";
2-
import node from "rollup-plugin-node-resolve";
31
import {terser} from "rollup-plugin-terser";
42
import * as meta from "./package.json";
53

@@ -9,8 +7,6 @@ export default [
97
{
108
input: "src/index.js",
119
plugins: [
12-
node(),
13-
commonjs(),
1410
terser({
1511
output: {preamble: copyright},
1612
mangle: {reserved: ["RequireError"]}

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
export {parseCell, peekId, CellParser, TemplateCellParser, parseModule, ModuleParser} from "./parse.js";
1+
export {parseCell, CellParser, TemplateCellParser} from "./parse.js";
2+
export {peekId} from "./peek.js";
23
export {default as walk} from "./walk.js";

0 commit comments

Comments
 (0)