Skip to content

Commit 9733a05

Browse files
committed
Fixing lints
1 parent 2a4b9a1 commit 9733a05

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
'no-restricted-syntax': 'off',
77
'no-underscore-dangle': 'off',
88
'import/extensions': 'off',
9+
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
910
},
1011
extends: 'airbnb-base',
1112
plugins: ['import'],

src/javascript/lib/core/erlang_compat/binary.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ function copy(subject, n = 1) {
1010
}
1111

1212
function first(subject) {
13-
if (subject.length == 0) {
14-
throw new Error(`Binary is of length 0`);
13+
if (subject.length === 0) {
14+
throw new Error('Binary is of length 0');
1515
}
1616
return at(subject, 0);
1717
}
1818

1919
function last(subject) {
20-
if (subject.length == 0) {
21-
throw new Error(`Binary is of length 0`);
20+
if (subject.length === 0) {
21+
throw new Error('Binary is of length 0');
2222
}
2323
return subject.slice(-1);
2424
}
@@ -29,20 +29,19 @@ function list_to_bin(bytelist) {
2929

3030
function part(subject, posOrTuple, len = null) {
3131
if (len === null) {
32-
var pos;
33-
[pos, len] = posOrTuple.values;
34-
return subject.substr(pos, len);
35-
} else {
36-
return subject.substr(posOrTuple, len);
32+
const [pos, theLen] = posOrTuple.values;
33+
return subject.substr(pos, theLen);
3734
}
35+
36+
return subject.substr(posOrTuple, len);
3837
}
3938

40-
//TODO: Support more options
41-
//TODO: pattern cannot be list of strings
39+
// TODO: Support more options
40+
// TODO: pattern cannot be list of strings
4241
function replace(subject, pattern, replacement, options = []) {
4342
const opt_global = proplists.get_value(Symbol.for('global'), options);
4443

45-
var regex;
44+
let regex;
4645
if (opt_global !== Symbol.for('undefined')) {
4746
regex = new RegExp(pattern, 'g');
4847
} else {
@@ -52,8 +51,8 @@ function replace(subject, pattern, replacement, options = []) {
5251
return subject.replace(regex, replacement);
5352
}
5453

55-
//TODO: Support more options, global is implied
56-
//TODO: pattern cannot be list of strings
54+
// TODO: Support more options, global is implied
55+
// TODO: pattern cannot be list of strings
5756
function split(subject, pattern, options = []) {
5857
return subject.split(pattern);
5958
}

src/javascript/tests/core/erlang_compat/binary_spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ test('replace/3', (t) => {
5555
});
5656

5757
test('replace/4', (t) => {
58-
const result = Core.binary.replace('abcb', 'b', 'c', [new Core.Tuple(Symbol.for('global'), true)]);
58+
const result = Core.binary.replace('abcb', 'b', 'c', [
59+
new Core.Tuple(Symbol.for('global'), true),
60+
]);
5961
t.deepEqual(result, 'accc');
6062
});
6163

0 commit comments

Comments
 (0)