hermes-eslint
Advanced tools
Comparing version 0.11.1 to 0.12.0
@@ -31,3 +31,3 @@ /** | ||
function parse(code, options) { | ||
var _options$sourceType; | ||
var _options$sourceType, _options$enableExperi; | ||
@@ -38,3 +38,4 @@ const parserOptions = { | ||
sourceType: (_options$sourceType = options == null ? void 0 : options.sourceType) != null ? _options$sourceType : 'module', | ||
tokens: true | ||
tokens: true, | ||
enableExperimentalComponentSyntax: (_options$enableExperi = options == null ? void 0 : options.enableExperimentalComponentSyntax) != null ? _options$enableExperi : false | ||
}; | ||
@@ -41,0 +42,0 @@ |
@@ -24,2 +24,3 @@ /** | ||
ClassName: null, | ||
ComponentName: null, | ||
Enum: null, | ||
@@ -26,0 +27,0 @@ FunctionName: null, |
@@ -24,2 +24,10 @@ /** | ||
var _ComponentNameDefinition = require("./ComponentNameDefinition"); | ||
Object.keys(_ComponentNameDefinition).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _ComponentNameDefinition[key]) return; | ||
exports[key] = _ComponentNameDefinition[key]; | ||
}); | ||
var _ClassNameDefinition = require("./ClassNameDefinition"); | ||
@@ -26,0 +34,0 @@ |
@@ -361,2 +361,37 @@ /** | ||
ComponentDeclaration(node) { | ||
const id = node.id; // id is defined in upper scope | ||
this.currentScope().defineIdentifier(id, new _definition.ComponentNameDefinition(id, node)); | ||
this.scopeManager.nestComponentScope(node); // component type parameters can be referenced by component params, so have to be declared first | ||
this.visitType(node.typeParameters); // Renders type may reference type parameters but not component parameters, so visit it before the parameters | ||
this.visitType(node.rendersType); // Process parameter declarations. | ||
for (const param of node.params) { | ||
const paramPattern = (() => { | ||
switch (param.type) { | ||
case 'ComponentParameter': | ||
return param.local; | ||
case 'RestElement': | ||
return param; | ||
} | ||
})(); | ||
this.visitPattern(paramPattern, (pattern, info) => { | ||
this.currentScope().defineIdentifier(pattern, new _definition.ParameterDefinition(pattern, node, info.rest)); | ||
this.referencingDefaultValue(pattern, info.assignments, null, true); | ||
}, typeAnnotation => { | ||
this.visitType(typeAnnotation); | ||
}, { | ||
processRightHandNodes: true | ||
}); | ||
} | ||
this.visitChildren(node.body); | ||
this.close(node); | ||
} | ||
FunctionDeclaration(node) { | ||
@@ -579,2 +614,6 @@ this.visitFunction(node); | ||
DeclareComponent(node) { | ||
this.visitType(node); | ||
} | ||
DeclareFunction(node) { | ||
@@ -581,0 +620,0 @@ this.visitType(node); |
@@ -132,2 +132,16 @@ /** | ||
DeclareComponent(node) { | ||
this._referencer.currentScope().defineIdentifier(node.id, new _definition.ComponentNameDefinition(node.id, node)); | ||
const hasTypeScope = this.maybeCreateTypeScope(node); | ||
this.visit(node.typeParameters); | ||
this.visitArray(node.params); | ||
this.visit(node.rest); | ||
this.visit(node.rendersType); | ||
if (hasTypeScope) { | ||
this._referencer.close(node); | ||
} | ||
} | ||
DeclareFunction(node) { | ||
@@ -189,2 +203,21 @@ this._referencer.currentScope().defineIdentifier(node.id, new _definition.FunctionNameDefinition(node.id, node)); // the function type is stored as an annotation on the ID | ||
ComponentTypeAnnotation(node) { | ||
const hasTypeScope = this.maybeCreateTypeScope(node); | ||
this.visit(node.typeParameters); | ||
this.visitArray(node.params); | ||
this.visit(node.rest); | ||
this.visit(node.rendersType); | ||
if (hasTypeScope) { | ||
this._referencer.close(node); | ||
} | ||
} | ||
ComponentTypeParameter(node) { | ||
// Do not visit 'name' child to prevent name from being treated as a reference. | ||
// e.g. 'foo' is a parameter name in a type that should not be treated like a | ||
// definition or reference in `type T = component(foo: string)`. | ||
this.visit(node.typeAnnotation); | ||
} | ||
GenericTypeAnnotation(node) { | ||
@@ -191,0 +224,0 @@ this.visit(node.id); |
@@ -32,2 +32,10 @@ /** | ||
var _ComponentScope = require("./ComponentScope"); | ||
Object.keys(_ComponentScope).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _ComponentScope[key]) return; | ||
exports[key] = _ComponentScope[key]; | ||
}); | ||
var _ClassFieldInitializerScope = require("./ClassFieldInitializerScope"); | ||
@@ -34,0 +42,0 @@ |
@@ -19,2 +19,3 @@ /** | ||
Catch: 'catch', | ||
Component: 'component', | ||
Class: 'class', | ||
@@ -21,0 +22,0 @@ ClassFieldInitializer: 'class-field-initializer', |
@@ -207,2 +207,6 @@ /** | ||
nestComponentScope(node) { | ||
return this._nestScope(new _scope.ComponentScope(this, this._assertCurrentScope(), node)); | ||
} | ||
nestFunctionScope(node, isMethodDefinition) { | ||
@@ -209,0 +213,0 @@ return this._nestScope(new _scope.FunctionScope(this, this._assertCurrentScope(), node, isMethodDefinition)); |
{ | ||
"name": "hermes-eslint", | ||
"version": "0.11.1", | ||
"version": "0.12.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.11.1", | ||
"hermes-parser": "0.11.1" | ||
"hermes-estree": "0.12.0", | ||
"hermes-parser": "0.12.0" | ||
} | ||
} |
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
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
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
247418
113
3350
+ Addedhermes-estree@0.12.0(transitive)
+ Addedhermes-parser@0.12.0(transitive)
- Removedhermes-estree@0.11.1(transitive)
- Removedhermes-parser@0.11.1(transitive)
Updatedhermes-estree@0.12.0
Updatedhermes-parser@0.12.0