Skip to content

Commit 7ea6a29

Browse files
authored
Curly braces linting fixes (#5585)
1 parent 7c1e6a6 commit 7ea6a29

File tree

9 files changed

+52
-32
lines changed

9 files changed

+52
-32
lines changed

src/compiler/compile/Component.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,7 @@ export default class Component {
521521
if (this.hoistable_nodes.has(node)) return false;
522522
if (this.reactive_declaration_nodes.has(node)) return false;
523523
if (node.type === 'ImportDeclaration') return false;
524-
if (node.type === 'ExportDeclaration' && node.specifiers.length > 0)
525-
return false;
524+
if (node.type === 'ExportDeclaration' && node.specifiers.length > 0) return false;
526525
return true;
527526
});
528527
}
@@ -1038,8 +1037,9 @@ export default class Component {
10381037
this.vars.find(
10391038
variable => variable.name === name && variable.module
10401039
)
1041-
)
1040+
) {
10421041
return false;
1042+
}
10431043

10441044
return true;
10451045
});
@@ -1288,8 +1288,9 @@ export default class Component {
12881288
declaration.dependencies.forEach(name => {
12891289
if (declaration.assignees.has(name)) return;
12901290
const earlier_declarations = lookup.get(name);
1291-
if (earlier_declarations)
1291+
if (earlier_declarations) {
12921292
earlier_declarations.forEach(add_declaration);
1293+
}
12931294
});
12941295

12951296
this.reactive_declarations.push(declaration);
@@ -1319,8 +1320,9 @@ export default class Component {
13191320
if (globals.has(name) && node.type !== 'InlineComponent') return;
13201321

13211322
let message = `'${name}' is not defined`;
1322-
if (!this.ast.instance)
1323+
if (!this.ast.instance) {
13231324
message += `. Consider adding a <script> block with 'export let ${name}' to declare a prop`;
1325+
}
13241326

13251327
this.warn(node, {
13261328
code: 'missing-declaration',
@@ -1382,8 +1384,9 @@ function process_component_options(component: Component, nodes) {
13821384
const message = "'tag' must be a string literal";
13831385
const tag = get_value(attribute, code, message);
13841386

1385-
if (typeof tag !== 'string' && tag !== null)
1387+
if (typeof tag !== 'string' && tag !== null) {
13861388
component.error(attribute, { code, message });
1389+
}
13871390

13881391
if (tag && !/^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/.test(tag)) {
13891392
component.error(attribute, {
@@ -1408,8 +1411,9 @@ function process_component_options(component: Component, nodes) {
14081411
const message = "The 'namespace' attribute must be a string literal representing a valid namespace";
14091412
const ns = get_value(attribute, code, message);
14101413

1411-
if (typeof ns !== 'string')
1414+
if (typeof ns !== 'string') {
14121415
component.error(attribute, { code, message });
1416+
}
14131417

14141418
if (valid_namespaces.indexOf(ns) === -1) {
14151419
const match = fuzzymatch(ns, valid_namespaces);
@@ -1437,8 +1441,9 @@ function process_component_options(component: Component, nodes) {
14371441
const message = `${name} attribute must be true or false`;
14381442
const value = get_value(attribute, code, message);
14391443

1440-
if (typeof value !== 'boolean')
1444+
if (typeof value !== 'boolean') {
14411445
component.error(attribute, { code, message });
1446+
}
14421447

14431448
component_options[name] = value;
14441449
break;

src/compiler/compile/nodes/Binding.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,21 @@ export default class Binding extends Node {
6767
} else {
6868
const variable = component.var_lookup.get(name);
6969

70-
if (!variable || variable.global) component.error(this.expression.node, {
71-
code: 'binding-undeclared',
72-
message: `${name} is not declared`
73-
});
70+
if (!variable || variable.global) {
71+
component.error(this.expression.node, {
72+
code: 'binding-undeclared',
73+
message: `${name} is not declared`
74+
});
75+
}
7476

7577
variable[this.expression.node.type === 'MemberExpression' ? 'mutated' : 'reassigned'] = true;
7678

77-
if (info.expression.type === 'Identifier' && !variable.writable) component.error(this.expression.node, {
78-
code: 'invalid-binding',
79-
message: 'Cannot bind to a variable which is not writable'
80-
});
79+
if (info.expression.type === 'Identifier' && !variable.writable) {
80+
component.error(this.expression.node, {
81+
code: 'invalid-binding',
82+
message: 'Cannot bind to a variable which is not writable'
83+
});
84+
}
8185
}
8286

8387
const type = parent.get_static_attribute_value('type');

src/compiler/compile/render_dom/wrappers/Element/Attribute.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
4848
// special case — <option value={foo}> — see below
4949
if (this.parent.node.name === 'option' && node.name === 'value') {
5050
let select: ElementWrapper = this.parent;
51-
while (select && (select.node.type !== 'Element' || select.node.name !== 'select'))
51+
while (select && (select.node.type !== 'Element' || select.node.name !== 'select')) {
5252
// @ts-ignore todo: doublecheck this, but looks to be correct
5353
select = select.parent;
54+
}
5455

5556
if (select && select.select_binding_dependencies) {
5657
select.select_binding_dependencies.forEach(prop => {

src/compiler/parse/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,12 @@ export class Parser {
178178
}
179179

180180
read_until(pattern: RegExp) {
181-
if (this.index >= this.template.length)
181+
if (this.index >= this.template.length) {
182182
this.error({
183183
code: 'unexpected-eof',
184184
message: 'Unexpected end of input'
185185
});
186+
}
186187

187188
const start = this.index;
188189
const match = pattern.exec(this.template.slice(start));

src/compiler/parse/read/script.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ export default function read_script(parser: Parser, start: number, attributes: N
3232
const script_start = parser.index;
3333
const script_end = parser.template.indexOf(script_closing_tag, script_start);
3434

35-
if (script_end === -1) parser.error({
36-
code: 'unclosed-script',
37-
message: '<script> must have a closing tag'
38-
});
35+
if (script_end === -1) {
36+
parser.error({
37+
code: 'unclosed-script',
38+
message: '<script> must have a closing tag'
39+
});
40+
}
3941

4042
const source = parser.template.slice(0, script_start).replace(/[^\n]/g, ' ') +
4143
parser.template.slice(script_start, script_end);

src/compiler/parse/state/mustache.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,12 @@ export default function mustache(parser: Parser) {
288288
if (parser.eat(',')) {
289289
parser.allow_whitespace();
290290
block.index = parser.read_identifier();
291-
if (!block.index) parser.error({
292-
code: 'expected-name',
293-
message: 'Expected name'
294-
});
291+
if (!block.index) {
292+
parser.error({
293+
code: 'expected-name',
294+
message: 'Expected name'
295+
});
296+
}
295297

296298
parser.allow_whitespace();
297299
}

src/compiler/utils/fuzzymatch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ const GRAM_SIZE_UPPER = 3;
1313

1414
// return an edit distance from 0 to 1
1515
function _distance(str1: string, str2: string) {
16-
if (str1 === null && str2 === null)
16+
if (str1 === null && str2 === null) {
1717
throw 'Trying to compare two null values';
18+
}
1819
if (str1 === null || str2 === null) return 0;
1920
str1 = String(str1);
2021
str2 = String(str2);

src/runtime/motion/spring.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ function tick_spring<T>(ctx: TickContext<T>, last_value: T, current_value: T, ta
3434
tick_spring(ctx, last_value[i], current_value[i], target_value[i]));
3535
} else if (typeof current_value === 'object') {
3636
const next_value = {};
37-
for (const k in current_value)
37+
for (const k in current_value) {
3838
// @ts-ignore
3939
next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);
40+
}
4041
// @ts-ignore
4142
return next_value;
4243
} else {
@@ -121,8 +122,9 @@ export function spring<T=any>(value?: T, opts: SpringOpts = {}): Spring<T> {
121122
last_value = value;
122123
store.set(value = next_value);
123124

124-
if (ctx.settled)
125+
if (ctx.settled) {
125126
task = null;
127+
}
126128
return !ctx.settled;
127129
});
128130
}

test/hydration/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@ describe('hydration', () => {
118118
throw err;
119119
}
120120

121-
if (config.show) showOutput(cwd, {
122-
hydratable: true
123-
});
121+
if (config.show) {
122+
showOutput(cwd, {
123+
hydratable: true
124+
});
125+
}
124126
});
125127
}
126128

0 commit comments

Comments
 (0)