Skip to content

Commit 415b9ba

Browse files
Hans Halversonfacebook-github-bot
authored andcommitted
Add workspaces and prepare for publishing to NPM
Summary: An initial version of the `hermes-eslint` package is complete - let's get it ready for publishing to NPM. Now that we have multiple packages that depend on each other we should be using workspaces so that the dependency is resolved locally if the versions match. We also now need to actually specify versions so that `hermes-eslint` can depend on the latest version of `hermes-parser`. We can set this to `0.4.0` as this is the next version that will be released, which will be published once this diff is out. Now that we are using workspaces we no longer need to `yarn install` for each package - a `yarn install` in the root workspace will install all packages in the workspace. Let's also add a basic README mentioning how to use `hermes-eslint` and what options are allowed. Reviewed By: pieterv Differential Revision: D26291161 fbshipit-source-id: aae927c0716cfd3cfbea4f924ddf9bfc5ce17d0d
1 parent 566b829 commit 415b9ba

6 files changed

Lines changed: 48 additions & 12 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# hermes-eslint
2+
A custom parser for [ESLint](https://eslint.org/) built from the Hermes engine's parser compiled to WebAssembly. The Hermes parser supports ES6, Flow, and JSX syntax, which are parsed into an ESTree AST and then analyzed to determine scope information in a format that can be consumed by ESLint.
3+
4+
## Usage
5+
The `hermes-eslint` package is a [custom parser](https://eslint.org/docs/developer-guide/working-with-custom-parsers) for ESLint. To use `hermes-eslint` as the parser for ESLint in your project you must specify `"hermes-eslint"` as the `"parser"` in your ESLint configuration file:
6+
7+
**.eslintrc**
8+
```js
9+
{
10+
"parser": "hermes-parser"
11+
}
12+
```
13+
14+
The ESLint documentation provides more information about [how to configure ESLint](https://eslint.org/docs/user-guide/configuring/), including [how to specify a custom parser](https://eslint.org/docs/user-guide/configuring/plugins#specifying-parser).
15+
16+
### Options
17+
18+
You may provide additional configuration for `hermes-eslint` by passing an object containing configuration options as the `"parserOptions"` in your ESLint configuration file. This object may contain the following properties:
19+
- **sourceType**: `"module"` or `"script"`, defaults to `"module"`
20+
21+
**.eslintrc**
22+
```js
23+
{
24+
"parser": "hermes-parser",
25+
"parserOptions": {
26+
"sourceType": "module"
27+
}
28+
}
29+
```

tools/hermes-parser/js/hermes-eslint/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "hermes-eslint",
3-
"private": true,
4-
"version": "%VERSION%",
3+
"version": "0.4.0",
54
"description": "A custom parser for ESLint using the Hermes parser",
65
"main": "dist/index.js",
76
"license": "MIT",
@@ -14,6 +13,7 @@
1413
],
1514
"dependencies": {
1615
"esrecurse": "^4.3.0",
17-
"estraverse": "^4.1.1"
16+
"estraverse": "^4.1.1",
17+
"hermes-parser": "0.4.0"
1818
}
1919
}

tools/hermes-parser/js/hermes-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hermes-parser",
3-
"version": "%VERSION%",
3+
"version": "0.4.0",
44
"description": "A JavaScript parser built from the Hermes engine",
55
"main": "dist/index.js",
66
"license": "MIT",

tools/hermes-parser/js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "hermes-parser-packages",
33
"private": true,
4-
"version": "0.0.0",
54
"devDependencies": {
65
"@babel/core": "7.12.10",
76
"@babel/cli": "7.12.10",
@@ -12,5 +11,6 @@
1211
"scripts": {
1312
"build": "./scripts/build.sh",
1413
"test": "jest"
15-
}
14+
},
15+
"workspaces": ["hermes-eslint", "hermes-parser"]
1616
}

tools/hermes-parser/js/scripts/build.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ PACKAGES=(hermes-parser hermes-eslint)
1010

1111
# Yarn install all packages
1212
yarn install
13-
for package in "${PACKAGES[@]}"; do
14-
pushd "$THIS_DIR/../$package" || exit
15-
yarn install
16-
popd || exit
17-
done
1813

1914
# Use internal FB build or pass path to WASM parser as first command line argument
2015
FB_BUILD_WASM_PARSER="$THIS_DIR/facebook/buildWasmParser.sh"

tools/hermes-parser/js/yarn.lock

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1900,11 +1900,23 @@ esprima@^4.0.0, esprima@^4.0.1:
19001900
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
19011901
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
19021902

1903-
estraverse@^4.2.0:
1903+
esrecurse@^4.3.0:
1904+
version "4.3.0"
1905+
resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921"
1906+
integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==
1907+
dependencies:
1908+
estraverse "^5.2.0"
1909+
1910+
estraverse@^4.1.1, estraverse@^4.2.0:
19041911
version "4.3.0"
19051912
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d"
19061913
integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==
19071914

1915+
estraverse@^5.2.0:
1916+
version "5.2.0"
1917+
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880"
1918+
integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==
1919+
19081920
esutils@^2.0.2:
19091921
version "2.0.3"
19101922
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"

0 commit comments

Comments
 (0)