Skip to content

Commit 5ab98d2

Browse files
committed
Fix lints
1 parent a71d737 commit 5ab98d2

File tree

7 files changed

+47
-58
lines changed

7 files changed

+47
-58
lines changed

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%{"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [], [], "hexpm"},
22
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [], [], "hexpm"},
3-
"credo": {:hex, :credo, "0.8.6", "335f723772d35da499b5ebfdaf6b426bfb73590b6fcbc8908d476b75f8cbca3f", [], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"},
3+
"credo": {:hex, :credo, "0.8.6", "335f723772d35da499b5ebfdaf6b426bfb73590b6fcbc8908d476b75f8cbca3f", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"},
44
"earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [], [], "hexpm"},
55
"estree": {:hex, :estree, "2.6.1", "0a17cc0e9e35315dc4fcd79d30a746b1f3e9ed654be6084ce882ab491165ae22", [], [], "hexpm"},
66
"ex_doc": {:hex, :ex_doc, "0.16.2", "3b3e210ebcd85a7c76b4e73f85c5640c011d2a0b2f06dcdf5acdb2ae904e5084", [], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},

rollup.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export default {
88
plugins: [
99
nodeResolve({ jsnext: true }),
1010
babel({
11-
babelrc: false
11+
babelrc: false,
1212
}),
1313
minify({
1414
keepFnName: true,
15-
keepClassName: true
16-
})
15+
keepClassName: true,
16+
}),
1717
],
18-
targets: [{ dest: 'priv/build/iife/ElixirScript.Core.js', format: 'iife' }]
18+
targets: [{ dest: 'priv/build/iife/ElixirScript.Core.js', format: 'iife' }],
1919
};

src/javascript/lib/core/functions.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ function call_property(item, property) {
2525
throw new Error(`Property ${property} not found in ${item}`);
2626
}
2727

28-
if (
29-
item.get(prop) instanceof Function ||
30-
typeof item.get(prop) === 'function'
31-
) {
28+
if (item.get(prop) instanceof Function || typeof item.get(prop) === 'function') {
3229
return item.get(prop)();
3330
}
3431
return item.get(prop);
@@ -97,22 +94,22 @@ function build_namespace(ns, ns_string) {
9794
function map_to_object(map, options = []) {
9895
const object = {};
9996

100-
var type_keys = proplists.get_value(Symbol("keys"), options);
101-
var symbols = proplists.get_value(Symbol("symbols"), options);
97+
const type_keys = proplists.get_value(Symbol('keys'), options);
98+
const symbols = proplists.get_value(Symbol('symbols'), options);
10299

103-
for (var [key, value] of map.entries()) {
104-
if (type_keys == Symbol("string") && typeof key == 'number') {
100+
for (let [key, value] of map.entries()) {
101+
if (type_keys === Symbol('string') && typeof key === 'number') {
105102
key = key.toString();
106103
} else if (
107-
(type_keys == Symbol("string") || symbols != Symbol("undefined"))
108-
&& typeof key == 'symbol'
104+
(type_keys === Symbol('string') || symbols !== Symbol('undefined')) &&
105+
typeof key === 'symbol'
109106
) {
110107
key = erlang.atom_to_binary(key);
111108
}
112109

113110
if (value instanceof Map) {
114111
object[key] = map_to_object(value, options);
115-
} else if (symbols != Symbol("undefined") && typeof value == 'symbol') {
112+
} else if (symbols !== Symbol('undefined') && typeof value === 'symbol') {
116113
object[key] = erlang.atom_to_binary(value);
117114
} else {
118115
object[key] = value;
@@ -154,12 +151,12 @@ function split_at(value, position) {
154151

155152
for (const character of value) {
156153
if (index < position) {
157-
first = first + character;
154+
first += character;
158155
} else {
159-
second = second + character;
156+
second += character;
160157
}
161158

162-
index = index + 1;
159+
index += 1;
163160
}
164161

165162
return new Core.Tuple(first, second);
@@ -173,5 +170,5 @@ export default {
173170
map_to_object,
174171
trampoline,
175172
Recurse,
176-
split_at
173+
split_at,
177174
};

src/javascript/lib/core/protocol.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Protocol {
77
this.fallback = null;
88

99
function createFun(funName) {
10-
return function(...args) {
10+
return function (...args) {
1111
const thing = args[0];
1212
let fun = null;
1313

@@ -36,7 +36,7 @@ class Protocol {
3636
this.hasImplementation(thing)
3737
) {
3838
fun = this.registry.get(
39-
thing.get(Symbol.for('__struct__')).__MODULE__
39+
thing.get(Symbol.for('__struct__')).__MODULE__,
4040
)[funName];
4141
} else if (thing !== null && this.hasImplementation(thing)) {
4242
fun = this.registry.get(thing.constructor)[funName];

src/javascript/lib/core/special_forms.js

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,9 @@ function cond(...clauses) {
1414
throw new Error();
1515
}
1616

17-
function _for(expression, generators, collectable_protocol, into = []) {
18-
let [result, fun] = collectable_protocol.into(into);
19-
20-
const generatedValues = run_list_generators(generators.pop()(), generators);
21-
22-
for (const value of generatedValues) {
23-
if (expression.guard.apply(this, value)) {
24-
result = fun(
25-
result,
26-
new Core.Tuple(Symbol.for('cont'), expression.fn.apply(this, value))
27-
);
28-
}
29-
}
30-
31-
return fun(result, Symbol.for('done'));
32-
}
33-
3417
function run_list_generators(generator, generators) {
35-
if (generators.length == 0) {
36-
return generator.map(x => {
18+
if (generators.length === 0) {
19+
return generator.map((x) => {
3720
if (Array.isArray(x)) {
3821
return x;
3922
}
@@ -52,13 +35,21 @@ function run_list_generators(generator, generators) {
5235
return run_list_generators(next_gen, generators);
5336
}
5437

55-
function _try(
56-
do_fun,
57-
rescue_function,
58-
catch_fun,
59-
else_function,
60-
after_function
61-
) {
38+
function _for(expression, generators, collectable_protocol, into = []) {
39+
let [result, fun] = collectable_protocol.into(into);
40+
41+
const generatedValues = run_list_generators(generators.pop()(), generators);
42+
43+
for (const value of generatedValues) {
44+
if (expression.guard.apply(this, value)) {
45+
result = fun(result, new Core.Tuple(Symbol.for('cont'), expression.fn.apply(this, value)));
46+
}
47+
}
48+
49+
return fun(result, Symbol.for('done'));
50+
}
51+
52+
function _try(do_fun, rescue_function, catch_fun, else_function, after_function) {
6253
let result = null;
6354

6455
try {
@@ -141,7 +132,7 @@ function _with(...args) {
141132
return successFunction(...argsToPass);
142133
}
143134

144-
function receive(clauses, after) {
135+
function receive() {
145136
console.warn('Receive not supported');
146137
}
147138

@@ -151,5 +142,5 @@ export default {
151142
_for,
152143
_try,
153144
_with,
154-
receive
145+
receive,
155146
};

src/javascript/lib/core/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ export default {
4343
create,
4444
update,
4545
read,
46-
remove
46+
remove,
4747
};
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import test from 'ava';
22
import Core from '../../lib/core';
3+
34
const Functions = Core.Functions;
45

5-
test('call_property', t => {
6+
test('call_property', (t) => {
67
t.is(Functions.call_property(1, 'toString'), '1');
78
t.is(Functions.call_property([], 'toString'), '');
89
t.is(Functions.call_property([], 'length'), 0);
@@ -13,27 +14,27 @@ test('call_property', t => {
1314
t.is(Functions.call_property({ id: 0 }, 'id'), 0);
1415
});
1516

16-
test('split_at', t => {
17+
test('split_at', (t) => {
1718
t.deepEqual(Functions.split_at('sweetelixir', 5).values, ['sweet', 'elixir']);
1819
t.deepEqual(Functions.split_at('sweetelixir', -6).values, [
1920
'sweet',
20-
'elixir'
21+
'elixir',
2122
]);
2223
t.deepEqual(Functions.split_at('abc', 0).values, ['', 'abc']);
2324
t.deepEqual(Functions.split_at('abc', 1000).values, ['abc', '']);
2425
t.deepEqual(Functions.split_at('abc', -1000).values, ['', 'abc']);
2526
t.deepEqual(Functions.split_at('😀abélkm', 4).values, ['😀abé', 'lkm']);
2627
});
2728

28-
test('map_to_object/2', t => {
29+
test('map_to_object/2', (t) => {
2930
const map = new Map([
30-
[Symbol.for('key'), "value"],
31-
[Symbol.for('anotherKey'), "value2"],
31+
[Symbol.for('key'), 'value'],
32+
[Symbol.for('anotherKey'), 'value2'],
3233
]);
3334

3435
const options = [new Core.Tuple(Symbol.for('keys'), Symbol.for('strings'))];
3536

3637
const result = Functions.map_to_object(map, options);
3738

38-
t.deepEqual(result, {key: "value", anotherKey: "value2"});
39+
t.deepEqual(result, { key: 'value', anotherKey: 'value2' });
3940
});

0 commit comments

Comments
 (0)