Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hermes-eslint

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hermes-eslint - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

10

dist/HermesESLintVisitorKeys.js

@@ -9,3 +9,10 @@ /**

* @format
* @generated
*/
/*
* !!! GENERATED FILE !!!
*
* Any manual changes to this file will be overwritten. To regenerate run `yarn build`.
*/
// lint directives to let us do some basic validation of generated files

@@ -28,2 +35,3 @@

BigIntLiteralTypeAnnotation: [],
BigIntTypeAnnotation: [],
BinaryExpression: ['left', 'right'],

@@ -134,3 +142,3 @@ BlockStatement: ['body'],

Property: ['key', 'value'],
PropertyDefinition: ['key', 'value', 'variance', 'typeAnnotation'],
PropertyDefinition: ['key', 'value', 'variance', 'typeAnnotation', 'tsModifiers'],
QualifiedTypeIdentifier: ['qualification', 'id'],

@@ -137,0 +145,0 @@ RestElement: ['argument'],

@@ -63,3 +63,13 @@ /**

function parseForESLint(code, options) {
const ast = parse(code, options);
const ast = parse(code, options); // set the parent pointers
HermesParser.SimpleTraverser.traverse(ast, {
enter(node, parent) {
// $FlowExpectedError[cannot-write]
node.parent = parent;
},
leave() {}
});
const scopeManager = (0, _scopeManager.analyze)(ast, options);

@@ -66,0 +76,0 @@ return {

41

dist/scope-manager/referencer/Referencer.js

@@ -67,4 +67,2 @@ /**

this._fbtSupport = void 0;
this._hasReferencedJsxFactory = false;
this._hasReferencedJsxFragmentFactory = false;
this.scopeManager = void 0;

@@ -108,39 +106,21 @@

}
/**
* Searches for a variable named "name" in the upper scopes and adds a pseudo-reference from itself to itself
*/
_referenceJsxPragma() {
const jsxPragma = this._jsxPragma;
_referenceInSomeUpperScope(name) {
let scope = this.scopeManager.currentScope;
while (scope) {
const variable = scope.set.get(name);
if (!variable) {
scope = scope.upper;
continue;
}
scope.referenceValue(variable.identifiers[0]);
return true;
}
return false;
}
_referenceJsxPragma() {
if (this._jsxPragma == null || this._hasReferencedJsxFactory) {
if (jsxPragma == null) {
return;
}
this._hasReferencedJsxFactory = this._referenceInSomeUpperScope(this._jsxPragma);
this.currentScope().indirectlyReferenceValue(jsxPragma);
}
_referenceJsxFragment() {
if (this._jsxFragmentName == null || this._hasReferencedJsxFragmentFactory) {
const jsxFragmentName = this._jsxFragmentName;
if (jsxFragmentName == null) {
return;
}
this._hasReferencedJsxFragmentFactory = this._referenceInSomeUpperScope(this._jsxFragmentName);
this.currentScope().indirectlyReferenceValue(jsxFragmentName);
} ///////////////////

@@ -430,2 +410,7 @@ // Visit helpers //

JSXNamespacedName(node) {
this.visit(node.namespace); // namespace:name
// the "name" doesn't reference a variable so it should be ignored, like a member expression
}
JSXOpeningElement(node) {

@@ -432,0 +417,0 @@ const rootName = getJsxName(node.name);

@@ -41,5 +41,6 @@ /**

for (const ref of this.__referencesLeftToResolve) {
if (ref.maybeImplicitGlobal && !this.set.has(ref.identifier.name)) {
const info = ref.maybeImplicitGlobal;
if (info && !this.set.has(ref.identifier.name)) {
// create an implicit global variable from assignment expression
const info = ref.maybeImplicitGlobal;
const node = info.pattern;

@@ -46,0 +47,0 @@

@@ -21,2 +21,4 @@ /**

var _DefinitionType = require("../definition/DefinitionType");
class ModuleScope extends _ScopeBase.ScopeBase {

@@ -27,4 +29,35 @@ constructor(scopeManager, upperScope, block) {

close(scopeManager) {
const result = super.close(scopeManager); // handle this case:
/*
declare function foo(): void;
declare function foo(arg: string): string;
export function foo(arg?: string) {
return arg;
}
*/
for (const variable of this.variables) {
if (variable.defs.length <= 1) {
continue;
}
for (const def of variable.defs) {
if (def.type !== _DefinitionType.DefinitionType.FunctionName) {
break;
}
if (def.node.type === 'FunctionDeclaration' && (def.node.parent.type === 'ExportNamedDeclaration' || def.node.parent.type === 'ExportDefaultDeclaration')) {
variable.eslintUsed = true;
break;
}
}
}
return result;
}
}
exports.ModuleScope = ModuleScope;

@@ -200,2 +200,7 @@ /**

*/
/**
* The names that are indirectly referenced within this scope.
* @private
*/
constructor(_scopeManager, type, upperScope, block, isMethodDefinition) {

@@ -217,2 +222,3 @@ this.$id = generator();

this.variableScope = void 0;
this.__indirectReferences = new Set();

@@ -344,2 +350,26 @@ this._staticCloseRef = (ref, _) => {

this.__referencesLeftToResolve = null;
if (this.__indirectReferences.size > 0) {
const upper = this.upper;
for (const name of this.__indirectReferences) {
const variable = this.set.get(name);
if (variable) {
variable.eslintUsed = true;
this.__indirectReferences.delete(name);
continue;
} // delegate it to the upper scope
if (upper) {
upper.__indirectReferences.add(name);
this.__indirectReferences.delete(name);
}
}
}
return this.upper;

@@ -423,3 +453,13 @@ }

}
/**
* Creates an indirect reference to a given `name` `from` the given location
* This is useful when a build process is expected to create a reference to
* the name, for example - the JSX transform that references a JSX pragma (React)
*/
indirectlyReferenceValue(name) {
this.__indirectReferences.add(name);
}
referenceType(node) {

@@ -426,0 +466,0 @@ var _this$__referencesLef2;

{
"name": "hermes-eslint",
"version": "0.9.0",
"version": "0.10.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.9.0",
"hermes-parser": "0.9.0"
"hermes-estree": "0.10.0",
"hermes-parser": "0.10.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc