Socket
Socket
Sign inDemoInstall

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.2 to 2.3.0

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# 2.3.0
- Respect `quotes` rule unless inside a template expression which is inside an attribute or directive enclosed in quotes
- Respect `no-unused-expressions` rule again (which is now safe thanks to a previous refactor)
# 2.2.2

@@ -2,0 +7,0 @@

21

index.js
'use strict';
const { compile, walk } = require('svelte/compiler');
const SCRIPT = 1, TEMPLATE_QUOTED = 2, TEMPLATE_UNQUOTED = 3;
let compiler_options, messages, transformed_code, line_offsets, ignore_warnings, ignore_styles, translations;

@@ -216,7 +216,7 @@

if (ast.module) {
get_translation(ast.module.content, 'module');
get_translation(ast.module.content, SCRIPT);
}
transformed_code += '\n';
if (ast.instance) {
get_translation(ast.instance.content, 'instance');
get_translation(ast.instance.content, SCRIPT);
}

@@ -237,2 +237,3 @@ transformed_code += '\n';

const nodes_with_contextual_scope = new WeakSet();
let in_quoted_attribute = false;
walk(ast.html, {

@@ -242,2 +243,4 @@ enter(node, parent, prop) {

return this.skip();
} else if (prop === 'attributes' && /['"]/.test(text[node.end - 1])) {
in_quoted_attribute = true;
}

@@ -259,7 +262,10 @@ contextual_names.length = 0;

transformed_code += '(\n';
get_translation(node.expression, 'template');
get_translation(node.expression, in_quoted_attribute ? TEMPLATE_QUOTED : TEMPLATE_UNQUOTED);
transformed_code += '\n);';
}
},
leave(node) {
leave(node, parent, prop) {
if (prop === 'attributes') {
in_quoted_attribute = false;
}
// close contextual scope

@@ -297,10 +303,9 @@ if (nodes_with_contextual_scope.has(node)) {

switch (message.ruleId) {
case 'indent': return type !== 'template';
case 'eol-last': return false;
case 'indent': return type === SCRIPT;
case 'no-labels': return get_identifier(get_referenced_string(message)) !== '$';
case 'no-restricted-syntax': return message.nodeType !== 'LabeledStatement' || get_identifier(get_referenced_string(message)) !== '$';
case 'no-self-assign': return false;
case 'no-unused-expressions': return type !== 'template';
case 'no-unused-labels': return get_referenced_string(message) !== '$';
case 'quotes': return type !== 'template';
case 'quotes': return type !== TEMPLATE_QUOTED;
}

@@ -307,0 +312,0 @@ return true;

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

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

@@ -7,7 +7,6 @@ # eslint-plugin-svelte3

- Svelte compiler errors and warnings are exposed as ESLint messages
- Variable references in your template or in store auto-subscriptions are handled when linting for unused variables
- Self-assignments are always allowed, as this is an official pattern for manually triggering reactive updates
- Unused labels called `$` are always allowed, as this is the syntax for reactive assignments
- Linting of template expressions in addition to the script blocks
- Compiler errors and warnings are displayed through ESLint
- Script blocks and template expression tags are linted with existing ESLint rules
- Svelte scope and stores are respected by unused variable and undefined variable rules
- Idioms like self-assignment and `$:` labels are always allowed, regardless of configuration

@@ -24,3 +23,3 @@ ## Requirements

```
npm install eslint-plugin-svelte3
npm install --save-dev eslint-plugin-svelte3
```

@@ -27,0 +26,0 @@

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