Skip to content

Commit

Permalink
fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
eimrek committed Jul 22, 2024
1 parent 1244b5c commit 197a222
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/MaterialSelector/MaterialDataGrid/ColumnSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "./ColumnSelector.css";

function parseInitTicks(colDefs) {
var initTicks = {};
colDefs.map((cd) => {
colDefs.forEach((cd) => {
initTicks[cd.field] = "hide" in cd ? !cd.hide : true;
});
return initTicks;
Expand Down
4 changes: 2 additions & 2 deletions src/MaterialSelector/MaterialDataGrid/CustomHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export default class CustomHeader extends React.Component {
);

let sortSymbol = "";
if (this.state.sortMode == "asc")
if (this.state.sortMode === "asc")
sortSymbol = (
<div style={{ display: "flex" }}>
{this.state.multiSort && this.state.sortIndex + 1}
<i className="ag-icon ag-icon-asc" />
</div>
);
if (this.state.sortMode == "desc")
if (this.state.sortMode === "desc")
sortSymbol = (
<div style={{ display: "flex" }}>
{this.state.multiSort && this.state.sortIndex + 1}
Expand Down
12 changes: 6 additions & 6 deletions src/MaterialSelector/MaterialDataGrid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function spaceGroupSymbolRenderer(params) {
return (
<span>
{params.value.split("").map((v, index) => {
if (v == "_") {
if (v === "_") {
nextIsSub = true;
return null;
}
Expand Down Expand Up @@ -253,13 +253,13 @@ class MaterialDataGrid extends React.Component {
updateNumRows = () => {
if (this.gridApi) {
let nRows = this.gridApi.getDisplayedRowCount();
if (this.state.numRows != nRows) this.setState({ numRows: nRows });
if (this.state.numRows !== nRows) this.setState({ numRows: nRows });
}
};

doesExternalFilterPass = (node) => {
if (node.data) {
if (this.props.ptable_filter["mode"] == "exact") {
if (this.props.ptable_filter["mode"] === "exact") {
let selectedElements = Object.keys(
this.props.ptable_filter["elements"]
);
Expand All @@ -270,14 +270,14 @@ class MaterialDataGrid extends React.Component {
return len_match && incl;
}

if (this.props.ptable_filter["mode"] == "include") {
if (this.props.ptable_filter["mode"] === "include") {
let include = [];
let exclude = [];
for (const [el, sel] of Object.entries(
this.props.ptable_filter["elements"]
)) {
if (sel == 1) include.push(el);
if (sel == 2) exclude.push(el);
if (sel === 1) include.push(el);
if (sel === 2) exclude.push(el);
}
// every element specified in "include" needs to be present
let incl = include.every((e) => node.data.elem_array.includes(e));
Expand Down
25 changes: 9 additions & 16 deletions src/MaterialSelector/PTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ export class Element extends React.Component {
}

handleOnClick() {
if (this.props.disabled && this.props.selection == 0) return;
if (this.props.disabled && this.props.selection === 0) return;
if (this.props.onSelectionChange == null) return;
this.props.onSelectionChange({ element: this.symbol });
}

render() {
let e_class = `pt_element pt_element-${this.props.num}`;

if (this.props.disabled && this.props.selection == 0) {
if (this.props.disabled && this.props.selection === 0) {
e_class += " pt_element-disabled";
} else {
e_class += ` pt_element-state${this.props.selection}`;
Expand Down Expand Up @@ -114,9 +114,6 @@ const helpPopover = (
);

class SelectionMode extends React.Component {
constructor(props) {
super(props);
}
// this.props.onSelectionChange({ mode: e.currentTarget.checked })
render() {
return (
Expand Down Expand Up @@ -153,13 +150,13 @@ class SelectionMode extends React.Component {
// ------------------------------------------------------------
// Functions to determine what elements to enable/disable
function fitsFilter(elem_array, numClicked) {
let elemSet = new Set(elem_array)
let include = numClicked[1]
let exclude = numClicked[2]
let elemSet = new Set(elem_array);
let include = numClicked[1];
let exclude = numClicked[2];
// every element specified in "include" needs to be present in elemSet
let incl = [...include].every(e => elemSet.has(e));
let incl = [...include].every((e) => elemSet.has(e));
// none of the elem_array elements can be in the excluded list
let excl = [...elemSet].every(e => !exclude.has(e));
let excl = [...elemSet].every((e) => !exclude.has(e));
return incl && excl;
}

Expand All @@ -175,9 +172,9 @@ function enabledElements(rows, filter) {
let numClicked = {
1: new Set(),
2: new Set(),
}
};
for (const [el, sel] of Object.entries(filter["elements"])) {
numClicked[sel].add(el)
numClicked[sel].add(el);
}

rows.forEach((row) => {
Expand All @@ -190,10 +187,6 @@ function enabledElements(rows, filter) {
// ------------------------------------------------------------

class PTable extends React.Component {
constructor(props) {
super(props);
}

makeElements = (start, end) => {
let items = [];
for (let i = start; i <= end; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/MaterialSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function modifyRows(rows, columns) {
*/

let booleanFields = columns
.filter((col) => col.colType == "boolean")
.filter((col) => col.colType === "boolean")
.map((col) => col.field);

const modifiedRows = rows.map((row) => {
Expand Down
4 changes: 2 additions & 2 deletions src/MaterialSelector/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const RGB_Log_Blend = (p, c0, c1) => {
"rgb" +
(x ? "a(" : "(") +
r(
(P * i(a[3] == "a" ? a.slice(5) : a.slice(4)) ** 2 +
p * i(e[3] == "a" ? e.slice(5) : e.slice(4)) ** 2) **
(P * i(a[3] === "a" ? a.slice(5) : a.slice(4)) ** 2 +
p * i(e[3] === "a" ? e.slice(5) : e.slice(4)) ** 2) **
0.5
) +
"," +
Expand Down

0 comments on commit 197a222

Please sign in to comment.