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

eslint-plugin-svelte3

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-svelte3 - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 2.2.1
- Handle `then` and `catch` scope in `{#await}`
# 2.2.0

@@ -2,0 +6,0 @@

50

index.js

@@ -133,3 +133,19 @@ 'use strict';

/// PRE- AND POSTPROCESSING FUNCTIONS FOR SVELTE COMPONENTS ///
// find the contextual name or names described by a particular node in the AST
const contextual_names = [];
const find_contextual_names = node => {
if (node) {
if (typeof node === 'string') {
contextual_names.push(node);
} else if (typeof node === 'object') {
walk(node, {
enter(node, parent, prop) {
if (node.name && prop !== 'key') {
contextual_names.push(node.name);
}
},
});
}
}
};

@@ -221,2 +237,3 @@ // extract scripts to lint from component definition

// add expressions from template to the constructed string
const nodes_with_contextual_scope = new WeakSet();
walk(ast.html, {

@@ -227,17 +244,13 @@ enter(node, parent, prop) {

}
if (node.context && typeof node.context === 'object') {
// find all the variables declared in this context
const names = [];
walk(node.context, {
enter(node, parent, prop) {
if (node.name && prop !== 'key') {
names.push(node.name);
}
},
});
transformed_code += `{${names.map(name => `let ${name}=0;`).join('')}\n`;
contextual_names.length = 0;
find_contextual_names(node.context);
if (node.type === 'EachBlock') {
find_contextual_names(node.index);
} else if (node.type === 'AwaitBlock') {
find_contextual_names(node.value);
find_contextual_names(node.error);
}
if (node.index && typeof node.index === 'string') {
// declare the index variable, if present
transformed_code += `{let ${node.index}=0;\n`;
if (contextual_names.length) {
nodes_with_contextual_scope.add(node);
transformed_code += `{let ${contextual_names.map(name => `${name}=0`).join(',')};\n`;
}

@@ -252,9 +265,6 @@ if (node.expression && typeof node.expression === 'object') {

leave(node) {
// close nested scopes created for context or index
if (node.context && typeof node.context === 'object') {
// close contextual scope
if (nodes_with_contextual_scope.has(node)) {
transformed_code += '}';
}
if (node.index && typeof node.index === 'string') {
transformed_code += '}';
}
},

@@ -261,0 +271,0 @@ });

{
"name": "eslint-plugin-svelte3",
"version": "2.2.0",
"version": "2.2.1",
"description": "An ESLint plugin for Svelte v3 components.",

@@ -5,0 +5,0 @@ "keywords": [

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