Skip to content

Commit

Permalink
Update prettier and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
w3nl committed Jul 2, 2020
1 parent b958c9f commit 09bd63e
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 48 deletions.
36 changes: 20 additions & 16 deletions .eslintrc.cjs
Expand Up @@ -3,32 +3,36 @@ module.exports = {
env: {
es6: true,
node: true,
browser: true
browser: true,
},
extends: ['@hckrnews/eslint-config'],
parserOptions: {
sourceType: "module",
parser: "babel-eslint",
sourceType: 'module',
parser: 'babel-eslint',
babelOptions: {
configFile: "babel.config.js",
}
configFile: 'babel.config.js',
},
},
rules: {
"import/extensions": ['error', {
"js": "never",
"mjs": "always",
"json": "always"
}]
'import/extensions': [
'error',
{
js: 'never',
mjs: 'always',
json: 'always',
},
],
'arrow-parens': ['error', 'always'],
},
overrides: [
{
files: [
"**/__tests__/*.{j,t}s?(x)",
"**/tests/unit/**/*.spec.{j,t}s?(x)"
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)',
],
env: {
jest: true
}
}
]
jest: true,
},
},
],
};
2 changes: 1 addition & 1 deletion src/AndGate.mjs
Expand Up @@ -6,7 +6,7 @@ class AndGate extends Gate {
}
}

const and = input => AndGate.create(input).output;
const and = (input) => AndGate.create(input).output;

export default AndGate;
export { AndGate, and };
2 changes: 1 addition & 1 deletion src/Gate.mjs
Expand Up @@ -4,7 +4,7 @@ class Gate {
constructor(inputs) {
if (
!Array.isArray(inputs) ||
!inputs.every(item => typeof item === 'boolean')
!inputs.every((item) => typeof item === 'boolean')
) {
throw new InvalidInputError(
inputs,
Expand Down
6 changes: 3 additions & 3 deletions src/Helper.js
Expand Up @@ -13,9 +13,9 @@ export default class Helper {
);
}

return parseInt(number, 10)
.toString(2)
.padStart(propositions, '0');
const binary = parseInt(number, 10).toString(2);

return binary.padStart(propositions, '0');
}

static totalTrueInputs(row) {
Expand Down
2 changes: 1 addition & 1 deletion src/NandGate.mjs
Expand Up @@ -6,7 +6,7 @@ class NandGate extends Gate {
}
}

const nand = input => NandGate.create(input).output;
const nand = (input) => NandGate.create(input).output;

export default NandGate;
export { NandGate, nand };
2 changes: 1 addition & 1 deletion src/NorGate.mjs
Expand Up @@ -6,7 +6,7 @@ class NorGate extends Gate {
}
}

const nor = input => NorGate.create(input).output;
const nor = (input) => NorGate.create(input).output;

export default NorGate;
export { NorGate, nor };
4 changes: 2 additions & 2 deletions src/NotGate.mjs
Expand Up @@ -2,11 +2,11 @@ import Gate from './Gate.mjs';

class NotGate extends Gate {
generateOutput() {
this.output = this.inputs.map(item => !item);
this.output = this.inputs.map((item) => !item);
}
}

const not = input => NotGate.create(input).output;
const not = (input) => NotGate.create(input).output;

export default NotGate;
export { NotGate, not };
2 changes: 1 addition & 1 deletion src/OrGate.mjs
Expand Up @@ -6,7 +6,7 @@ class OrGate extends Gate {
}
}

const or = input => OrGate.create(input).output;
const or = (input) => OrGate.create(input).output;

export default OrGate;
export { OrGate, or };
2 changes: 1 addition & 1 deletion src/XandGate.mjs
Expand Up @@ -7,7 +7,7 @@ class XandGate extends Gate {
}
}

const xand = input => XandGate.create(input).output;
const xand = (input) => XandGate.create(input).output;

export default XandGate;
export { XandGate, xand };
2 changes: 1 addition & 1 deletion src/XnandGate.mjs
Expand Up @@ -7,7 +7,7 @@ class XnandGate extends Gate {
}
}

const xnand = input => XnandGate.create(input).output;
const xnand = (input) => XnandGate.create(input).output;

export default XnandGate;
export { XnandGate, xnand };
2 changes: 1 addition & 1 deletion src/XnorGate.mjs
Expand Up @@ -7,7 +7,7 @@ class XnorGate extends Gate {
}
}

const xnor = input => XnorGate.create(input).output;
const xnor = (input) => XnorGate.create(input).output;

export default XnorGate;
export { XnorGate, xnor };
2 changes: 1 addition & 1 deletion src/XorGate.mjs
Expand Up @@ -7,7 +7,7 @@ class XorGate extends Gate {
}
}

const xor = input => XorGate.create(input).output;
const xor = (input) => XorGate.create(input).output;

export default XorGate;
export { XorGate, xor };
4 changes: 2 additions & 2 deletions tests/unit/and.spec.js
Expand Up @@ -55,7 +55,7 @@ const TestCases = [

describe.each(TestCases)('Test AndGate', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
const table = AndGate.create(inputTest[0]);
expect(table.output).toBe(inputTest[1]);
});
Expand All @@ -64,7 +64,7 @@ describe.each(TestCases)('Test AndGate', ({ description, expectedResult }) => {

describe.each(TestCases)('Test and', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
expect(and(inputTest[0])).toBe(inputTest[1]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/nand.spec.js
Expand Up @@ -55,7 +55,7 @@ const TestCases = [

describe.each(TestCases)('Test NandGate', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
const table = NandGate.create(inputTest[0]);
expect(table.output).toBe(inputTest[1]);
});
Expand All @@ -64,7 +64,7 @@ describe.each(TestCases)('Test NandGate', ({ description, expectedResult }) => {

describe.each(TestCases)('Test nand', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
expect(nand(inputTest[0])).toBe(inputTest[1]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/nor.spec.js
Expand Up @@ -55,7 +55,7 @@ const TestCases = [

describe.each(TestCases)('Test NorGate', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
const table = NorGate.create(inputTest[0]);
expect(table.output).toBe(inputTest[1]);
});
Expand All @@ -64,7 +64,7 @@ describe.each(TestCases)('Test NorGate', ({ description, expectedResult }) => {

describe.each(TestCases)('Test nor', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
expect(nor(inputTest[0])).toBe(inputTest[1]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/not.spec.js
Expand Up @@ -139,7 +139,7 @@ const TestCases = [

describe.each(TestCases)('Test NotGate', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
const table = NotGate.create(inputTest[0]);
expect(table.output).toMatchObject(inputTest[1]);
});
Expand All @@ -148,7 +148,7 @@ describe.each(TestCases)('Test NotGate', ({ description, expectedResult }) => {

describe.each(TestCases)('Test not', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
expect(not(inputTest[0])).toMatchObject(inputTest[1]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/or.spec.js
Expand Up @@ -55,7 +55,7 @@ const TestCases = [

describe.each(TestCases)('Test OrGate', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
const table = OrGate.create(inputTest[0]);
expect(table.output).toBe(inputTest[1]);
});
Expand All @@ -64,7 +64,7 @@ describe.each(TestCases)('Test OrGate', ({ description, expectedResult }) => {

describe.each(TestCases)('Test or', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
expect(or(inputTest[0])).toBe(inputTest[1]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/xand.spec.js
Expand Up @@ -55,7 +55,7 @@ const TestCases = [

describe.each(TestCases)('Test XandGate', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
const table = XandGate.create(inputTest[0]);
expect(table.output).toBe(inputTest[1]);
});
Expand All @@ -64,7 +64,7 @@ describe.each(TestCases)('Test XandGate', ({ description, expectedResult }) => {

describe.each(TestCases)('Test xand', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
expect(xand(inputTest[0])).toBe(inputTest[1]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/xnand.spec.js
Expand Up @@ -57,7 +57,7 @@ describe.each(TestCases)(
'Test XnandGate',
({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
const table = XnandGate.create(inputTest[0]);
expect(table.output).toBe(inputTest[1]);
});
Expand All @@ -67,7 +67,7 @@ describe.each(TestCases)(

describe.each(TestCases)('Test xnand', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
expect(xnand(inputTest[0])).toBe(inputTest[1]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/xnor.spec.js
Expand Up @@ -55,7 +55,7 @@ const TestCases = [

describe.each(TestCases)('Test XnorGate', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
const table = XnorGate.create(inputTest[0]);
expect(table.output).toBe(inputTest[1]);
});
Expand All @@ -64,7 +64,7 @@ describe.each(TestCases)('Test XnorGate', ({ description, expectedResult }) => {

describe.each(TestCases)('Test xnor', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
expect(xnor(inputTest[0])).toBe(inputTest[1]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/xor.spec.js
Expand Up @@ -55,7 +55,7 @@ const TestCases = [

describe.each(TestCases)('Test XorGate', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
const table = XorGate.create(inputTest[0]);
expect(table.output).toBe(inputTest[1]);
});
Expand All @@ -64,7 +64,7 @@ describe.each(TestCases)('Test XorGate', ({ description, expectedResult }) => {

describe.each(TestCases)('Test xor', ({ description, expectedResult }) => {
it(description, () => {
expectedResult.forEach(inputTest => {
expectedResult.forEach((inputTest) => {
expect(xor(inputTest[0])).toBe(inputTest[1]);
});
});
Expand Down

0 comments on commit 09bd63e

Please sign in to comment.