Skip to content

Commit

Permalink
Update linter configuration
Browse files Browse the repository at this point in the history
Fixes #246
  • Loading branch information
dubzzz committed Nov 26, 2018
1 parent b932e54 commit fd8e00c
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion prebuild/property.ts
@@ -1,4 +1,4 @@
import { arbCommas, commas, iota, joiner, txCommas } from './helpers';
import { commas, iota, joiner, txCommas } from './helpers';

const predicateFor = (num: number, isAsync: boolean): string =>
isAsync
Expand Down
1 change: 0 additions & 1 deletion test/e2e/GenerateAllValues.spec.ts
@@ -1,4 +1,3 @@
import * as assert from 'assert';
import * as prand from 'pure-rand';
import * as fc from '../../src/fast-check';

Expand Down
9 changes: 5 additions & 4 deletions test/e2e/ModelBased.spec.ts
@@ -1,5 +1,4 @@
import * as assert from 'assert';
import * as prand from 'pure-rand';
import * as fc from '../../src/fast-check';

interface IList<T> {
Expand All @@ -8,7 +7,9 @@ interface IList<T> {
size(): number;
}

type Model = { num: number };
interface Model {
num: number;
}

class PushCommand implements fc.Command<Model, IList<number>> {
constructor(readonly value: number) {}
Expand Down Expand Up @@ -66,8 +67,8 @@ describe(`Model Based (seed: ${seed})`, () => {
start: number = 0;
end: number = 0;
data: number[];
constructor(size: number) {
this.data = [...Array(size)].fill(null);
constructor(len: number) {
this.data = [...Array(len)].fill(null);
}
push = (v: number) => {
this.data[this.end] = v;
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/Shadows.spec.ts
Expand Up @@ -39,7 +39,7 @@ class Space {
}
toString() {
return `Space(grid{x:${this.dim_x},y:${this.dim_y}},solution{x:${this.solution_x},y:${this.solution_y}},initial{x:${
this.initial_y
this.initial_x
},y:${this.initial_y}})`;
}
}
Expand Down
9 changes: 5 additions & 4 deletions test/unit/check/arbitrary/ConstantArbitrary.spec.ts
Expand Up @@ -2,9 +2,9 @@ import * as assert from 'assert';
import * as fc from '../../../../lib/fast-check';

import { clonedConstant, constant, constantFrom } from '../../../../src/check/arbitrary/ConstantArbitrary';
import { cloneMethod } from '../../../../src/fast-check';

import * as stubRng from '../../stubs/generators';
import { cloneMethod } from '../../../../src/fast-check';

const cloneable = { [cloneMethod]: () => cloneable };

Expand All @@ -16,7 +16,7 @@ describe('ConstantArbitrary', () => {
assert.equal(g, 42);
});
it('Should always return the original instance', () => {
let instance = ['hello'];
const instance = ['hello'];
const mrng = stubRng.mutable.nocall();
const g = constant(instance).generate(mrng).value;
assert.deepEqual(g, ['hello']);
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('ConstantArbitrary', () => {
fc.property(fc.array(fc.string(), 1, 10), fc.integer(), fc.nat(), (data, seed, idx) => {
const mrng = stubRng.mutable.fastincrease(seed);
const arb = constantFrom(...data);
for (let id = 0; id != 10000; ++id) {
for (let id = 0; id !== 10000; ++id) {
const g = arb.generate(mrng).value;
if (g === data[idx % data.length]) return true;
}
Expand Down Expand Up @@ -72,11 +72,12 @@ describe('ConstantArbitrary', () => {
let clonedOnce = false;
const mrng = stubRng.mutable.nocall();
const g = clonedConstant({
[cloneMethod]: function() {
[cloneMethod]() {
clonedOnce = true;
return this;
}
}).generate(mrng).value;
assert.ok(g != null);
assert.ok(clonedOnce);
});
});
Expand Down
5 changes: 2 additions & 3 deletions test/unit/check/arbitrary/FrequencyArbitrary.spec.ts
@@ -1,4 +1,3 @@
import * as assert from 'assert';
import * as fc from '../../../../lib/fast-check';

import { frequency } from '../../../../src/check/arbitrary/FrequencyArbitrary';
Expand All @@ -19,7 +18,7 @@ describe('FrequencyArbitrary', () => {
rng(seed)
).value;
const gOneOf = oneof(...choices.map(stubArb.counter)).generate(rng(seed)).value;
return gFreq == gOneOf;
return gFreq === gOneOf;
})
));
it('Should produce the same as oneof with sum of weights elements', () =>
Expand All @@ -33,7 +32,7 @@ describe('FrequencyArbitrary', () => {
...choices.map(c => Object({ weight: c[1], arbitrary: stubArb.counter(c[0]) }))
).generate(rng(seed)).value;
const gOneOf = oneof(...choicesOneOf.map(stubArb.counter)).generate(rng(seed)).value;
return gFreq == gOneOf;
return gFreq === gOneOf;
})
));
});
Expand Down
3 changes: 1 addition & 2 deletions test/unit/check/arbitrary/ObjectArbitrary.spec.ts
Expand Up @@ -9,8 +9,7 @@ import {
jsonObject,
unicodeJsonObject,
json,
unicodeJson,
ObjectConstraints
unicodeJson
} from '../../../../src/check/arbitrary/ObjectArbitrary';

import * as stubRng from '../../stubs/generators';
Expand Down
11 changes: 5 additions & 6 deletions test/unit/check/arbitrary/StringArbitrary.spec.ts
@@ -1,15 +1,14 @@
import * as assert from 'assert';
import * as fc from '../../../../lib/fast-check';

import { constantFrom } from '../../../../src/check/arbitrary/ConstantArbitrary';
import {
stringOf,
string,
asciiString,
string16bits,
unicodeString,
base64String,
hexaString,
base64String
string,
string16bits,
stringOf,
unicodeString
} from '../../../../src/check/arbitrary/StringArbitrary';

import * as genericHelper from './generic/GenericArbitraryHelper';
Expand Down
3 changes: 1 addition & 2 deletions test/unit/check/arbitrary/definition/Arbitrary.spec.ts
@@ -1,17 +1,16 @@
import * as assert from 'assert';
import * as fc from '../../../../../lib/fast-check';

import { constant } from '../../../../../src/check/arbitrary/ConstantArbitrary';
import { Arbitrary } from '../../../../../src/check/arbitrary/definition/Arbitrary';
import { Shrinkable } from '../../../../../src/check/arbitrary/definition/Shrinkable';
import { constant } from '../../../../../src/check/arbitrary/ConstantArbitrary';
import { nat } from '../../../../../src/check/arbitrary/IntegerArbitrary';
import { tuple } from '../../../../../src/check/arbitrary/TupleArbitrary';
import { Random } from '../../../../../src/random/generator/Random';
import { stream } from '../../../../../src/stream/Stream';

import * as genericHelper from '../generic/GenericArbitraryHelper';

import * as stubArb from '../../../stubs/arbitraries';
import * as stubRng from '../../../stubs/generators';

class ForwardArbitrary extends Arbitrary<number> {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/check/runner/Sampler.spec.ts
Expand Up @@ -50,7 +50,7 @@ describe('Sampler', () => {
fc.assert(
fc.property(fc.nat(MAX_NUM_RUNS), fc.integer(), (num, start) => {
const arb = stubArb.counter(start);
const out = sample(arb, num);
sample(arb, num);
assert.equal(arb.generatedValues.length, num, 'Should not call the arbitrary too many times');
})
));
Expand Down Expand Up @@ -189,7 +189,7 @@ describe('Sampler', () => {
fc.property(fc.nat(MAX_NUM_RUNS), fc.integer(), (num, start) => {
const classify = (g: number) => g.toString();
const arb = stubArb.counter(start);
const out = statistics(arb, classify, { numRuns: num, logger: (v: string) => {} });
statistics(arb, classify, { numRuns: num, logger: (v: string) => {} });
assert.equal(arb.generatedValues.length, num, 'Should not call the arbitrary too many times');
})
));
Expand Down
11 changes: 5 additions & 6 deletions test/unit/random/generator/Random.spec.ts
@@ -1,4 +1,3 @@
import * as assert from 'assert';
import * as prand from 'pure-rand';
import * as fc from '../../../../lib/fast-check';

Expand All @@ -11,7 +10,7 @@ describe('Random', () => {
fc.assert(
fc.property(fc.integer(), fc.nat(31), fc.nat(MAX_SIZE), (seed, n, num) => {
const mrng = new Random(prand.xorshift128plus(seed));
for (let idx = 0; idx != num; ++idx) {
for (let idx = 0; idx !== num; ++idx) {
const v = mrng.next(n);
if (v < 0 || v > (((1 << n) - 1) | 0)) return false;
}
Expand All @@ -26,7 +25,7 @@ describe('Random', () => {
const mrng = new Random(prand.xorshift128plus(seed));
const min = a < b ? a : b;
const max = a < b ? b : a;
for (let idx = 0; idx != num; ++idx) {
for (let idx = 0; idx !== num; ++idx) {
const v = mrng.nextInt(min, max);
if (min > v || max < v) return false;
}
Expand All @@ -38,7 +37,7 @@ describe('Random', () => {
fc.property(fc.integer(), fc.nat(MAX_SIZE), (seed, num) => {
const mrng1 = new Random(prand.xorshift128plus(seed));
const mrng2 = new Random(prand.xorshift128plus(seed));
for (let idx = 0; idx != num; ++idx) if (mrng1.nextInt() != mrng2.nextInt()) return false;
for (let idx = 0; idx !== num; ++idx) if (mrng1.nextInt() !== mrng2.nextInt()) return false;
return true;
})
));
Expand All @@ -48,7 +47,7 @@ describe('Random', () => {
fc.assert(
fc.property(fc.integer(), fc.nat(MAX_SIZE), (seed, num) => {
const mrng = new Random(prand.xorshift128plus(seed));
for (let idx = 0; idx != num; ++idx) {
for (let idx = 0; idx !== num; ++idx) {
const v = mrng.nextDouble();
if (v < 0 || v >= 1) return false;
}
Expand All @@ -62,7 +61,7 @@ describe('Random', () => {
fc.property(fc.integer(), fc.nat(MAX_SIZE), (seed, num) => {
const mrng1 = new Random(prand.xorshift128plus(seed));
const mrng2 = mrng1.clone();
for (let idx = 0; idx != num; ++idx) if (mrng1.nextInt() != mrng2.nextInt()) return false;
for (let idx = 0; idx !== num; ++idx) if (mrng1.nextInt() !== mrng2.nextInt()) return false;
return true;
})
));
Expand Down
1 change: 0 additions & 1 deletion test/unit/stream/Stream.spec.ts
Expand Up @@ -290,7 +290,6 @@ describe('Stream', () => {
assert.deepEqual(v, 19);
});
it('Should be null for empty streams', () => {
function* g(): IterableIterator<number> {}
let v = Stream.nil<number>().getNthOrLast(10);
assert.deepEqual(v, null);
});
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Expand Up @@ -5,6 +5,7 @@
"alwaysStrict": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"removeComments": false,
"preserveConstEnums": true,
"strictNullChecks": true,
Expand Down
1 change: 0 additions & 1 deletion tslint.json
Expand Up @@ -13,7 +13,6 @@
"no-bitwise": false,
"no-namespace": false,
"no-unnecessary-callback-wrapper": false, // a.map(f) != a.map(e => f(e))
"no-unused-variable": true,
"unified-signatures": false,
// Format (handled by prettier if needed)
"curly": false,
Expand Down

0 comments on commit fd8e00c

Please sign in to comment.