hermes-eslint
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -52,3 +52,5 @@ /** | ||
if (e instanceof SyntaxError) { | ||
e.lineNumber = e.loc.line; | ||
// $FlowFixMe[prop-missing] | ||
e.lineNumber = e.loc.line; // $FlowFixMe[prop-missing] | ||
e.column = e.loc.column; | ||
@@ -55,0 +57,0 @@ } |
@@ -51,2 +51,4 @@ /** | ||
const FBT_NAMES = new Set(['fbt', 'fbs']); | ||
// Referencing variables and creating bindings. | ||
@@ -430,3 +432,3 @@ class Referencer extends _Visitor.Visitor { | ||
if (rootName !== 'fbt' || this._fbtSupport !== true) { | ||
if (this._fbtSupport !== true || !FBT_NAMES.has(rootName)) { | ||
// <fbt /> does not reference the jsxPragma, but instead references the fbt import | ||
@@ -438,3 +440,3 @@ this._referenceJsxPragma(); | ||
case 'JSXIdentifier': | ||
if (rootName[0].toUpperCase() === rootName[0] || rootName === 'fbt' && this._fbtSupport === true) { | ||
if (rootName[0].toUpperCase() === rootName[0] || this._fbtSupport === true && FBT_NAMES.has(rootName)) { | ||
// lower cased component names are always treated as "intrinsic" names, and are converted to a string, | ||
@@ -441,0 +443,0 @@ // not a variable by JSX transforms: |
@@ -171,2 +171,3 @@ /** | ||
this.visit(node.typeParameters); | ||
this.visit(node.this); | ||
this.visitArray(node.params); | ||
@@ -173,0 +174,0 @@ this.visit(node.returnType); |
@@ -50,4 +50,5 @@ /** | ||
} | ||
} | ||
} // $FlowFixMe[incompatible-type] We know this value is an array at this point. | ||
this.__implicit.referencesLeftToResolve = this.__referencesLeftToResolve; | ||
@@ -54,0 +55,0 @@ return super.close(scopeManager); |
@@ -252,6 +252,6 @@ /** | ||
do { | ||
while (current) { | ||
current.through.push(ref); | ||
current = current.upper; | ||
} while (current); | ||
} | ||
}; | ||
@@ -258,0 +258,0 @@ |
{ | ||
"name": "hermes-eslint", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "A custom parser for ESLint using the Hermes parser", | ||
@@ -12,9 +12,12 @@ "main": "dist/index.js", | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"LICENCE", | ||
"TYPESCRIPT_ESLINT_SCOPE_MANAGER_LICENSE", | ||
"README.md" | ||
], | ||
"dependencies": { | ||
"esrecurse": "^4.3.0", | ||
"hermes-estree": "0.8.0", | ||
"hermes-parser": "0.8.0" | ||
"hermes-estree": "0.9.0", | ||
"hermes-parser": "0.9.0" | ||
} | ||
} |
# hermes-eslint | ||
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. | ||
`hermes-eslint` is a custom parser for [ESLint](https://eslint.org/). It is the recommended parser for use for linting with Flow code. | ||
## Usage | ||
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: | ||
**.eslintrc** | ||
```js | ||
To use `hermes-eslint` as the parser for ESLint in your project you must specify `"hermes-eslint"` as the `"parser"` in your `.eslintrc` configuration file: | ||
```json | ||
{ | ||
"parser": "hermes-parser" | ||
"parser": "hermes-eslint" | ||
} | ||
@@ -19,8 +20,44 @@ ``` | ||
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: | ||
- **sourceType**: `"module"` or `"script"`, defaults to `"module"` | ||
**.eslintrc** | ||
```js | ||
```ts | ||
type ParserOptions = { | ||
/** | ||
* The identifier that's used for JSX Element creation (after transpilation). | ||
* This should not be a member expression - just the root identifier (i.e. use "React" instead of "React.createElement"). | ||
* | ||
* To use the new global JSX transform function, you can explicitly set this to `null`. | ||
* | ||
* Defaults to `"React"`. | ||
*/ | ||
jsxPragma?: string | null, | ||
/** | ||
* The identifier that's used for JSX fragment elements (after transpilation). | ||
* If `null`, assumes transpilation will always use a member on `jsxFactory` (i.e. React.Fragment). | ||
* This should not be a member expression - just the root identifier (i.e. use "h" instead of "h.Fragment"). | ||
* | ||
* Defaults to `null`. | ||
*/ | ||
jsxFragmentName?: string | null, | ||
/** | ||
* The source type of the script. | ||
* | ||
* Defaults to `"module"`. | ||
*/ | ||
sourceType?: 'script' | 'module', | ||
/** | ||
* Ignore <fbt /> JSX elements when adding references to the module-level `React` variable. | ||
* FBT is JSX that's transformed to non-JSX and thus references differently | ||
* | ||
* https://facebook.github.io/fbt/ | ||
*/ | ||
fbt?: boolean, | ||
}; | ||
``` | ||
```json | ||
{ | ||
"parser": "hermes-parser", | ||
"parser": "hermes-eslint", | ||
"parserOptions": { | ||
@@ -27,0 +64,0 @@ "sourceType": "module" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
239496
111
3335
67
+ Addedhermes-estree@0.9.0(transitive)
+ Addedhermes-parser@0.9.0(transitive)
- Removedhermes-estree@0.8.0(transitive)
- Removedhermes-parser@0.8.0(transitive)
Updatedhermes-estree@0.9.0
Updatedhermes-parser@0.9.0