Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lint warnings caused by recent ESLint configuration update #5031

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
188 changes: 94 additions & 94 deletions src/compiler/compile/Component.ts

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions src/compiler/compile/css/Selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ function apply_selector(blocks: Block[], node: Element, stack: Element[], to_enc
}

switch (block_might_apply_to_node(block, node)) {
case BlockAppliesToNode.NotPossible:
return false;
case BlockAppliesToNode.NotPossible:
return false;

case BlockAppliesToNode.UnknownSelectorType:
// bail. TODO figure out what these could be
to_encapsulate.push({ node, block });
return true;
case BlockAppliesToNode.UnknownSelectorType:
// bail. TODO figure out what these could be
to_encapsulate.push({ node, block });
return true;
}

if (block.combinator) {
Expand Down Expand Up @@ -255,13 +255,13 @@ function test_attribute(operator, expected_value, case_insensitive, value) {
value = value.toLowerCase();
}
switch (operator) {
case '=': return value === 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.endsWith(expected_value);
case '*=': return value.includes(expected_value);
default: throw new Error(`this shouldn't happen`);
case '=': return value === 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.endsWith(expected_value);
case '*=': return value.includes(expected_value);
default: throw new Error(`this shouldn't happen`);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
code: `options-lowercase-name`,
message,
filename,
toString: () => message,
toString: () => message
});
}

Expand All @@ -62,7 +62,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
code: `options-loop-guard-timeout`,
message,
filename,
toString: () => message,
toString: () => message
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/nodes/Binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class Binding extends Node {

if (info.expression.type === 'Identifier' && !variable.writable) component.error(this.expression.node, {
code: 'invalid-binding',
message: 'Cannot bind to a variable which is not writable',
message: 'Cannot bind to a variable which is not writable'
});
}

Expand Down
82 changes: 41 additions & 41 deletions src/compiler/compile/nodes/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,55 +167,55 @@ export default class Element extends Node {

info.attributes.forEach(node => {
switch (node.type) {
case 'Action':
this.actions.push(new Action(component, this, scope, node));
break;
case 'Action':
this.actions.push(new Action(component, this, scope, node));
break;

case 'Attribute':
case 'Spread':
// special case
if (node.name === 'xmlns') this.namespace = node.value[0].data;
case 'Attribute':
case 'Spread':
// special case
if (node.name === 'xmlns') this.namespace = node.value[0].data;

this.attributes.push(new Attribute(component, this, scope, node));
break;
this.attributes.push(new Attribute(component, this, scope, node));
break;

case 'Binding':
this.bindings.push(new Binding(component, this, scope, node));
break;
case 'Binding':
this.bindings.push(new Binding(component, this, scope, node));
break;

case 'Class':
this.classes.push(new Class(component, this, scope, node));
break;
case 'Class':
this.classes.push(new Class(component, this, scope, node));
break;

case 'EventHandler':
this.handlers.push(new EventHandler(component, this, scope, node));
break;
case 'EventHandler':
this.handlers.push(new EventHandler(component, this, scope, node));
break;

case 'Let': {
const l = new Let(component, this, scope, node);
this.lets.push(l);
const dependencies = new Set([l.name.name]);
case 'Let': {
const l = new Let(component, this, scope, node);
this.lets.push(l);
const dependencies = new Set([l.name.name]);

l.names.forEach(name => {
scope.add(name, dependencies, this);
});
break;
}
l.names.forEach(name => {
scope.add(name, dependencies, this);
});
break;
}

case 'Transition':
{
const transition = new Transition(component, this, scope, node);
if (node.intro) this.intro = transition;
if (node.outro) this.outro = transition;
break;
}
case 'Transition':
{
const transition = new Transition(component, this, scope, node);
if (node.intro) this.intro = transition;
if (node.outro) this.outro = transition;
break;
}

case 'Animation':
this.animation = new Animation(component, this, scope, node);
break;
case 'Animation':
this.animation = new Animation(component, this, scope, node);
break;

default:
throw new Error(`Not implemented: ${node.type}`);
default:
throw new Error(`Not implemented: ${node.type}`);
}
});

Expand Down Expand Up @@ -388,7 +388,7 @@ export default class Element extends Node {
if (/(^[0-9-.])|[\^$@%&#?!|()[\]{}^*+~;]/.test(name)) {
component.error(attribute, {
code: `illegal-attribute`,
message: `'${name}' is not a valid attribute name`,
message: `'${name}' is not a valid attribute name`
});
}

Expand All @@ -412,7 +412,7 @@ export default class Element extends Node {
if (!(parent.type === 'InlineComponent' || within_custom_element(parent))) {
component.error(attribute, {
code: `invalid-slotted-content`,
message: `Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`,
message: `Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`
});
}
}
Expand Down
74 changes: 37 additions & 37 deletions src/compiler/compile/nodes/InlineComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,50 +38,50 @@ export default class InlineComponent extends Node {
info.attributes.forEach(node => {
/* eslint-disable no-fallthrough */
switch (node.type) {
case 'Action':
component.error(node, {
code: `invalid-action`,
message: `Actions can only be applied to DOM elements, not components`
});
case 'Action':
component.error(node, {
code: `invalid-action`,
message: `Actions can only be applied to DOM elements, not components`
});

case 'Attribute':
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':
case 'Attribute':
if (node.name === 'slot') {
component.error(node, {
code: `invalid-class`,
message: `Classes can only be applied to DOM elements, not components`
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, {
code: `invalid-class`,
message: `Classes can only be applied to DOM elements, not components`
});

case 'EventHandler':
this.handlers.push(new EventHandler(component, this, scope, node));
break;
case 'EventHandler':
this.handlers.push(new EventHandler(component, this, scope, node));
break;

case 'Let':
this.lets.push(new Let(component, this, scope, node));
break;
case 'Let':
this.lets.push(new Let(component, this, scope, node));
break;

case 'Transition':
component.error(node, {
code: `invalid-transition`,
message: `Transitions can only be applied to DOM elements, not components`
});
case 'Transition':
component.error(node, {
code: `invalid-transition`,
message: `Transitions can only be applied to DOM elements, not components`
});

default:
throw new Error(`Not implemented: ${node.type}`);
default:
throw new Error(`Not implemented: ${node.type}`);
}
/* eslint-enable no-fallthrough */
});
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/nodes/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const elements_without_text = new Set([
'dl',
'optgroup',
'select',
'video',
'video'
]);

export default class Text extends Node {
Expand Down
34 changes: 17 additions & 17 deletions src/compiler/compile/nodes/shared/map_children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ export type Children = ReturnType<typeof map_children>;

function get_constructor(type) {
switch (type) {
case 'AwaitBlock': return AwaitBlock;
case 'Body': return Body;
case 'Comment': return Comment;
case 'EachBlock': return EachBlock;
case 'Element': return Element;
case 'Head': return Head;
case 'IfBlock': return IfBlock;
case 'InlineComponent': return InlineComponent;
case 'MustacheTag': return MustacheTag;
case 'Options': return Options;
case 'RawMustacheTag': return RawMustacheTag;
case 'DebugTag': return DebugTag;
case 'Slot': return Slot;
case 'Text': return Text;
case 'Title': return Title;
case 'Window': return Window;
default: throw new Error(`Not implemented: ${type}`);
case 'AwaitBlock': return AwaitBlock;
case 'Body': return Body;
case 'Comment': return Comment;
case 'EachBlock': return EachBlock;
case 'Element': return Element;
case 'Head': return Head;
case 'IfBlock': return IfBlock;
case 'InlineComponent': return InlineComponent;
case 'MustacheTag': return MustacheTag;
case 'Options': return Options;
case 'RawMustacheTag': return RawMustacheTag;
case 'DebugTag': return DebugTag;
case 'Slot': return Slot;
case 'Text': return Text;
case 'Title': return Title;
case 'Window': return Window;
default: throw new Error(`Not implemented: ${type}`);
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/compiler/compile/render_dom/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class Block {
intro: [],
update: [],
outro: [],
destroy: [],
destroy: []
};

this.has_animation = false;
Expand Down Expand Up @@ -393,15 +393,15 @@ export default class Block {
${this.chunks.declarations}

${Array.from(this.variables.values()).map(({ id, init }) => {
return init
? b`let ${id} = ${init}`
: b`let ${id}`;
})}
return init
? b`let ${id} = ${init}`
: b`let ${id}`;
})}

${this.chunks.init}

${dev
? b`
? b`
const ${block} = ${return_value};
@dispatch_dev("SvelteRegisterBlock", {
block: ${block},
Expand All @@ -411,9 +411,9 @@ export default class Block {
ctx: #ctx
});
return ${block};`
: b`
: b`
return ${return_value};`
}
}
`;

return body;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render_dom/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class Renderer {

bindings: new Map(),

dependencies: new Set(),
dependencies: new Set()
});

this.block.has_update_method = true;
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/compile/render_dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export default function dom(
${uses_rest && !uses_props && x`$$props = @assign(@assign({}, $$props), @exclude_internal_props($$new_props))`}
${uses_rest && renderer.invalidate('$$restProps', x`$$restProps = ${compute_rest}`)}
${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 &&
b`if ('$$scope' in ${$$props}) ${renderer.invalidate('$$scope', x`$$scope = ${$$props}.$$scope`)};`}
}
Expand Down Expand Up @@ -190,8 +190,8 @@ export default function dom(
${$$props} => {
${uses_props && renderer.invalidate('$$props', x`$$props = @assign(@assign({}, $$props), $$new_props)`)}
${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}`)};`
)}
}
`;

Expand Down