eslint-plugin-svelte3
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -0,1 +1,5 @@ | ||
# 2.2.2 | ||
- Stop using inline configuration comments internally, to avoid issues with `--no-inline-config` and `--report-unused-disable-directives` | ||
# 2.2.1 | ||
@@ -2,0 +6,0 @@ |
52
index.js
@@ -57,5 +57,2 @@ 'use strict'; | ||
const transform_message = (message, { unoffsets, dedent, offsets, range }) => { | ||
if (message.line < unoffsets.lines) { | ||
return false; | ||
} | ||
// strip out the start and end of the fix if they are not actually changes | ||
@@ -131,3 +128,2 @@ if (message.fix) { | ||
} | ||
return true; | ||
}; | ||
@@ -204,7 +200,7 @@ | ||
// include declarations of all injected identifiers | ||
transformed_code = injected_vars.length ? `/* eslint-disable */let ${injected_vars.map(v => v.name).join(',')};\n/* eslint-enable */` : ''; | ||
transformed_code = injected_vars.length ? `let ${injected_vars.map(v => v.name).join(',')};\n` : ''; | ||
// get translation info and include the processed scripts in transformed_code | ||
const get_translation = node => { | ||
const translation = { unoffsets: get_offsets(transformed_code) }; | ||
const get_translation = (node, type) => { | ||
const translation = { type, unoffsets: get_offsets(transformed_code) }; | ||
translation.range = [node.start, node.end]; | ||
@@ -215,14 +211,17 @@ const { dedented, offsets } = dedent_code(text.slice(node.start, node.end)); | ||
translation.dedent = offsets; | ||
translations.push(translation); | ||
const end = get_offsets(transformed_code).lines; | ||
for (let i = translation.unoffsets.lines; i <= end; i++) { | ||
translations.set(i, translation); | ||
} | ||
}; | ||
translations = []; | ||
translations = new Map(); | ||
if (ast.module) { | ||
get_translation(ast.module.content); | ||
get_translation(ast.module.content, 'module'); | ||
} | ||
transformed_code += '/* eslint-disable */\n/* eslint-enable */'; | ||
transformed_code += '\n'; | ||
if (ast.instance) { | ||
get_translation(ast.instance.content); | ||
get_translation(ast.instance.content, 'instance'); | ||
} | ||
transformed_code += '/* eslint-disable */\n'; | ||
transformed_code += '\n'; | ||
@@ -256,9 +255,9 @@ // no-unused-vars: create references to all identifiers referred to by the template | ||
nodes_with_contextual_scope.add(node); | ||
transformed_code += `{let ${contextual_names.map(name => `${name}=0`).join(',')};\n`; | ||
transformed_code += `{let ${contextual_names.map(name => `${name}=0`).join(',')};`; | ||
} | ||
if (node.expression && typeof node.expression === 'object') { | ||
// add the expression in question to the constructed string | ||
transformed_code += '(/* eslint-enable *//* eslint-disable indent, no-unused-expressions, quotes */'; | ||
get_translation(node.expression); | ||
transformed_code += '/* eslint-disable */);\n'; | ||
transformed_code += '(\n'; | ||
get_translation(node.expression, 'template'); | ||
transformed_code += '\n);'; | ||
} | ||
@@ -274,5 +273,2 @@ }, | ||
// reverse sort the translations | ||
translations.sort((a, b) => b.unoffsets.length - a.unoffsets.length); | ||
// return processed string | ||
@@ -301,4 +297,5 @@ return [transformed_code]; | ||
// determine whether this message from ESLint is something we care about | ||
const is_valid_message = message => { | ||
const is_valid_message = (message, type) => { | ||
switch (message.ruleId) { | ||
case 'indent': return type !== 'template'; | ||
case 'eol-last': return false; | ||
@@ -308,3 +305,5 @@ case 'no-labels': return 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'; | ||
} | ||
@@ -320,9 +319,6 @@ return true; | ||
const message = raw_messages[i]; | ||
if (is_valid_message(message)) { | ||
for (let k = 0; k < translations.length; k++) { | ||
if (transform_message(message, translations[k])) { | ||
messages.push(message); | ||
break; | ||
} | ||
} | ||
const translation = translations.get(message.line); | ||
if (translation && is_valid_message(message, translation.type)) { | ||
transform_message(message, translation); | ||
messages.push(message); | ||
} | ||
@@ -329,0 +325,0 @@ } |
{ | ||
"name": "eslint-plugin-svelte3", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "An ESLint plugin for Svelte v3 components.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
20532
322