Commit 4e95e3f3 authored by Yannick Li's avatar Yannick Li
Browse files

ESLint: automatic fixes

parent b364d4a0
......@@ -41,9 +41,9 @@ interface IGameState {
class Game extends React.Component<{}, IGameState> {
constructor(props: any) {
super(props);
let CONFIG = require('../config.json');
let session = client.Session.Companion.connect(CONFIG.dbName, CONFIG.serviceUrl, CONFIG.credentials);
let collection = session.openCollection("sudoku", false);
const CONFIG = require('../config.json');
const session = client.Session.Companion.connect(CONFIG.dbName, CONFIG.serviceUrl, CONFIG.credentials);
const collection = session.openCollection("sudoku", false);
this.state = {
session: session,
collection: collection
......
......@@ -90,8 +90,8 @@ describe ("getValue", () => {
const wrapper = shallow(<Grid initial = {initVal}/>)
const grid = wrapper.instance()
let envs = Array(9)
let newvals = Array(9)
const envs = Array(9)
const newvals = Array(9)
for (let i = 0; i<9; i++){
envs[i] = new crdtlib.utils.SimpleEnvironment(
new crdtlib.utils.ClientUId("myClientId"+i));
......@@ -147,9 +147,9 @@ describe("checkLine", () => {
const wrapper = shallow(<Grid initial = {initVal}/>)
const grid = wrapper.instance()
let env = new crdtlib.utils.SimpleEnvironment(
const env = new crdtlib.utils.SimpleEnvironment(
new crdtlib.utils.ClientUId("myClientId1"));
let newval = new crdtlib.crdt.MVRegister()
const newval = new crdtlib.crdt.MVRegister()
newval.set("1", env.tick())
grid.state.cells[45].merge(newval)
......@@ -180,9 +180,9 @@ describe("checkColumn", () => {
const wrapper = shallow(<Grid initial = {initVal}/>)
const grid = wrapper.instance()
let env = new crdtlib.utils.SimpleEnvironment(
const env = new crdtlib.utils.SimpleEnvironment(
new crdtlib.utils.ClientUId("myClientId1"));
let newval = new crdtlib.crdt.MVRegister()
const newval = new crdtlib.crdt.MVRegister()
newval.set("1", env.tick())
grid.state.cells[5].merge(newval)
......@@ -213,9 +213,9 @@ describe("checkBlock", () => {
const wrapper = shallow(<Grid initial = {initVal}/>)
const grid = wrapper.instance()
let env = new crdtlib.utils.SimpleEnvironment(
const env = new crdtlib.utils.SimpleEnvironment(
new crdtlib.utils.ClientUId("myClientId"));
let newval = new crdtlib.crdt.MVRegister()
const newval = new crdtlib.crdt.MVRegister()
newval.set("1", env.tick())
grid.state.cells[3].merge(newval)
......@@ -321,9 +321,9 @@ describe("validateLine", () => {
const wrapper = shallow(<Grid initial = {initVal}/>)
const grid = wrapper.instance()
let env = new crdtlib.utils.SimpleEnvironment(
const env = new crdtlib.utils.SimpleEnvironment(
new crdtlib.utils.ClientUId("myClientId"));
let newval = new crdtlib.crdt.MVRegister()
const newval = new crdtlib.crdt.MVRegister()
newval.set("1", env.tick())
grid.state.cells[1].merge(newval)
......@@ -424,9 +424,9 @@ describe("validateColumn", () => {
const wrapper = shallow(<Grid initial = {initVal}/>)
const grid = wrapper.instance()
let env = new crdtlib.utils.SimpleEnvironment(
const env = new crdtlib.utils.SimpleEnvironment(
new crdtlib.utils.ClientUId("myClientId"));
let newval = new crdtlib.crdt.MVRegister()
const newval = new crdtlib.crdt.MVRegister()
newval.set("1", env.tick())
grid.state.cells[1].merge(newval)
......@@ -527,9 +527,9 @@ describe("validateBlock", () => {
const wrapper = shallow(<Grid initial = {initVal}/>)
const grid = wrapper.instance()
let env = new crdtlib.utils.SimpleEnvironment(
const env = new crdtlib.utils.SimpleEnvironment(
new crdtlib.utils.ClientUId("myClientId"));
let newval = new crdtlib.crdt.MVRegister()
const newval = new crdtlib.crdt.MVRegister()
newval.set("1", env.tick())
grid.state.cells[1].merge(newval)
......@@ -630,9 +630,9 @@ describe("validateSudoku", () => {
const wrapper = shallow(<Grid initial = {initVal}/>)
const grid = wrapper.instance()
let env = new crdtlib.utils.SimpleEnvironment(
const env = new crdtlib.utils.SimpleEnvironment(
new crdtlib.utils.ClientUId("myClientId"));
let newval = new crdtlib.crdt.MVRegister()
const newval = new crdtlib.crdt.MVRegister()
newval.set("1", env.tick())
grid.state.cells[1].merge(newval)
......
......@@ -57,10 +57,10 @@ class Grid extends React.Component<IGridProps, IGridState> {
constructor(props: any) {
super(props);
let cells = new Array(81).fill(null).map(()=>({value:"", modifiable:false, error:false}));
const cells = new Array(81).fill(null).map(()=>({value:"", modifiable:false, error:false}));
this.modifiedCells = new Array(81).fill(null);
let gridNum = "1";
let mvmap = this.props.collection.open("grid" + gridNum, "MVMap", false, function () {return});
const gridNum = "1";
const mvmap = this.props.collection.open("grid" + gridNum, "MVMap", false, function () {return});
this.state = {
gridNum: gridNum,
mvmap: mvmap,
......@@ -94,7 +94,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
* Update cells values from C-Client.
*/
updateGrid() {
let cells = this.state.cells;
const cells = this.state.cells;
if (!this.state.isConnected) {
console.error("updateGrid() called while not connected.")
return cells;
......@@ -105,9 +105,9 @@ class Grid extends React.Component<IGridProps, IGridState> {
}
}
this.props.session.transaction(client.utils.ConsistencyLevel.None, () => {
let itString = this.state.mvmap.iteratorString()
const itString = this.state.mvmap.iteratorString()
while(itString.hasNext()) {
let val = itString.next()
const val = itString.next()
cells[val.first].value = hashSetToString(val.second)
}
})
......@@ -143,7 +143,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
*/
initFrom(values:any) {
assert.ok(values.length === 81);
let cells = this.state.cells;
const cells = this.state.cells;
for (let index = 0; index < 81; index++) {
cells[index].value = values[index] === "." ? "" : values[index];
cells[index].modifiable = values[index] === "." ? true : false;
......@@ -155,7 +155,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
* Reset the value of all modifiable cells.
*/
reset() {
let cells = this.state.cells;
const cells = this.state.cells;
for (let index = 0; index < 81; index++) {
if (cells[index].modifiable) {
cells[index].value = "";
......@@ -183,7 +183,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
console.error("Trying to change an non modifiable cell. Should not happend");
}
let cells = this.state.cells;
const cells = this.state.cells;
cells[index].value = value;
this.updateState(cells);
......@@ -204,7 +204,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
if (Number(gridNum) < 1 || Number(gridNum) > 100 || gridNum === this.state.gridNum) {
return;
}
let mvmap = this.props.collection.open("grid" + gridNum, "MVMap", false, function () {return});
const mvmap = this.props.collection.open("grid" + gridNum, "MVMap", false, function () {return});
this.setState({gridNum: gridNum, mvmap: mvmap});
this.initFrom(generateStaticGrid(gridNum));
}
......@@ -231,7 +231,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
*/
renderBlock(blockNum: number) {
assert.ok(blockNum >= 0 && blockNum < 9)
let index = blockIndex(blockNum);
const index = blockIndex(blockNum);
return (
<td>
{this.renderCell(index[0])}{this.renderCell(index[1])}{this.renderCell(index[2])}<br />
......@@ -275,10 +275,10 @@ class Grid extends React.Component<IGridProps, IGridState> {
*/
checkLine(line: number) {
assert.ok(line >= 0 && line < 9)
let cpt = Array(9).fill(0)
const cpt = Array(9).fill(0)
for (let column = 0; column < 9; column++) {
let index = line * 9 + column
let val = this.state.cells[index].value
const index = line * 9 + column
const val = this.state.cells[index].value
if (val.length === 0 || val.length > 1) {
continue
}
......@@ -293,10 +293,10 @@ class Grid extends React.Component<IGridProps, IGridState> {
*/
checkColumn(column: number) {
assert.ok(column >= 0 && column < 9)
let cpt = Array(9).fill(0)
const cpt = Array(9).fill(0)
for (let line = 0; line < 9; line++) {
let index = line * 9 + column
let val = this.state.cells[index].value
const index = line * 9 + column
const val = this.state.cells[index].value
if (val.length === 0 || val.length > 1) {
continue
}
......@@ -311,10 +311,10 @@ class Grid extends React.Component<IGridProps, IGridState> {
*/
checkBlock(block: number) {
assert.ok(block >= 0 && block < 9)
let cpt = Array(9).fill(0)
let indexList = blockIndex(block)
for (let index of indexList) {
let val = this.state.cells[index].value
const cpt = Array(9).fill(0)
const indexList = blockIndex(block)
for (const index of indexList) {
const val = this.state.cells[index].value
if (val.length === 0 || val.length > 1) {
continue
}
......@@ -327,7 +327,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
* This function check if all lines respect Sudoku lines rules.
*/
checkLines() {
let indexList = []
const indexList = []
for (let line = 0; line < 9; line++) {
if (this.checkLine(line) === false) {
for (let column = 0; column < 9; column++) {
......@@ -342,7 +342,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
* This function check if all columns respect Sudoku columns rules.
*/
checkColumns() {
let indexList = []
const indexList = []
for (let column = 0; column < 9; column++) {
if (this.checkColumn(column) === false) {
for (let line = 0; line < 9; line++) {
......@@ -370,9 +370,9 @@ class Grid extends React.Component<IGridProps, IGridState> {
* This function check if cells contains multiple values.
*/
checkCells() {
let indexList = []
const indexList = []
for (let cell = 0; cell < 81; cell++) {
let val = this.state.cells[cell].value
const val = this.state.cells[cell].value
if (val.length > 1) {
indexList.push(cell)
}
......@@ -390,7 +390,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
errorIndexList = errorIndexList.concat(this.checkBlocks());
errorIndexList = errorIndexList.concat(this.checkCells());
let errorIndexSet = new Set(errorIndexList);
const errorIndexSet = new Set(errorIndexList);
for (let index = 0; index < 81; index++) {
if (errorIndexSet.has(index)) {
......@@ -429,9 +429,9 @@ function generateStaticGrid(gridNum: string) {
*/
function blockIndex(block: number) {
assert.ok(block >= 0 && block < 9)
let line = Math.floor(block / 3) * 3
let column = (block % 3) * 3
let index = [ line * 9 + column, line * 9 + column + 1, line * 9 + column + 2,
const line = Math.floor(block / 3) * 3
const column = (block % 3) * 3
const index = [ line * 9 + column, line * 9 + column + 1, line * 9 + column + 2,
(line + 1) * 9 + column, (line + 1) * 9 + column + 1, (line + 1) * 9 + column + 2,
(line + 2) * 9 + column, (line + 2) * 9 + column + 1, (line + 2) * 9 + column + 2]
return index
......@@ -442,10 +442,10 @@ function blockIndex(block: number) {
* @param set HashSet to be concatenated.
*/
function hashSetToString(set: any) {
let res = new Set();
let it = set.iterator();
const res = new Set();
const it = set.iterator();
while (it.hasNext()) {
let val = it.next();
const val = it.next();
if (val !== "") {
res.add(val);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment