hermes-eslint
Advanced tools
Comparing version 0.17.1 to 0.18.0
@@ -239,5 +239,36 @@ /** | ||
///////////////////// | ||
visitJSXTag(node) { | ||
const rootName = getJsxName(node.name); | ||
if (this._fbtSupport !== true || !FBT_NAMES.has(rootName)) { | ||
// <fbt /> does not reference the jsxPragma, but instead references the fbt import | ||
this._referenceJsxPragma(); | ||
} | ||
switch (node.name.type) { | ||
case 'JSXIdentifier': | ||
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, | ||
// not a variable by JSX transforms: | ||
// <div /> => React.createElement("div", null) | ||
this.visit(node.name); | ||
} | ||
break; | ||
case 'JSXMemberExpression': | ||
case 'JSXNamespacedName': | ||
// special case for <this.Foo /> - we don't want to create an unclosed | ||
// and impossible-to-resolve reference to a variable called `this`. | ||
if (rootName !== 'this') { | ||
this.visit(node.name); | ||
} | ||
break; | ||
} | ||
} ///////////////////// | ||
// Visit selectors // | ||
///////////////////// | ||
ArrowFunctionExpression(node) { | ||
@@ -430,3 +461,14 @@ this.visitFunction(node); | ||
JSXClosingElement(_) {// should not be counted as a reference | ||
JSXClosingElement(node) { | ||
/** | ||
* Note that this was not previously considered to be a reference and that | ||
* other scope analyzers do not count them either: e.g. TypeScript-eslint | ||
* https://fburl.com/4q93a3x3 | ||
* | ||
* We are considering this a reference because it technically includes an | ||
* identifier that refers to a defined variable. So, if you want to answer: | ||
* "what are all of the references to this variable?", the closing element | ||
* should be included. | ||
*/ | ||
this.visitJSXTag(node); | ||
} | ||
@@ -456,31 +498,4 @@ | ||
JSXOpeningElement(node) { | ||
const rootName = getJsxName(node.name); | ||
this.visitJSXTag(node); // the opening tag may also have type args and attributes | ||
if (this._fbtSupport !== true || !FBT_NAMES.has(rootName)) { | ||
// <fbt /> does not reference the jsxPragma, but instead references the fbt import | ||
this._referenceJsxPragma(); | ||
} | ||
switch (node.name.type) { | ||
case 'JSXIdentifier': | ||
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, | ||
// not a variable by JSX transforms: | ||
// <div /> => React.createElement("div", null) | ||
this.visit(node.name); | ||
} | ||
break; | ||
case 'JSXMemberExpression': | ||
case 'JSXNamespacedName': | ||
// special case for <this.Foo /> - we don't want to create an unclosed | ||
// and impossible-to-resolve reference to a variable called `this`. | ||
if (rootName !== 'this') { | ||
this.visit(node.name); | ||
} | ||
break; | ||
} | ||
this.visitType(node.typeArguments); | ||
@@ -487,0 +502,0 @@ |
{ | ||
"name": "hermes-eslint", | ||
"version": "0.17.1", | ||
"version": "0.18.0", | ||
"description": "A custom parser for ESLint using the Hermes parser", | ||
@@ -19,5 +19,5 @@ "main": "dist/index.js", | ||
"esrecurse": "^4.3.0", | ||
"hermes-estree": "0.17.1", | ||
"hermes-parser": "0.17.1" | ||
"hermes-estree": "0.18.0", | ||
"hermes-parser": "0.18.0" | ||
} | ||
} |
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
248896
3367
+ Addedhermes-estree@0.18.0(transitive)
+ Addedhermes-parser@0.18.0(transitive)
- Removedhermes-estree@0.17.1(transitive)
- Removedhermes-parser@0.17.1(transitive)
Updatedhermes-estree@0.18.0
Updatedhermes-parser@0.18.0