Curly brace cleanup and enforcement (#5647)

pull/5660/head
Ben McCann 4 years ago committed by GitHub
parent 9745b61aab
commit 240f5410f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

4
package-lock.json generated

@ -144,8 +144,8 @@
}
},
"@sveltejs/eslint-config": {
"version": "github:sveltejs/eslint-config#54081d752d199dba97db9f578665c87f18469da3",
"from": "github:sveltejs/eslint-config#v5.5.0",
"version": "github:sveltejs/eslint-config#cca8177349dd5a02b19a5865afc4a7066921409a",
"from": "github:sveltejs/eslint-config#v5.6.0",
"dev": true
},
"@tootallnate/once": {

@ -63,7 +63,7 @@
"@rollup/plugin-sucrase": "^3.0.0",
"@rollup/plugin-typescript": "^2.0.1",
"@rollup/plugin-virtual": "^2.0.0",
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.5.0",
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.6.0",
"@types/mocha": "^7.0.0",
"@types/node": "^8.10.53",
"@typescript-eslint/eslint-plugin": "^3.0.2",

@ -267,17 +267,13 @@ export default class Component {
this.helpers.set(name, alias);
node.name = alias.name;
}
}
else if (node.name[0] !== '#' && !is_valid(node.name)) {
} else if (node.name[0] !== '#' && !is_valid(node.name)) {
// this hack allows x`foo.${bar}` where bar could be invalid
const literal: Literal = { type: 'Literal', value: node.name };
if (parent.type === 'Property' && key === 'key') {
parent.key = literal;
}
else if (parent.type === 'MemberExpression' && key === 'property') {
} else if (parent.type === 'MemberExpression' && key === 'property') {
parent.property = literal;
parent.computed = true;
}

@ -248,25 +248,17 @@ function block_might_apply_to_node(block: Block, node: Element): BlockAppliesToN
if (selector.type === 'ClassSelector') {
if (!attribute_matches(node, 'class', name, '~=', false) && !node.classes.some(c => c.name === name)) return BlockAppliesToNode.NotPossible;
}
else if (selector.type === 'IdSelector') {
} else if (selector.type === 'IdSelector') {
if (!attribute_matches(node, 'id', name, '=', false)) return BlockAppliesToNode.NotPossible;
}
else if (selector.type === 'AttributeSelector') {
} else if (selector.type === 'AttributeSelector') {
if (
!(whitelist_attribute_selector.has(node.name.toLowerCase()) && whitelist_attribute_selector.get(node.name.toLowerCase()).has(selector.name.name.toLowerCase())) &&
!attribute_matches(node, selector.name.name, selector.value && unquote(selector.value), selector.matcher, selector.flags)) {
return BlockAppliesToNode.NotPossible;
}
}
else if (selector.type === 'TypeSelector') {
} else if (selector.type === 'TypeSelector') {
if (node.name.toLowerCase() !== name.toLowerCase() && name !== '*') return BlockAppliesToNode.NotPossible;
}
else {
} else {
return BlockAppliesToNode.UnknownSelectorType;
}
}

@ -167,9 +167,7 @@ class Atrule {
this.children.forEach(child => {
child.apply(node);
});
}
else if (is_keyframes_node(this.node)) {
} else if (is_keyframes_node(this.node)) {
this.children.forEach((rule: Rule) => {
rule.selectors.forEach(selector => {
selector.used = true;

@ -5,14 +5,10 @@ export const UNKNOWN = {};
export function gather_possible_values(node: Node, set: Set<string|{}>) {
if (node.type === 'Literal') {
set.add(node.value);
}
else if (node.type === 'ConditionalExpression') {
} else if (node.type === 'ConditionalExpression') {
gather_possible_values(node.consequent, set);
gather_possible_values(node.alternate, set);
}
else {
} else {
set.add(UNKNOWN);
}
}

@ -38,9 +38,7 @@ export default class Attribute extends Node {
this.chunks = null;
this.is_static = false;
}
else {
} else {
this.name = info.name;
this.is_true = info.value === true;
this.is_static = true;

@ -13,9 +13,7 @@ export default class Body extends Node {
info.attributes.forEach(node => {
if (node.type === 'EventHandler') {
this.handlers.push(new EventHandler(component, this, scope, node));
}
else {
} else {
// TODO there shouldn't be anything else here...
}
});

@ -28,9 +28,7 @@ export default class Window extends Node {
info.attributes.forEach(node => {
if (node.type === 'EventHandler') {
this.handlers.push(new EventHandler(component, this, scope, node));
}
else if (node.type === 'Binding') {
} else if (node.type === 'Binding') {
if (node.expression.type !== 'Identifier') {
const { parts } = flatten_reference(node.expression);
@ -64,13 +62,9 @@ export default class Window extends Node {
}
this.bindings.push(new Binding(component, this, scope, node));
}
else if (node.type === 'Action') {
} else if (node.type === 'Action') {
this.actions.push(new Action(component, this, scope, node));
}
else {
} else {
// TODO there shouldn't be anything else here...
}
});

@ -261,17 +261,13 @@ export default class Expression {
hoistable: true,
referenced: true
});
}
else if (contextual_dependencies.size === 0) {
} else if (contextual_dependencies.size === 0) {
// function can be hoisted inside the component init
component.partly_hoisted.push(declaration);
block.renderer.add_to_context(id.name);
this.replace(block.renderer.reference(id));
}
else {
} else {
// we need a combo block/init recipe
const deps = Array.from(contextual_dependencies);
const function_expression = node as FunctionExpression;

@ -164,9 +164,7 @@ function get_style_value(chunks: Array<Text | Expression>) {
break;
}
}
else {
} else {
value.push(chunk);
}
}

@ -745,9 +745,7 @@ export default class ElementWrapper extends Wrapper {
}
block.chunks.destroy.push(b`if (detaching && ${name}) ${name}.end();`);
}
else {
} else {
const intro_name = intro && block.get_unique_name(`${this.var.name}_intro`);
const outro_name = outro && block.get_unique_name(`${this.var.name}_outro`);
@ -920,22 +918,16 @@ function to_html(wrappers: Array<ElementWrapper | TextWrapper | MustacheTagWrapp
.replace(/\\/g, '\\\\')
.replace(/`/g, '\\`')
.replace(/\$/g, '\\$');
}
else if (wrapper instanceof MustacheTagWrapper || wrapper instanceof RawMustacheTagWrapper) {
} else if (wrapper instanceof MustacheTagWrapper || wrapper instanceof RawMustacheTagWrapper) {
literal.quasis.push(state.quasi);
literal.expressions.push(wrapper.node.expression.manipulate(block));
state.quasi = {
type: 'TemplateElement',
value: { raw: '' }
};
}
else if (wrapper.node.name === 'noscript') {
} else if (wrapper.node.name === 'noscript') {
// do nothing
}
else {
} else {
// element
state.quasi.value.raw += `<${wrapper.node.name}`;

@ -36,9 +36,7 @@ export default class RawMustacheTagWrapper extends Tag {
);
block.chunks.mount.push(insert(init));
}
else {
} else {
const needs_anchor = in_head || (this.next ? !this.next.is_dom_node() : (!this.parent || !this.parent.is_dom_node()));
const html_tag = block.get_unique_name('html_tag');

@ -142,10 +142,8 @@ export default function mustache(parser: Parser) {
};
parser.stack.push(block.else.children[0]);
}
// :else
else {
} else {
// :else
const block = parser.current();
if (block.type !== 'IfBlock' && block.type !== 'EachBlock') {
parser.error({

@ -73,19 +73,13 @@ export function update_keyed_each(old_blocks, dirty, get_key, dynamic, ctx, list
next = new_block.first;
o--;
n--;
}
else if (!new_lookup.has(old_key)) {
} else if (!new_lookup.has(old_key)) {
// remove old block
destroy(old_block, lookup);
o--;
}
else if (!lookup.has(new_key) || will_move.has(new_key)) {
} else if (!lookup.has(new_key) || will_move.has(new_key)) {
insert(new_block);
}
else if (did_move.has(old_key)) {
} else if (did_move.has(old_key)) {
o--;
} else if (deltas.get(new_key) > deltas.get(old_key)) {

@ -318,9 +318,7 @@ export function create_bidirectional_transition(node: Element & ElementCSSInline
}
running_program = null;
}
else if (now >= running_program.start) {
} else if (now >= running_program.start) {
const p = now - running_program.start;
t = running_program.a + running_program.d * easing(p / running_program.duration);
tick(t, 1 - t);

Loading…
Cancel
Save