upgrade eslint plugins, turn off new rules, convert errors to warnings

pull/4940/head
Antony Jones 5 years ago
parent 20b4d9138c
commit 589a9f4cd0

1177
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -65,16 +65,16 @@
"@rollup/plugin-virtual": "^2.0.0", "@rollup/plugin-virtual": "^2.0.0",
"@types/mocha": "^5.2.7", "@types/mocha": "^5.2.7",
"@types/node": "^8.10.53", "@types/node": "^8.10.53",
"@typescript-eslint/eslint-plugin": "^1.13.0", "@typescript-eslint/eslint-plugin": "^3.0.2",
"@typescript-eslint/parser": "^2.1.0", "@typescript-eslint/parser": "^3.0.2",
"acorn": "^7.1.0", "acorn": "^7.1.0",
"agadoo": "^1.1.0", "agadoo": "^1.1.0",
"c8": "^5.0.1", "c8": "^5.0.1",
"code-red": "0.1.1", "code-red": "0.1.1",
"codecov": "^3.5.0", "codecov": "^3.5.0",
"css-tree": "1.0.0-alpha22", "css-tree": "1.0.0-alpha22",
"eslint": "^6.3.0", "eslint": "^7.1.0",
"eslint-plugin-import": "^2.18.2", "eslint-plugin-import": "^2.20.2",
"eslint-plugin-svelte3": "^2.7.3", "eslint-plugin-svelte3": "^2.7.3",
"estree-walker": "^1.0.0", "estree-walker": "^1.0.0",
"is-reference": "^1.1.4", "is-reference": "^1.1.4",

@ -1362,78 +1362,78 @@ function process_component_options(component: Component, nodes) {
const { name } = attribute; const { name } = attribute;
switch (name) { switch (name) {
case 'tag': { case 'tag': {
const code = 'invalid-tag-attribute'; const code = 'invalid-tag-attribute';
const message = `'tag' must be a string literal`; const message = `'tag' must be a string literal`;
const tag = get_value(attribute, code, message); const tag = get_value(attribute, code, message);
if (typeof tag !== 'string' && tag !== null) if (typeof tag !== 'string' && tag !== null)
component.error(attribute, { code, message }); component.error(attribute, { code, message });
if (tag && !/^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/.test(tag)) { if (tag && !/^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/.test(tag)) {
component.error(attribute, { component.error(attribute, {
code: `invalid-tag-property`, code: `invalid-tag-property`,
message: `tag name must be two or more words joined by the '-' character` message: `tag name must be two or more words joined by the '-' character`
}); });
} }
if (tag && !component.compile_options.customElement) {
component.warn(attribute, {
code: 'missing-custom-element-compile-options',
message: `The 'tag' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?`
});
}
component_options.tag = tag; if (tag && !component.compile_options.customElement) {
break; component.warn(attribute, {
code: 'missing-custom-element-compile-options',
message: `The 'tag' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?`
});
} }
case 'namespace': { component_options.tag = tag;
const code = 'invalid-namespace-attribute'; break;
const message = `The 'namespace' attribute must be a string literal representing a valid namespace`; }
const ns = get_value(attribute, code, message);
if (typeof ns !== 'string') case 'namespace': {
component.error(attribute, { code, message }); const code = 'invalid-namespace-attribute';
const message = `The 'namespace' attribute must be a string literal representing a valid namespace`;
const ns = get_value(attribute, code, message);
if (valid_namespaces.indexOf(ns) === -1) { if (typeof ns !== 'string')
const match = fuzzymatch(ns, valid_namespaces); component.error(attribute, { code, message });
if (match) {
component.error(attribute, {
code: `invalid-namespace-property`,
message: `Invalid namespace '${ns}' (did you mean '${match}'?)`
});
} else {
component.error(attribute, {
code: `invalid-namespace-property`,
message: `Invalid namespace '${ns}'`
});
}
}
component_options.namespace = ns; if (valid_namespaces.indexOf(ns) === -1) {
break; const match = fuzzymatch(ns, valid_namespaces);
if (match) {
component.error(attribute, {
code: `invalid-namespace-property`,
message: `Invalid namespace '${ns}' (did you mean '${match}'?)`
});
} else {
component.error(attribute, {
code: `invalid-namespace-property`,
message: `Invalid namespace '${ns}'`
});
}
} }
case 'accessors': component_options.namespace = ns;
case 'immutable': break;
case 'preserveWhitespace': { }
const code = `invalid-${name}-value`;
const message = `${name} attribute must be true or false`;
const value = get_value(attribute, code, message);
if (typeof value !== 'boolean') case 'accessors':
component.error(attribute, { code, message }); case 'immutable':
case 'preserveWhitespace': {
const code = `invalid-${name}-value`;
const message = `${name} attribute must be true or false`;
const value = get_value(attribute, code, message);
component_options[name] = value; if (typeof value !== 'boolean')
break; component.error(attribute, { code, message });
}
default: component_options[name] = value;
component.error(attribute, { break;
code: `invalid-options-attribute`, }
message: `<svelte:options> unknown attribute`
}); default:
component.error(attribute, {
code: `invalid-options-attribute`,
message: `<svelte:options> unknown attribute`
});
} }
} else { } else {
component.error(attribute, { component.error(attribute, {

@ -156,13 +156,13 @@ function apply_selector(blocks: Block[], node: Element, stack: Element[], to_enc
} }
switch (block_might_apply_to_node(block, node)) { switch (block_might_apply_to_node(block, node)) {
case BlockAppliesToNode.NotPossible: case BlockAppliesToNode.NotPossible:
return false; return false;
case BlockAppliesToNode.UnknownSelectorType: case BlockAppliesToNode.UnknownSelectorType:
// bail. TODO figure out what these could be // bail. TODO figure out what these could be
to_encapsulate.push({ node, block }); to_encapsulate.push({ node, block });
return true; return true;
} }
if (block.combinator) { if (block.combinator) {
@ -255,13 +255,13 @@ function test_attribute(operator, expected_value, case_insensitive, value) {
value = value.toLowerCase(); value = value.toLowerCase();
} }
switch (operator) { switch (operator) {
case '=': return value === expected_value; case '=': return value === expected_value;
case '~=': return value.split(/\s/).includes(expected_value); case '~=': return value.split(/\s/).includes(expected_value);
case '|=': return `${value}-`.startsWith(`${expected_value}-`); case '|=': return `${value}-`.startsWith(`${expected_value}-`);
case '^=': return value.startsWith(expected_value); case '^=': return value.startsWith(expected_value);
case '$=': return value.endsWith(expected_value); case '$=': return value.endsWith(expected_value);
case '*=': return value.includes(expected_value); case '*=': return value.includes(expected_value);
default: throw new Error(`this shouldn't happen`); default: throw new Error(`this shouldn't happen`);
} }
} }

@ -167,55 +167,55 @@ export default class Element extends Node {
info.attributes.forEach(node => { info.attributes.forEach(node => {
switch (node.type) { switch (node.type) {
case 'Action': case 'Action':
this.actions.push(new Action(component, this, scope, node)); this.actions.push(new Action(component, this, scope, node));
break; break;
case 'Attribute': case 'Attribute':
case 'Spread': case 'Spread':
// special case // special case
if (node.name === 'xmlns') this.namespace = node.value[0].data; if (node.name === 'xmlns') this.namespace = node.value[0].data;
this.attributes.push(new Attribute(component, this, scope, node)); this.attributes.push(new Attribute(component, this, scope, node));
break; break;
case 'Binding': case 'Binding':
this.bindings.push(new Binding(component, this, scope, node)); this.bindings.push(new Binding(component, this, scope, node));
break; break;
case 'Class': case 'Class':
this.classes.push(new Class(component, this, scope, node)); this.classes.push(new Class(component, this, scope, node));
break; break;
case 'EventHandler': case 'EventHandler':
this.handlers.push(new EventHandler(component, this, scope, node)); this.handlers.push(new EventHandler(component, this, scope, node));
break; break;
case 'Let': { case 'Let': {
const l = new Let(component, this, scope, node); const l = new Let(component, this, scope, node);
this.lets.push(l); this.lets.push(l);
const dependencies = new Set([l.name.name]); const dependencies = new Set([l.name.name]);
l.names.forEach(name => { l.names.forEach(name => {
scope.add(name, dependencies, this); scope.add(name, dependencies, this);
}); });
break; break;
} }
case 'Transition': case 'Transition':
{ {
const transition = new Transition(component, this, scope, node); const transition = new Transition(component, this, scope, node);
if (node.intro) this.intro = transition; if (node.intro) this.intro = transition;
if (node.outro) this.outro = transition; if (node.outro) this.outro = transition;
break; break;
} }
case 'Animation': case 'Animation':
this.animation = new Animation(component, this, scope, node); this.animation = new Animation(component, this, scope, node);
break; break;
default: default:
throw new Error(`Not implemented: ${node.type}`); throw new Error(`Not implemented: ${node.type}`);
} }
}); });

@ -38,50 +38,50 @@ export default class InlineComponent extends Node {
info.attributes.forEach(node => { info.attributes.forEach(node => {
/* eslint-disable no-fallthrough */ /* eslint-disable no-fallthrough */
switch (node.type) { switch (node.type) {
case 'Action': case 'Action':
component.error(node, { component.error(node, {
code: `invalid-action`, code: `invalid-action`,
message: `Actions can only be applied to DOM elements, not components` message: `Actions can only be applied to DOM elements, not components`
}); });
case 'Attribute': case 'Attribute':
if (node.name === 'slot') { if (node.name === 'slot') {
component.error(node, {
code: `invalid-prop`,
message: `'slot' is reserved for future use in named slots`
});
}
// fallthrough
case 'Spread':
this.attributes.push(new Attribute(component, this, scope, node));
break;
case 'Binding':
this.bindings.push(new Binding(component, this, scope, node));
break;
case 'Class':
component.error(node, { component.error(node, {
code: `invalid-class`, code: `invalid-prop`,
message: `Classes can only be applied to DOM elements, not components` message: `'slot' is reserved for future use in named slots`
}); });
}
// fallthrough
case 'Spread':
this.attributes.push(new Attribute(component, this, scope, node));
break;
case 'Binding':
this.bindings.push(new Binding(component, this, scope, node));
break;
case 'Class':
component.error(node, {
code: `invalid-class`,
message: `Classes can only be applied to DOM elements, not components`
});
case 'EventHandler': case 'EventHandler':
this.handlers.push(new EventHandler(component, this, scope, node)); this.handlers.push(new EventHandler(component, this, scope, node));
break; break;
case 'Let': case 'Let':
this.lets.push(new Let(component, this, scope, node)); this.lets.push(new Let(component, this, scope, node));
break; break;
case 'Transition': case 'Transition':
component.error(node, { component.error(node, {
code: `invalid-transition`, code: `invalid-transition`,
message: `Transitions can only be applied to DOM elements, not components` message: `Transitions can only be applied to DOM elements, not components`
}); });
default: default:
throw new Error(`Not implemented: ${node.type}`); throw new Error(`Not implemented: ${node.type}`);
} }
/* eslint-enable no-fallthrough */ /* eslint-enable no-fallthrough */
}); });

@ -20,23 +20,23 @@ export type Children = ReturnType<typeof map_children>;
function get_constructor(type) { function get_constructor(type) {
switch (type) { switch (type) {
case 'AwaitBlock': return AwaitBlock; case 'AwaitBlock': return AwaitBlock;
case 'Body': return Body; case 'Body': return Body;
case 'Comment': return Comment; case 'Comment': return Comment;
case 'EachBlock': return EachBlock; case 'EachBlock': return EachBlock;
case 'Element': return Element; case 'Element': return Element;
case 'Head': return Head; case 'Head': return Head;
case 'IfBlock': return IfBlock; case 'IfBlock': return IfBlock;
case 'InlineComponent': return InlineComponent; case 'InlineComponent': return InlineComponent;
case 'MustacheTag': return MustacheTag; case 'MustacheTag': return MustacheTag;
case 'Options': return Options; case 'Options': return Options;
case 'RawMustacheTag': return RawMustacheTag; case 'RawMustacheTag': return RawMustacheTag;
case 'DebugTag': return DebugTag; case 'DebugTag': return DebugTag;
case 'Slot': return Slot; case 'Slot': return Slot;
case 'Text': return Text; case 'Text': return Text;
case 'Title': return Title; case 'Title': return Title;
case 'Window': return Window; case 'Window': return Window;
default: throw new Error(`Not implemented: ${type}`); default: throw new Error(`Not implemented: ${type}`);
} }
} }

@ -393,15 +393,15 @@ export default class Block {
${this.chunks.declarations} ${this.chunks.declarations}
${Array.from(this.variables.values()).map(({ id, init }) => { ${Array.from(this.variables.values()).map(({ id, init }) => {
return init return init
? b`let ${id} = ${init}` ? b`let ${id} = ${init}`
: b`let ${id}`; : b`let ${id}`;
})} })}
${this.chunks.init} ${this.chunks.init}
${dev ${dev
? b` ? b`
const ${block} = ${return_value}; const ${block} = ${return_value};
@dispatch_dev("SvelteRegisterBlock", { @dispatch_dev("SvelteRegisterBlock", {
block: ${block}, block: ${block},
@ -411,9 +411,9 @@ export default class Block {
ctx: #ctx ctx: #ctx
}); });
return ${block};` return ${block};`
: b` : b`
return ${return_value};` return ${return_value};`
} }
`; `;
return body; return body;

@ -90,8 +90,8 @@ export default function dom(
${uses_rest && !uses_props && x`$$props = @assign(@assign({}, $$props), @exclude_internal_props($$new_props))`} ${uses_rest && !uses_props && x`$$props = @assign(@assign({}, $$props), @exclude_internal_props($$new_props))`}
${uses_rest && renderer.invalidate('$$restProps', x`$$restProps = ${compute_rest}`)} ${uses_rest && renderer.invalidate('$$restProps', x`$$restProps = ${compute_rest}`)}
${writable_props.map(prop => ${writable_props.map(prop =>
b`if ('${prop.export_name}' in ${$$props}) ${renderer.invalidate(prop.name, x`${prop.name} = ${$$props}.${prop.export_name}`)};` b`if ('${prop.export_name}' in ${$$props}) ${renderer.invalidate(prop.name, x`${prop.name} = ${$$props}.${prop.export_name}`)};`
)} )}
${component.slots.size > 0 && ${component.slots.size > 0 &&
b`if ('$$scope' in ${$$props}) ${renderer.invalidate('$$scope', x`$$scope = ${$$props}.$$scope`)};`} b`if ('$$scope' in ${$$props}) ${renderer.invalidate('$$scope', x`$$scope = ${$$props}.$$scope`)};`}
} }
@ -190,8 +190,8 @@ export default function dom(
${$$props} => { ${$$props} => {
${uses_props && renderer.invalidate('$$props', x`$$props = @assign(@assign({}, $$props), $$new_props)`)} ${uses_props && renderer.invalidate('$$props', x`$$props = @assign(@assign({}, $$props), $$new_props)`)}
${injectable_vars.map( ${injectable_vars.map(
v => b`if ('${v.name}' in $$props) ${renderer.invalidate(v.name, x`${v.name} = ${$$props}.${v.name}`)};` v => b`if ('${v.name}' in $$props) ${renderer.invalidate(v.name, x`${v.name} = ${$$props}.${v.name}`)};`
)} )}
} }
`; `;

@ -119,61 +119,61 @@ export default class BindingWrapper {
// special cases // special cases
switch (this.node.name) { switch (this.node.name) {
case 'group': case 'group':
{ {
const binding_group = get_binding_group(parent.renderer, this.node.expression.node); const binding_group = get_binding_group(parent.renderer, this.node.expression.node);
block.renderer.add_to_context(`$$binding_groups`); block.renderer.add_to_context(`$$binding_groups`);
const reference = block.renderer.reference(`$$binding_groups`); const reference = block.renderer.reference(`$$binding_groups`);
block.chunks.hydrate.push( block.chunks.hydrate.push(
b`${reference}[${binding_group}].push(${parent.var});` b`${reference}[${binding_group}].push(${parent.var});`
); );
block.chunks.destroy.push(
b`${reference}[${binding_group}].splice(${reference}[${binding_group}].indexOf(${parent.var}), 1);`
);
break;
}
case 'textContent': block.chunks.destroy.push(
update_conditions.push(x`${this.snippet} !== ${parent.var}.textContent`); b`${reference}[${binding_group}].splice(${reference}[${binding_group}].indexOf(${parent.var}), 1);`
mount_conditions.push(x`${this.snippet} !== void 0`); );
break; break;
}
case 'innerHTML': case 'textContent':
update_conditions.push(x`${this.snippet} !== ${parent.var}.innerHTML`); update_conditions.push(x`${this.snippet} !== ${parent.var}.textContent`);
mount_conditions.push(x`${this.snippet} !== void 0`); mount_conditions.push(x`${this.snippet} !== void 0`);
break; break;
case 'innerHTML':
update_conditions.push(x`${this.snippet} !== ${parent.var}.innerHTML`);
mount_conditions.push(x`${this.snippet} !== void 0`);
break;
case 'currentTime':
update_conditions.push(x`!@_isNaN(${this.snippet})`);
mount_dom = null;
break;
case 'playbackRate':
case 'volume':
update_conditions.push(x`!@_isNaN(${this.snippet})`);
mount_conditions.push(x`!@_isNaN(${this.snippet})`);
break;
case 'paused':
{
// this is necessary to prevent audio restarting by itself
const last = block.get_unique_name(`${parent.var.name}_is_paused`);
block.add_variable(last, x`true`);
update_conditions.push(x`${last} !== (${last} = ${this.snippet})`);
update_dom = b`${parent.var}[${last} ? "pause" : "play"]();`;
mount_dom = null;
break;
}
case 'currentTime': case 'value':
update_conditions.push(x`!@_isNaN(${this.snippet})`); if (parent.node.get_static_attribute_value('type') === 'file') {
update_dom = null;
mount_dom = null; mount_dom = null;
break;
case 'playbackRate':
case 'volume':
update_conditions.push(x`!@_isNaN(${this.snippet})`);
mount_conditions.push(x`!@_isNaN(${this.snippet})`);
break;
case 'paused':
{
// this is necessary to prevent audio restarting by itself
const last = block.get_unique_name(`${parent.var.name}_is_paused`);
block.add_variable(last, x`true`);
update_conditions.push(x`${last} !== (${last} = ${this.snippet})`);
update_dom = b`${parent.var}[${last} ? "pause" : "play"]();`;
mount_dom = null;
break;
} }
case 'value':
if (parent.node.get_static_attribute_value('type') === 'file') {
update_dom = null;
mount_dom = null;
}
} }
if (update_dom) { if (update_dom) {
@ -265,11 +265,11 @@ function get_event_handler(
name: string, name: string,
lhs: Node lhs: Node
): { ): {
uses_context: boolean; uses_context: boolean;
mutation: (Node | Node[]); mutation: (Node | Node[]);
contextual_dependencies: Set<string>; contextual_dependencies: Set<string>;
lhs?: Node; lhs?: Node;
} { } {
const value = get_value_from_dom(renderer, binding.parent, binding); const value = get_value_from_dom(renderer, binding.parent, binding);
const contextual_dependencies = new Set(binding.node.expression.contextual_dependencies); const contextual_dependencies = new Set(binding.node.expression.contextual_dependencies);

@ -569,9 +569,9 @@ export default class ElementWrapper extends Wrapper {
function ${handler}(${params}) { function ${handler}(${params}) {
${group.bindings.map(b => b.handler.mutation)} ${group.bindings.map(b => b.handler.mutation)}
${Array.from(dependencies) ${Array.from(dependencies)
.filter(dep => dep[0] !== '$') .filter(dep => dep[0] !== '$')
.filter(dep => !contextual_dependencies.has(dep)) .filter(dep => !contextual_dependencies.has(dep))
.map(dep => b`${this.renderer.invalidate(dep)};`)} .map(dep => b`${this.renderer.invalidate(dep)};`)}
} }
`); `);

@ -267,22 +267,22 @@ export default class IfBlockWrapper extends Wrapper {
block.chunks.init.push(b` block.chunks.init.push(b`
function ${select_block_type}(#ctx, #dirty) { function ${select_block_type}(#ctx, #dirty) {
${this.branches.map(({ dependencies, condition, snippet, block }) => condition ${this.branches.map(({ dependencies, condition, snippet, block }) => condition
? b` ? b`
${snippet && ( ${snippet && (
dependencies.length > 0 dependencies.length > 0
? b`if (${condition} == null || ${block.renderer.dirty(dependencies)}) ${condition} = !!${snippet}` ? b`if (${condition} == null || ${block.renderer.dirty(dependencies)}) ${condition} = !!${snippet}`
: b`if (${condition} == null) ${condition} = !!${snippet}` : b`if (${condition} == null) ${condition} = !!${snippet}`
)} )}
if (${condition}) return ${block.name};` if (${condition}) return ${block.name};`
: b`return ${block.name};`)} : b`return ${block.name};`)}
} }
`); `);
} else { } else {
block.chunks.init.push(b` block.chunks.init.push(b`
function ${select_block_type}(#ctx, #dirty) { function ${select_block_type}(#ctx, #dirty) {
${this.branches.map(({ condition, snippet, block }) => condition ${this.branches.map(({ condition, snippet, block }) => condition
? b`if (${snippet || condition}) return ${block.name};` ? b`if (${snippet || condition}) return ${block.name};`
: b`return ${block.name};`)} : b`return ${block.name};`)}
} }
`); `);
} }
@ -385,25 +385,25 @@ export default class IfBlockWrapper extends Wrapper {
const ${if_blocks} = []; const ${if_blocks} = [];
${this.needs_update ${this.needs_update
? b` ? b`
function ${select_block_type}(#ctx, #dirty) { function ${select_block_type}(#ctx, #dirty) {
${this.branches.map(({ dependencies, condition, snippet }, i) => condition ${this.branches.map(({ dependencies, condition, snippet }, i) => condition
? b` ? b`
${snippet && ( ${snippet && (
dependencies.length > 0 dependencies.length > 0
? b`if (${block.renderer.dirty(dependencies)}) ${condition} = !!${snippet}` ? b`if (${block.renderer.dirty(dependencies)}) ${condition} = !!${snippet}`
: b`if (${condition} == null) ${condition} = !!${snippet}` : b`if (${condition} == null) ${condition} = !!${snippet}`
)} )}
if (${condition}) return ${i};` if (${condition}) return ${i};`
: b`return ${i};`)} : b`return ${i};`)}
${!has_else && b`return -1;`} ${!has_else && b`return -1;`}
} }
` `
: b` : b`
function ${select_block_type}(#ctx, #dirty) { function ${select_block_type}(#ctx, #dirty) {
${this.branches.map(({ condition, snippet }, i) => condition ${this.branches.map(({ condition, snippet }, i) => condition
? b`if (${snippet || condition}) return ${i};` ? b`if (${snippet || condition}) return ${i};`
: b`return ${i};`)} : b`return ${i};`)}
${!has_else && b`return -1;`} ${!has_else && b`return -1;`}
} }
`} `}
@ -532,11 +532,11 @@ export default class IfBlockWrapper extends Wrapper {
if (${name}) { if (${name}) {
${dynamic && b`${name}.p(#ctx, #dirty);`} ${dynamic && b`${name}.p(#ctx, #dirty);`}
${ ${
has_transitions && has_transitions &&
b`if (${block.renderer.dirty(branch.dependencies)}) { b`if (${block.renderer.dirty(branch.dependencies)}) {
@transition_in(${name}, 1); @transition_in(${name}, 1);
}` }`
} }
} else { } else {
${name} = ${branch.block.name}(#ctx); ${name} = ${branch.block.name}(#ctx);
${name}.c(); ${name}.c();

@ -164,8 +164,8 @@ export default class InlineComponentWrapper extends Wrapper {
? [ ? [
p`$$slots: { p`$$slots: {
${Array.from(this.slots).map(([name, slot]) => { ${Array.from(this.slots).map(([name, slot]) => {
return p`${name}: [${slot.block.name}, ${slot.get_context || null}, ${slot.get_changes || null}]`; return p`${name}: [${slot.block.name}, ${slot.get_context || null}, ${slot.get_changes || null}]`;
})} })}
}`, }`,
p`$$scope: { p`$$scope: {
ctx: #ctx ctx: #ctx
@ -254,8 +254,8 @@ export default class InlineComponentWrapper extends Wrapper {
unchanged unchanged
? x`${levels}[${i}]` ? x`${levels}[${i}]`
: condition : condition
? x`${condition} && ${change_object}` ? x`${condition} && ${change_object}`
: change_object : change_object
); );
}); });

@ -14,21 +14,21 @@ export default function is_used_as_reference(
/* eslint-disable no-fallthrough */ /* eslint-disable no-fallthrough */
switch (parent.type) { switch (parent.type) {
// disregard the `foo` in `const foo = bar` // disregard the `foo` in `const foo = bar`
case 'VariableDeclarator': case 'VariableDeclarator':
return node !== parent.id; return node !== parent.id;
// disregard the `foo`, `bar` in `function foo(bar){}` // disregard the `foo`, `bar` in `function foo(bar){}`
case 'FunctionDeclaration': case 'FunctionDeclaration':
// disregard the `foo` in `import { foo } from 'foo'` // disregard the `foo` in `import { foo } from 'foo'`
case 'ImportSpecifier': case 'ImportSpecifier':
// disregard the `foo` in `import foo from 'foo'` // disregard the `foo` in `import foo from 'foo'`
case 'ImportDefaultSpecifier': case 'ImportDefaultSpecifier':
// disregard the `foo` in `import * as foo from 'foo'` // disregard the `foo` in `import * as foo from 'foo'`
case 'ImportNamespaceSpecifier': case 'ImportNamespaceSpecifier':
// disregard the `foo` in `export { foo }` // disregard the `foo` in `export { foo }`
case 'ExportSpecifier': case 'ExportSpecifier':
return false; return false;
default: default:
return true; return true;
} }
} }

@ -12,8 +12,8 @@ export function escape(data: string, { only_escape_at_symbol = false } = {}) {
} }
const escaped = { const escaped = {
'"': '&quot;', '"': '&quot;',
"'": '&#39;', "'": '&#39;',
'&': '&amp;', '&': '&amp;',
'<': '&lt;', '<': '&lt;',
'>': '&gt;' '>': '&gt;'

@ -2,29 +2,29 @@ import { TemplateNode } from '../../interfaces';
export function to_string(node: TemplateNode) { export function to_string(node: TemplateNode) {
switch (node.type) { switch (node.type) {
case 'IfBlock': case 'IfBlock':
return '{#if} block'; return '{#if} block';
case 'ThenBlock': case 'ThenBlock':
return '{:then} block'; return '{:then} block';
case 'ElseBlock': case 'ElseBlock':
return '{:else} block'; return '{:else} block';
case 'PendingBlock': case 'PendingBlock':
case 'AwaitBlock': case 'AwaitBlock':
return '{#await} block'; return '{#await} block';
case 'CatchBlock': case 'CatchBlock':
return '{:catch} block'; return '{:catch} block';
case 'EachBlock': case 'EachBlock':
return '{#each} block'; return '{#each} block';
case 'RawMustacheTag': case 'RawMustacheTag':
return '{@html} block'; return '{@html} block';
case 'DebugTag': case 'DebugTag':
return '{@debug} block'; return '{@debug} block';
case 'Element': case 'Element':
case 'InlineComponent': case 'InlineComponent':
case 'Slot': case 'Slot':
case 'Title': case 'Title':
return `<${node.name}> tag`; return `<${node.name}> tag`;
default: default:
return node.type; return node.type;
} }
} }

@ -19,7 +19,6 @@ interface Fragment {
/* outro */ o: (local: any) => void; /* outro */ o: (local: any) => void;
/* destroy */ d: (detaching: 0|1) => void; /* destroy */ d: (detaching: 0|1) => void;
} }
// eslint-disable-next-line @typescript-eslint/class-name-casing
interface T$$ { interface T$$ {
dirty: number[]; dirty: number[];
ctx: null|any; ctx: null|any;

@ -113,7 +113,7 @@ export class SvelteComponentDev extends SvelteComponent {
hydrate?: boolean; hydrate?: boolean;
intro?: boolean; intro?: boolean;
$$inline?: boolean; $$inline?: boolean;
}) { }) {
if (!options || (!options.target && !options.$$inline)) { if (!options || (!options.target && !options.$$inline)) {
throw new Error(`'target' is a required option`); throw new Error(`'target' is a required option`);
} }

@ -3,5 +3,5 @@ declare const global: any;
export const globals = (typeof window !== 'undefined' export const globals = (typeof window !== 'undefined'
? window ? window
: typeof globalThis !== 'undefined' : typeof globalThis !== 'undefined'
? globalThis ? globalThis
: global) as unknown as typeof globalThis; : global) as unknown as typeof globalThis;

@ -184,7 +184,7 @@ export function derived<T>(stores: Stores, fn: Function, initial_value?: T): Rea
}, },
() => { () => {
pending |= (1 << i); pending |= (1 << i);
}), })
); );
inited = true; inited = true;

Loading…
Cancel
Save