Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 6d28cc9

Browse files
committed
fix lint
1 parent e12bda5 commit 6d28cc9

16 files changed

+55
-54
lines changed

src/Option.hack

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class None<T> implements Option<T> {
4747
}
4848

4949
public function getValue(): T {
50-
invariant_violation("%s called on %s", __METHOD__, __CLASS__);
50+
invariant_violation('%s called on %s', __METHOD__, __CLASS__);
5151
}
5252
}
5353

src/ParseException.hack

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ParseException extends \Exception {
1717
) {
1818
parent::__construct(
1919
\sprintf(
20-
"%s:%d:%d %s",
20+
'%s:%d:%d %s',
2121
$sourceFile,
2222
$pos['line'] ?? -1,
2323
$pos['character'] ?? -1,

src/consumers/decl_name_in_context.hack

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ function decl_name_in_context(
2121
if ($ns === null || $ns === '') {
2222
return $name;
2323
}
24-
return $ns."\\".$name;
24+
return $ns.'\\'.$name;
2525
}

src/consumers/name_from_ast.hack

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ function name_from_ast(HHAST\Node $node): string {
2323
// If there's a leading `\` in the name, the first item is empty.
2424
return $node->getParts()->getChildrenOfItems()
2525
|> Vec\map($$, $x ==> $x?->getText() ?? '')
26-
|> Str\join($$, "\\");
26+
|> Str\join($$, '\\');
2727
}
2828

2929
if ($node is HHAST\SimpleTypeSpecifier) {
3030
return name_from_ast($node->getSpecifier());
3131
}
3232

3333
invariant_violation(
34-
"Expected Token or QualifiedName, got %s",
34+
'Expected Token or QualifiedName, got %s',
3535
\get_class($node),
3636
);
3737
}

src/consumers/parameters_from_ast.hack

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function parameters_from_ast(
2626
);
2727
$out = vec[];
2828
foreach ($params->getChildren() as $node) {
29-
invariant($node is HHAST\ListItem<_>, "Got non-listitem child");
29+
invariant($node is HHAST\ListItem<_>, 'Got non-listitem child');
3030
$item = $node->getItem();
3131
if ($item is HHAST\VariadicParameter) {
3232
$out[] = new ScannedParameter(

src/consumers/scope_from_ast.hack

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function scope_from_ast(
4747

4848
invariant(
4949
$body === null || $body is HHAST\NamespaceEmptyBody,
50-
"Expected a NamespaceBody or NamespaceEmptyBody",
50+
'Expected a NamespaceBody or NamespaceEmptyBody',
5151
);
5252

5353
$offset = $offsets[$i];

src/definitions/ScannedTypehint.hack

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ final class ScannedTypehint {
5858

5959
public function getShapeFields(): vec<ScannedShapeField> {
6060
$fields = $this->shapeFields;
61-
invariant($fields !== null, "Called getShapeFields, but not a shape");
61+
invariant($fields !== null, 'Called getShapeFields, but not a shape');
6262
return $fields;
6363
}
6464

tests/AliasingTest.hack

+7-7
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ final class AliasingTest extends \Facebook\HackTest\HackTest {
6969
$code = "<?hh\n".
7070
"namespace MyNamespace;\n".
7171
"use MyOtherNamespace\\{Foo, Bar};\n".
72-
"class MyClass implements Foo, Bar{}";
72+
'class MyClass implements Foo, Bar{}';
7373
$def = (await FileParser::fromDataAsync($code))->getClass(
7474
'MyNamespace\\MyClass',
7575
);
@@ -83,7 +83,7 @@ final class AliasingTest extends \Facebook\HackTest\HackTest {
8383
$code = "<?hh\n".
8484
"namespace MyNamespace;\n".
8585
"use MyOtherNamespace\\{Foo, Bar,};\n".
86-
"class MyClass implements Foo, Bar{}";
86+
'class MyClass implements Foo, Bar{}';
8787
$def = (await FileParser::fromDataAsync($code))->getClass(
8888
'MyNamespace\\MyClass',
8989
);
@@ -96,7 +96,7 @@ final class AliasingTest extends \Facebook\HackTest\HackTest {
9696
$code = "<?hh\n".
9797
"namespace MyNamespace;\n".
9898
"use MyOtherNamespace\\{Foo as Herp, Bar as Derp};\n".
99-
"class MyClass implements Herp, Derp {}";
99+
'class MyClass implements Herp, Derp {}';
100100
$def = (await FileParser::fromDataAsync($code))->getClass(
101101
'MyNamespace\\MyClass',
102102
);
@@ -128,7 +128,7 @@ final class AliasingTest extends \Facebook\HackTest\HackTest {
128128
$code = "<?hh\n".
129129
"namespace MyNamespace;\n".
130130
"use MyOtherNamespace\\Foo;\n".
131-
"function my_func(): Foo {}";
131+
'function my_func(): Foo {}';
132132
$def = (await FileParser::fromDataAsync($code))->getFunction(
133133
'MyNamespace\\my_func',
134134
);
@@ -141,7 +141,7 @@ final class AliasingTest extends \Facebook\HackTest\HackTest {
141141
$code = "<?hh\n".
142142
"namespace MyNamespace;\n".
143143
"use function MyOtherNamespace\\Foo;\n".
144-
"function my_func(): Foo {}";
144+
'function my_func(): Foo {}';
145145
$def = (await FileParser::fromDataAsync($code))->getFunction(
146146
'MyNamespace\\my_func',
147147
);
@@ -152,7 +152,7 @@ final class AliasingTest extends \Facebook\HackTest\HackTest {
152152
$code = "<?hh\n".
153153
"namespace MyNamespace;\n".
154154
"use const MyOtherNamespace\\Foo;\n".
155-
"function my_func(): Foo {}";
155+
'function my_func(): Foo {}';
156156
$def = (await FileParser::fromDataAsync($code))->getFunction(
157157
'MyNamespace\\my_func',
158158
);
@@ -201,7 +201,7 @@ final class AliasingTest extends \Facebook\HackTest\HackTest {
201201

202202
public async function testUseConflictingHSLNamespace(): Awaitable<void> {
203203
$code = "<?hh\n".
204-
"use namespace HH\Lib\{Dict, Keyset, Vec};".
204+
'use namespace HH\Lib\{Dict, Keyset, Vec};'.
205205
"function my_func(Dict\A \$_, Keyset\A \$_, Vec\A \$_): Awaitable<void> {}";
206206
$def = (await FileParser::fromDataAsync($code))->getFunction('my_func');
207207
expect(

tests/AttributesTest.hack

+10-10
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ class AttributesTest extends \Facebook\HackTest\HackTest {
3333

3434
public async function testSingleSimpleAttribute(): Awaitable<void> {
3535
$class = $this->findClass('ClassWithSimpleAttribute');
36-
expect($class->getAttributes())->toBeSame(dict["Foo" => vec[]]);
36+
expect($class->getAttributes())->toBeSame(dict['Foo' => vec[]]);
3737
}
3838

3939
public async function testMultipleSimpleAttributes(): Awaitable<void> {
4040
$class = $this->findClass('ClassWithSimpleAttributes');
4141
expect($class->getAttributes())->toBeSame(
42-
dict["Foo" => vec[], "Bar" => vec[]],
42+
dict['Foo' => vec[], 'Bar' => vec[]],
4343
);
4444
}
4545

@@ -105,12 +105,12 @@ class AttributesTest extends \Facebook\HackTest\HackTest {
105105
return varray[
106106
tuple("'herp'.'derp'", 'herpderp'),
107107
tuple("Foo\\Bar::class", "Foo\\Bar"),
108-
tuple("true", true),
109-
tuple("false", false),
110-
tuple("null", null),
111-
tuple("INF", \INF),
112-
tuple("+123", 123),
113-
tuple("-123", -123),
108+
tuple('true', true),
109+
tuple('false', false),
110+
tuple('null', null),
111+
tuple('INF', \INF),
112+
tuple('+123', 123),
113+
tuple('-123', -123),
114114
tuple('array()', varray[]),
115115
tuple('array(123)', varray[123]),
116116
tuple('array(123,)', varray[123]),
@@ -129,8 +129,8 @@ class AttributesTest extends \Facebook\HackTest\HackTest {
129129
tuple("vec['foo']", vec['foo']),
130130
tuple('keyset[123]', keyset[123]),
131131
tuple("dict[123 => '456']", dict[123 => '456']),
132-
tuple("\n<<<EOF\nHello!\nEOF\n", "Hello!"),
133-
tuple("\n<<<'EOF'\nHello!\nEOF\n", "Hello!"),
132+
tuple("\n<<<EOF\nHello!\nEOF\n", 'Hello!'),
133+
tuple("\n<<<'EOF'\nHello!\nEOF\n", 'Hello!'),
134134
tuple('010', 8),
135135
tuple('0x10', 16),
136136
tuple('0b10', 2),

tests/ClassContentsTest.hack

+3-3
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class ClassContentsTest extends \Facebook\HackTest\HackTest {
218218
"class Bar {\n".
219219
" const type FOO = Foo;\n".
220220
" function foo(self::FOO::BAR \$baz): Awaitable<void> {}\n".
221-
"}";
221+
'}';
222222
$parser = (await FileParser::fromDataAsync($data));
223223
$class = $parser->getClass('Bar');
224224
expect(
@@ -357,10 +357,10 @@ class ClassContentsTest extends \Facebook\HackTest\HackTest {
357357
): Awaitable<void> {
358358
$data = \sprintf(
359359
'<?hh %s class Foo { public async function bar(): %s {} }',
360-
$namespace === '' ? '' : "namespace ".$namespace.";",
360+
$namespace === '' ? '' : 'namespace '.$namespace.';',
361361
$returnText,
362362
);
363-
$className = \ltrim($namespace.'\Foo', "\\");
363+
$className = \ltrim($namespace.'\Foo', '\\');
364364
$parser = (await FileParser::fromDataAsync($data));
365365
$method = C\onlyx($parser->getClass($className)->getMethods());
366366

tests/NamingTest.hack

+17-17
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ class NamingTest extends \Facebook\HackTest\HackTest {
202202

203203
public async function testNamespaceResolutionDependingOnSourceType(
204204
): Awaitable<void> {
205-
$php = "<?php namespace Foo; class MyClass extends Collection {}";
206-
$hack = "<?hh namespace Foo; class MyClass extends Collection {}";
205+
$php = '<?php namespace Foo; class MyClass extends Collection {}';
206+
$hack = '<?hh namespace Foo; class MyClass extends Collection {}';
207207

208208
$php_class = (await FileParser::fromDataAsync($php))->getClass(
209-
"Foo\\MyClass",
209+
'Foo\\MyClass',
210210
);
211211
$hack_class = (await FileParser::fromDataAsync($hack))->getClass(
212-
"Foo\\MyClass",
212+
'Foo\\MyClass',
213213
);
214214

215215
// We used to distinguish between PHP and Hack files here, but not anymore,
@@ -226,10 +226,10 @@ class NamingTest extends \Facebook\HackTest\HackTest {
226226
$hack = '<?hh namespace Foo; function myfunc(): string {}';
227227

228228
$php_func = (await FileParser::fromDataAsync($php))->getFunction(
229-
"Foo\\myfunc",
229+
'Foo\\myfunc',
230230
);
231231
$hack_func = (await FileParser::fromDataAsync($hack))->getFunction(
232-
"Foo\\myfunc",
232+
'Foo\\myfunc',
233233
);
234234

235235
expect($php_func->getReturnType()?->getTypeName())->toBeSame('string');
@@ -241,9 +241,9 @@ class NamingTest extends \Facebook\HackTest\HackTest {
241241
"namespace Foo;\n".
242242
"class MyClass {\n".
243243
" function foo(): this { }\n".
244-
"}";
244+
'}';
245245
$parser = await FileParser::fromDataAsync($code);
246-
$class = $parser->getClass("Foo\\MyClass");
246+
$class = $parser->getClass('Foo\\MyClass');
247247
$method = $class->getMethods()[0];
248248
expect($method->getReturnType()?->getTypeName())->toBeSame('this');
249249
}
@@ -253,9 +253,9 @@ class NamingTest extends \Facebook\HackTest\HackTest {
253253
"namespace Foo;\n".
254254
"class MyClass<T> {\n".
255255
" function foo(): T { }\n".
256-
"}";
256+
'}';
257257
$parser = await FileParser::fromDataAsync($code);
258-
$class = $parser->getClass("Foo\\MyClass");
258+
$class = $parser->getClass('Foo\\MyClass');
259259
$method = $class->getMethods()[0];
260260
expect($method->getReturnType()?->getTypeName())->toBeSame('T');
261261
}
@@ -266,9 +266,9 @@ class NamingTest extends \Facebook\HackTest\HackTest {
266266
"namespace Foo;\n".
267267
"class MyClass<T> {\n".
268268
" function foo(): ?T { }\n".
269-
"}";
269+
'}';
270270
$parser = await FileParser::fromDataAsync($code);
271-
$class = $parser->getClass("Foo\\MyClass");
271+
$class = $parser->getClass('Foo\\MyClass');
272272
$method = $class->getMethods()[0];
273273
expect($method->getReturnType()?->getTypeName())->toBeSame('T');
274274
expect($method->getReturnType()?->isNullable())->toBeTrue();
@@ -279,9 +279,9 @@ class NamingTest extends \Facebook\HackTest\HackTest {
279279
"namespace Foo;\n".
280280
"class MyClass {\n".
281281
" function foo<T>(): T { }\n".
282-
"}";
282+
'}';
283283
$parser = await FileParser::fromDataAsync($code);
284-
$class = $parser->getClass("Foo\\MyClass");
284+
$class = $parser->getClass('Foo\\MyClass');
285285
$method = $class->getMethods()[0];
286286
expect($method->getReturnType()?->getTypeName())->toBeSame('T');
287287
}
@@ -300,7 +300,7 @@ class NamingTest extends \Facebook\HackTest\HackTest {
300300
" ): TClassGeneric {}\n".
301301
"}\n";
302302
$parser = await FileParser::fromDataAsync($code);
303-
$class = $parser->getClass("Foo\\MyClass");
303+
$class = $parser->getClass('Foo\\MyClass');
304304
$method = $class->getMethods()[0];
305305
expect($method->getReturnType()?->getTypeName())->toBeSame('TClassGeneric');
306306
expect($method->getParameters()[0]->getTypehint()?->getTypeName())
@@ -312,9 +312,9 @@ class NamingTest extends \Facebook\HackTest\HackTest {
312312
"namespace Foo;\n".
313313
"class MyClass {\n".
314314
" function foo<T>(T \$bar): Awaitable<void> { }\n".
315-
"}";
315+
'}';
316316
$parser = await FileParser::fromDataAsync($code);
317-
$class = $parser->getClass("Foo\\MyClass");
317+
$class = $parser->getClass('Foo\\MyClass');
318318
$method = $class->getMethods()[0];
319319
expect($method->getParameters()[0]->getTypehint()?->getTypeName())
320320
->toBeSame('T');

tests/RelationshipsTest.hack

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ class RelationshipsTest extends \Facebook\HackTest\HackTest {
9797
" Foo::herp insteadof Bar;\n".
9898
" Bar::herp as derp;\n".
9999
" };\n".
100-
"}";
100+
'}';
101101
$def = (await FileParser::fromDataAsync($data))->getClass('MyClass');
102102
expect($def->getTraitNames())->toBeSame(vec['Foo', 'Bar']);
103103
}
104104

105105
public async function testUsesTraitsInNamespace(): Awaitable<void> {
106106
$data =
107-
"<?hh\n"."namespace MyNamespace;".'class Foo { use Herp; use Derp; }';
107+
"<?hh\n".'namespace MyNamespace;'.'class Foo { use Herp; use Derp; }';
108108
$def = (await FileParser::fromDataAsync($data))->getClass('MyNamespace\\Foo');
109109
expect($def->getTraitNames())->toBeSame(
110110
vec['MyNamespace\\Herp', 'MyNamespace\\Derp'],

tests/ShapesTest.hack

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class ShapesTest extends \Facebook\HackTest\HackTest {
4747

4848
public async function testDocComments(): Awaitable<void> {
4949
expect((await $this->getTypeAliasAsync())->getDocComment())->toBeSame(
50-
"/** A shape used for testing */",
50+
'/** A shape used for testing */',
5151
);
5252
expect(Vec\map((await $this->getFieldsAsync()), $f ==> $f->getDocComment()))
5353
->toBeSame(vec['/** The foo */', '/** The bar */']);

tests/SourceTypeTest.hack

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class SourceTypeTest extends \Facebook\HackTest\HackTest {
2020
tuple('<?hh', SourceType::HACK_PARTIAL),
2121
tuple('<?hh // foo', SourceType::HACK_PARTIAL),
2222
tuple("<?hh\n// strict", SourceType::HACK_PARTIAL),
23-
tuple("<?hh // strict", SourceType::HACK_STRICT),
24-
tuple("<?hh //strict", SourceType::HACK_STRICT),
25-
tuple("<?hh // decl", SourceType::HACK_DECL),
23+
tuple('<?hh // strict', SourceType::HACK_STRICT),
24+
tuple('<?hh //strict', SourceType::HACK_STRICT),
25+
tuple('<?hh // decl', SourceType::HACK_DECL),
2626
];
2727
}
2828

tests/TreeTest.hack

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ use function Facebook\FBExpect\expect;
1414

1515
final class TreeTest extends \Facebook\HackTest\HackTest {
1616
public function testTreeDefs(): void {
17+
/* HHAST_IGNORE_ERROR[DontUseAsioJoin] */
1718
$parser = \HH\Asio\join(TreeParser::fromPathAsync(__DIR__.'/data/'));
1819
// From multiple files
1920
$classes = $parser->getClassNames();
20-
expect($classes)->toContain("SingleNamespace\\SimpleClass");
21+
expect($classes)->toContain('SingleNamespace\\SimpleClass');
2122
expect($classes)->toContain("Namespaces\\AreNestedNow\\SimpleClass");
2223
}
2324
}

tests/TypehintTest.hack

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ final class TypehintTest extends \Facebook\HackTest\HackTest {
9696
): Awaitable<void> {
9797
$code = "<?hh \n".
9898
"namespace MyNamespace;\n".
99-
"function main(".
99+
'function main('.
100100
$input.
101101
" \$_): Awaitable<void> {}\n";
102102
$def = (await FileParser::fromDataAsync($code))->getFunction('MyNamespace\\main');
@@ -142,7 +142,7 @@ final class TypehintTest extends \Facebook\HackTest\HackTest {
142142
string $name,
143143
string $text,
144144
): Awaitable<void> {
145-
$code = "<?hh \n"."function main(".$input." \$_): Awaitable<void> {}\n";
145+
$code = "<?hh \n".'function main('.$input." \$_): Awaitable<void> {}\n";
146146
$def = (await FileParser::fromDataAsync($code))->getFunction('main');
147147
$type = $def->getParameters()[0]->getTypehint();
148148
expect($type)->toNotBeNull();

0 commit comments

Comments
 (0)