update lint rules

This commit is contained in:
Daniel 2020-10-15 15:48:27 -04:00
parent 78bb073c2f
commit ae25fe8fe2
38 changed files with 653 additions and 394 deletions

120
.eslintrc Normal file
View File

@ -0,0 +1,120 @@
{
"root": true,
"parser": "babel-eslint",
"plugins": [
"babel",
"react",
"import",
"react-hooks"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:promise/recommended"
],
"env": {
"browser": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"jsx": true,
"experimentalObjectRestSpread": true,
"legacyDecorators": true
}
},
"settings": {
"react": {
"version": "detect"
}
},
"ignorePatterns": [
"node_modules",
"build"
],
"rules": {
"arrow-parens": "off",
"dot-notation": "off",
"eqeqeq": "off",
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["./webpack.config.babel.js"]}],
"linebreak-style": "off",
"no-plusplus": "off",
"no-prototype-builtins": "off",
"no-undef": "error",
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }],
"no-unused-vars": ["warn", { "argsIgnorePattern": "props|context|e", "varsIgnorePattern": "s" }],
"no-useless-escape": "off",
"object-curly-newline": "off",
"object-curly-spacing": ["warn", "always", {"objectsInObjects": false, "arraysInObjects": false}],
"prefer-destructuring": ["warn", {
"VariableDeclarator": { "array": false, "object": true },
"AssignmentExpression": { "array": false, "object": false }
}, {
"enforceForRenamedProperties": false
}],
"promise/always-return": "off",
"promise/catch-or-return": ["warn", {
"allowFinally": true
}],
"promise/no-callback-in-promise": "off",
"react/display-name": "off",
"react/forbid-prop-types": "off",
"react/jsx-curly-brace-presence": "off",
"react/jsx-filename-extension": ["warn", { "extensions": [".js", ".jsx"] }],
"react/jsx-indent": ["warn", 2, { "indentLogicalExpressions": true }],
"react/jsx-indent-props": ["warn", 2],
"react/no-unescaped-entities": "off",
"react/prop-types": "off"
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"env": { "browser": true, "es6": true, "node": true, "mocha": true },
"extends": [
"plugin:@typescript-eslint/eslint-recommended"
],
"globals": { "Atomics": "readonly", "SharedArrayBuffer": "readonly" },
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": { "jsx": true },
"ecmaVersion": 2019,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-unused-vars": [1, {
"args": "after-used" ,
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true
}],
"comma-dangle": ["error", {
"arrays": "only-multiline",
"objects": "only-multiline",
"imports": "never",
"exports": "never",
"functions": "never"
}],
"import/extensions": "off",
"import/named": "off",
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.spec.ts"]}],
"import/no-unresolved": "off",
"lines-between-class-members": "off",
"no-param-reassign": "off",
"no-plusplus": "off",
"no-shadow": "off",
"no-unused-vars": "off",
"no-underscore-dangle": "off",
"no-use-before-define": "off",
"prefer-template": "error",
"react/jsx-filename-extension": [1, { "extensions": [".tsx"] }]
}
}
]
}

View File

@ -1,56 +0,0 @@
module.exports = {
"root": true,
"parser": "babel-eslint",
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"env": {
"browser": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"jsx": true,
"experimentalObjectRestSpread": true,
"legacyDecorators": true
}
},
"rules": {
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["./webpack.config.babel.js"]}],
"react/forbid-prop-types": "off",
"react/jsx-filename-extension": "off",
"react/no-unescaped-entities": "off",
"react/prop-types": "off",
"react/display-name": "off",
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }],
"no-plusplus": "off",
"no-prototype-builtins": "off",
"object-curly-spacing": ["warn", "always", {"objectsInObjects": false, "arraysInObjects": false}],
"object-curly-newline": "off",
"linebreak-style": "off",
"eqeqeq": "off",
"dot-notation": "off",
"no-unused-vars": ["warn", { "argsIgnorePattern": "props|context|e", "varsIgnorePattern": "s" }],
"no-undef": "error",
"no-useless-escape": "off"
},
"settings": {
"react": {
"version": require('./package.json').dependencies.react
}
},
"plugins": [
"react",
"import",
"react-hooks"
],
"ignorePatterns": [
"node_modules",
"build"
]
}

170
package-lock.json generated
View File

@ -3499,6 +3499,12 @@
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz",
"integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow==" "integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow=="
}, },
"@types/eslint-visitor-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
"integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==",
"dev": true
},
"@types/glob": { "@types/glob": {
"version": "7.1.2", "version": "7.1.2",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.2.tgz", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.2.tgz",
@ -3640,6 +3646,140 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@typescript-eslint/eslint-plugin": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz",
"integrity": "sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "3.10.1",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"regexpp": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz",
"integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==",
"dev": true
},
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
}
}
},
"@typescript-eslint/experimental-utils": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz",
"integrity": "sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/types": "3.10.1",
"@typescript-eslint/typescript-estree": "3.10.1",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
},
"dependencies": {
"eslint-utils": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
}
}
}
},
"@typescript-eslint/parser": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.10.1.tgz",
"integrity": "sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw==",
"dev": true,
"requires": {
"@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/experimental-utils": "3.10.1",
"@typescript-eslint/types": "3.10.1",
"@typescript-eslint/typescript-estree": "3.10.1",
"eslint-visitor-keys": "^1.1.0"
}
},
"@typescript-eslint/types": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.10.1.tgz",
"integrity": "sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz",
"integrity": "sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w==",
"dev": true,
"requires": {
"@typescript-eslint/types": "3.10.1",
"@typescript-eslint/visitor-keys": "3.10.1",
"debug": "^4.1.1",
"glob": "^7.1.6",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
}
}
},
"@typescript-eslint/visitor-keys": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz",
"integrity": "sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
}
},
"@webassemblyjs/ast": { "@webassemblyjs/ast": {
"version": "1.9.0", "version": "1.9.0",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz",
@ -7151,6 +7291,15 @@
} }
} }
}, },
"eslint-plugin-babel": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-babel/-/eslint-plugin-babel-5.3.1.tgz",
"integrity": "sha512-VsQEr6NH3dj664+EyxJwO4FCYm/00JhYb3Sk3ft8o+fpKuIfQ9TaW6uVUfvwMXHcf/lsnRIoyFPsLMyiWCSL/g==",
"dev": true,
"requires": {
"eslint-rule-composer": "^0.3.0"
}
},
"eslint-plugin-import": { "eslint-plugin-import": {
"version": "2.22.1", "version": "2.22.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz",
@ -7193,6 +7342,12 @@
} }
} }
}, },
"eslint-plugin-promise": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz",
"integrity": "sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw==",
"dev": true
},
"eslint-plugin-react": { "eslint-plugin-react": {
"version": "7.21.4", "version": "7.21.4",
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.21.4.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.21.4.tgz",
@ -7238,6 +7393,12 @@
"integrity": "sha512-EjxTHxjLKIBWFgDJdhKKzLh5q+vjTFrqNZX36uIxWS4OfyXe5DawqPj3U5qeJ1ngLwatjzQnmR0Lz0J0YH3kxw==", "integrity": "sha512-EjxTHxjLKIBWFgDJdhKKzLh5q+vjTFrqNZX36uIxWS4OfyXe5DawqPj3U5qeJ1ngLwatjzQnmR0Lz0J0YH3kxw==",
"dev": true "dev": true
}, },
"eslint-rule-composer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz",
"integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==",
"dev": true
},
"eslint-scope": { "eslint-scope": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz",
@ -15646,6 +15807,15 @@
"integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==", "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==",
"dev": true "dev": true
}, },
"tsutils": {
"version": "3.17.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"tty-browserify": { "tty-browserify": {
"version": "0.0.0", "version": "0.0.0",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",

View File

@ -5,8 +5,8 @@
"scripts": { "scripts": {
"start": "webpack serve --mode development --env development", "start": "webpack serve --mode development --env development",
"build": "webpack -p", "build": "webpack -p",
"lint": "tsc --noEmit; eslint '*/**/*.{js,ts,tsx}'", "lint": "tsc --noEmit && eslint '*/**/*.{js,ts,tsx}'",
"lint:fix": "tsc --noEmit; eslint '*/**/*.{js,ts,tsx}' --quiet --fix", "lint:fix": "tsc --noEmit && eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register src/**/*.spec.ts" "test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register src/**/*.spec.ts"
}, },
"repository": { "repository": {
@ -60,14 +60,18 @@
"@types/react": "^16.9.52", "@types/react": "^16.9.52",
"@types/react-dom": "^16.9.8", "@types/react-dom": "^16.9.8",
"@types/react-router-dom": "^5.1.6", "@types/react-router-dom": "^5.1.6",
"@typescript-eslint/eslint-plugin": "^3.3.0",
"@typescript-eslint/parser": "^3.3.0",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0", "babel-loader": "^8.1.0",
"chai": "^4.2.0", "chai": "^4.2.0",
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"css-loader": "^3.6.0", "css-loader": "^3.6.0",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-react": "^7.21.4", "eslint-plugin-react": "^7.21.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react-hooks": "^3.0.0", "eslint-plugin-react-hooks": "^3.0.0",
"ignore-styles": "^5.0.1", "ignore-styles": "^5.0.1",
"jsdom": "^16.4.0", "jsdom": "^16.4.0",

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
export function Initiative(props) { export function Initiative(props) {
let initiative = props.initiative; let { initiative } = props;
let image = null; let image = null;
if (["Danian", "Generic", "Mipedian", "OverWorld", "UnderWorld", "M'arrillian"].indexOf(initiative) > -1) { if (["Danian", "Generic", "Mipedian", "OverWorld", "UnderWorld", "M'arrillian"].indexOf(initiative) > -1) {
image = <img className="icon16" style={{ verticalAlign: 'middle' }} src={("/src/img/icons/tribes/" + initiative + ".png").toLowerCase()} /> image = <img className="icon16" style={{ verticalAlign: 'middle' }} src={("/src/img/icons/tribes/" + initiative + ".png").toLowerCase()} />

View File

@ -19,7 +19,7 @@ export function Rarity(props) {
return ( return (
<span> <span>
{set !== 'PE1' && <img className={props.size || "icon16"} style={{ verticalAlign: 'middle' }} src={("/src/img/icons/set/" + set + "/" + rarity + ".png").toLowerCase()} />} {set !== 'PE1' && <img className={props.size || "icon16"} style={{ verticalAlign: 'middle' }} src={("/src/img/icons/set/" + set + "/" + rarity + ".png").toLowerCase()} />}
{!props.notext && <React.Fragment>{API.sets[props.set]}&nbsp;|&nbsp;{props.rarity}</React.Fragment>} {!props.notext && <>{API.sets[props.set]}&nbsp;|&nbsp;{props.rarity}</>}
</span> </span>
); );
} }

View File

@ -26,7 +26,7 @@ export function Loading(props) {
} }
export function Splash(props) { export function Splash(props) {
let image = props.image; let { image } = props;
return ( return (
<div style={{ position: 'absolute', top: '0', left: '0', right: '0', bottom: '0', backgroundImage: 'url(\'' + image + '\') no-repeat center', backgroundSize: 'cover' }} /> <div style={{ position: 'absolute', top: '0', left: '0', right: '0', bottom: '0', backgroundImage: 'url(\'' + image + '\') no-repeat center', backgroundSize: 'cover' }} />
); );

View File

@ -203,7 +203,8 @@ class API {
this.buildCollection(collection) this.buildCollection(collection)
.then(() => { .then(() => {
resolve(); resolve();
}); })
.catch(() => {});
} }
else resolve(); else resolve();
}); });

View File

@ -16,7 +16,7 @@ export default class CardList extends React.Component {
} }
render() { render() {
let cards = this.props.cards; let { cards } = this.props;
if (cards.length == 1 && cards[0].text) { if (cards.length == 1 && cards[0].text) {
return ( return (

View File

@ -165,9 +165,9 @@ export default class SearchCollection extends React.Component {
} }
handleChange = (event, obj) => { handleChange = (event, obj) => {
const target = event.target; const { target } = event;
const value = target.type === 'checkbox' ? target.checked : target.value; const value = target.type === 'checkbox' ? target.checked : target.value;
const name = target.name; const { name } = target;
if (!obj) this.input[name] = value; if (!obj) this.input[name] = value;
else this.input[obj][name] = value; else this.input[obj][name] = value;
} }

View File

@ -7,7 +7,7 @@ import { Rarity, Unique, Name, Element, Ability, AttackIcon } from '../../Snippe
export default class Attack extends React.Component { export default class Attack extends React.Component {
render() { render() {
let card = this.props.card; let { card } = this.props;
if (this.props.ext == false) return ( if (this.props.ext == false) return (
<div className="card attack"> <div className="card attack">
@ -39,9 +39,9 @@ export default class Attack extends React.Component {
<Name name={card.gsx$name} /><br /> <Name name={card.gsx$name} /><br />
<Ability ability={card.gsx$ability} /> <Ability ability={card.gsx$ability} />
<Unique data={{ unique: card.gsx$unique, loyal: card.gsx$loyal, legendary: card.gsx$legendary }} /> <Unique data={{ unique: card.gsx$unique, loyal: card.gsx$loyal, legendary: card.gsx$legendary }} />
{card.gsx$flavortext && <React.Fragment> {card.gsx$flavortext && <>
<span className="flavortext">{card.gsx$flavortext}</span><br /> <span className="flavortext">{card.gsx$flavortext}</span><br />
</React.Fragment>} </>}
<span>Art By: {card.gsx$artist}</span> <span>Art By: {card.gsx$artist}</span>
</div> </div>
</div> </div>

View File

@ -7,7 +7,7 @@ import { Rarity, Unique, Name, Ability, BattlegearIcon } from '../../Snippets';
export default class Battlegear extends React.Component { export default class Battlegear extends React.Component {
render() { render() {
let card = this.props.card; let { card } = this.props;
if (this.props.ext == false) return ( if (this.props.ext == false) return (
<div className="card battlegear"> <div className="card battlegear">
@ -31,9 +31,9 @@ export default class Battlegear extends React.Component {
<Name name={card.gsx$name} /><br /> <Name name={card.gsx$name} /><br />
<Ability ability={card.gsx$ability} /> <Ability ability={card.gsx$ability} />
<Unique data={{ unique: card.gsx$unique, loyal: card.gsx$loyal, legendary: card.gsx$legendary }} /> <Unique data={{ unique: card.gsx$unique, loyal: card.gsx$loyal, legendary: card.gsx$legendary }} />
{card.gsx$flavortext && <React.Fragment> {card.gsx$flavortext && <>
<span className="flavortext">{card.gsx$flavortext}</span><br /> <span className="flavortext">{card.gsx$flavortext}</span><br />
</React.Fragment>} </>}
<span>Art By: {card.gsx$artist}</span> <span>Art By: {card.gsx$artist}</span>
</div> </div>
</div> </div>

View File

@ -7,7 +7,7 @@ import { Rarity, Unique, Name, Element, Mugic, Discipline, Ability, Tribe } from
export default class Creature extends React.Component { export default class Creature extends React.Component {
render() { render() {
let card = this.props.card; let { card } = this.props;
let mugic = []; let mugic = [];
for (let i = 0; i < card.gsx$mugicability; i++) { for (let i = 0; i < card.gsx$mugicability; i++) {
@ -102,9 +102,9 @@ export default class Creature extends React.Component {
card.gsx$types.includes("Chieftain") && card.gsx$types.includes("Chieftain") &&
<span className="chieftain">(Minions use Brainwashed text. Minions may only play Generic Mugic.)<br /></span> <span className="chieftain">(Minions use Brainwashed text. Minions may only play Generic Mugic.)<br /></span>
} }
{card.gsx$flavortext && <React.Fragment> {card.gsx$flavortext && <>
<span className="flavortext">{card.gsx$flavortext}</span><br /> <span className="flavortext">{card.gsx$flavortext}</span><br />
</React.Fragment>} </>}
<span>Art By: {card.gsx$artist}</span> <span>Art By: {card.gsx$artist}</span>
</div> </div>
</div> </div>

View File

@ -8,7 +8,7 @@ import API from '../../SpreadsheetData';
export default class Location extends React.Component { export default class Location extends React.Component {
render() { render() {
let card = this.props.card; let { card } = this.props;
if (this.props.ext == false) return ( if (this.props.ext == false) return (
<div className="card location"> <div className="card location">
@ -34,9 +34,9 @@ export default class Location extends React.Component {
<Initiative initiative={card.gsx$initiative} /> <Initiative initiative={card.gsx$initiative} />
<Ability ability={card.gsx$ability} /> <Ability ability={card.gsx$ability} />
<Unique data={{ unique: card.gsx$unique, loyal: card.gsx$loyal, legendary: card.gsx$legendary }} /> <Unique data={{ unique: card.gsx$unique, loyal: card.gsx$loyal, legendary: card.gsx$legendary }} />
{card.gsx$flavortext && <React.Fragment> {card.gsx$flavortext && <>
<span className="flavortext">{card.gsx$flavortext}</span><br /> <span className="flavortext">{card.gsx$flavortext}</span><br />
</React.Fragment>} </>}
<span>Art By: {card.gsx$artist}</span> <span>Art By: {card.gsx$artist}</span>
</div> </div>
</div> </div>

View File

@ -53,9 +53,9 @@ class Attack extends React.Component {
<Name name={card.gsx$name} /><br /> <Name name={card.gsx$name} /><br />
<Ability ability={card.gsx$ability} tribe={card.gsx$tribe} /> <Ability ability={card.gsx$ability} tribe={card.gsx$tribe} />
<Unique data={{ unique: card.gsx$unique, loyal: card.gsx$loyal, legendary: card.gsx$legendary }} /> <Unique data={{ unique: card.gsx$unique, loyal: card.gsx$loyal, legendary: card.gsx$legendary }} />
{card.gsx$flavortext && <React.Fragment> {card.gsx$flavortext && <>
<span className="flavortext">{card.gsx$flavortext}</span><br /> <span className="flavortext">{card.gsx$flavortext}</span><br />
</React.Fragment>} </>}
<span>Art By: {card.gsx$artist}</span> <span>Art By: {card.gsx$artist}</span>
</div> </div>
</div> </div>

View File

@ -14,7 +14,7 @@ export default class Base extends React.Component {
} }
function Routing(props) { function Routing(props) {
const match = props.match; const { match } = props;
return ( return (
<div className="pack"> <div className="pack">
<Route exact path={match.url} component={EnterTheCode} /> <Route exact path={match.url} component={EnterTheCode} />

View File

@ -32,7 +32,7 @@ const Collection = loadable(
/** /**
* This function is to define beta routes * This function is to define beta routes
*/ */
function BetaRoutingWrapper(props) { function BetaRoutingWrapper() {
return ( return (
<Switch> <Switch>
<Route path="/beta/collection" component={Collection} /> <Route path="/beta/collection" component={Collection} />
@ -44,7 +44,7 @@ function BetaRoutingWrapper(props) {
); );
} }
function Routing(props) { function Routing() {
return ( return (
<Switch> <Switch>
<Route exact path="/" component={Home} /> <Route exact path="/" component={Home} />
@ -67,7 +67,7 @@ function Base(props) {
const children = <BetaRoutingWrapper />; const children = <BetaRoutingWrapper />;
return ( return (
<React.Fragment> <>
<div className="fix-pgBkgrnd-repeat-x"> <div className="fix-pgBkgrnd-repeat-x">
<div className={"fix-img-bkgrnd fix-img-bkgrnd_"+bkgrnd}></div> <div className={"fix-img-bkgrnd fix-img-bkgrnd_"+bkgrnd}></div>
</div> </div>
@ -179,7 +179,7 @@ function Base(props) {
</div> </div>
</div> </div>
</div> </div>
</React.Fragment> </>
); );
} }

View File

@ -16,7 +16,7 @@ const cases = {
Object.entries(cases).forEach(([key, value]) => { Object.entries(cases).forEach(([key, value]) => {
describe(key, () => { describe(key, () => {
it('should return ' + value.output, () => { it(`should return ${value.output}`, () => {
const tune = output(parseTune(value.input)); const tune = output(parseTune(value.input));
expect(tune).to.deep.equal(value.output); expect(tune).to.deep.equal(value.output);
}); });

View File

@ -22,7 +22,7 @@ export const output = (seq: Note[]) => {
// db notation uses duration (quarter notes) and pitch // db notation uses duration (quarter notes) and pitch
// 2Eb => E flat for 2 quarter notes // 2Eb => E flat for 2 quarter notes
export const parseTune = (input: string): Note[] => { export const parseTune = (input: string): Note[] => {
let seq: Note[] = []; const seq: Note[] = [];
let time = 0; let time = 0;
console.log(input.split(" ")); console.log(input.split(" "));
input.split(" ").forEach((note) => { input.split(" ").forEach((note) => {
@ -79,7 +79,7 @@ const parseNote = (pitch: string, seq: Note[]): {pitch: string, octave: number}
if (seq.length === 0) return 4; if (seq.length === 0) return 4;
const l = seq.length - 1; const l = seq.length - 1;
const octave = seq[l].octave; const { octave } = seq[l];
const current = pitchValue(pitch, octave); const current = pitchValue(pitch, octave);
const previous = pitchValue(seq[l]); const previous = pitchValue(seq[l]);
@ -148,8 +148,8 @@ const parseNote = (pitch: string, seq: Note[]): {pitch: string, octave: number}
const trend = (current: number, l: number, seq: Note[]): number => { const trend = (current: number, l: number, seq: Note[]): number => {
if (l < 1) return seq[l].octave; if (l < 1) return seq[l].octave;
let prev = pitchValue(seq[l]); const prev = pitchValue(seq[l]);
let prev2 = pitchValue(seq[l-1]); const prev2 = pitchValue(seq[l-1]);
console.log(prev2, prev, current); console.log(prev2, prev, current);
// downward trend // downward trend
@ -176,7 +176,7 @@ const trend = (current: number, l: number, seq: Note[]): number => {
* Takes two pitches and returns the distance between them * Takes two pitches and returns the distance between them
*/ */
const compare = (one: number, two: number): number => { const compare = (one: number, two: number): number => {
let res = Math.abs(one - two); const res = Math.abs(one - two);
if (res < 4) { if (res < 4) {
return res; return res;
} }

View File

@ -54,11 +54,12 @@ class DBSearch extends React.Component {
{ 'cards': 'attacks' }, { 'cards': 'battlegear' }, { 'cards': 'creatures' }, { 'cards': 'locations' }, { 'cards': 'mugic' } { 'cards': 'attacks' }, { 'cards': 'battlegear' }, { 'cards': 'creatures' }, { 'cards': 'locations' }, { 'cards': 'mugic' }
]).then(() => { ]).then(() => {
this.loaded = true; this.loaded = true;
}); })
.catch(() => {})
return (<span>Loading...</span>); return (<span>Loading...</span>);
} }
let string = this.props.string; let { string } = this.props;
// No search // No search
if (string == "") { if (string == "") {
@ -90,6 +91,21 @@ class DBSearch extends React.Component {
</div>); </div>);
}; };
const create_link = (card, data, i, url) => {
// Prevent site from crashing due to misspelled/missing data
if (!data) return (<div key={i}></div>);
return (<div key={i} className="nav_item">
<Interactive as={Link}
to={url || `/portal/${this.props.type}/${card.gsx$name}`}
{...s.link}
>
<span>{card.gsx$name.split(",")[0]}</span><br />
<img className="thumb" src={API.base_image + data.gsx$thumb}></img>
</Interactive>
</div>);
};
let filter = this.filter.addCollection('filter'); let filter = this.filter.addCollection('filter');
var pview = filter.addDynamicView('filter'); var pview = filter.addDynamicView('filter');
pview.applySimpleSort('gsx$name'); pview.applySimpleSort('gsx$name');
@ -229,11 +245,11 @@ class DBSearch extends React.Component {
return (<div className="results"> return (<div className="results">
<hr /> <hr />
{names.length > 0 && <React.Fragment> {names.length > 0 && <>
<div>Entries</div> <div>Entries</div>
{names} {names}
<hr /> <hr />
</React.Fragment>} </>}
<div>{header}</div> <div>{header}</div>
{content} {content}
</div>); </div>);

View File

@ -26,7 +26,7 @@ export default class SingleAttack extends React.Component {
if (attack) { if (attack) {
return (<Single return (<Single
card={card_data} card={card_data}
col2={<React.Fragment> col2={<>
<div> <div>
<strong>Attributes:</strong><br /> <strong>Attributes:</strong><br />
{attack.gsx$attributes} {attack.gsx$attributes}
@ -41,7 +41,7 @@ export default class SingleAttack extends React.Component {
<strong>Details:</strong><br /> <strong>Details:</strong><br />
{attack.gsx$details} {attack.gsx$details}
</div> </div>
</React.Fragment>} </>}
/> />
); );
} }

View File

@ -26,7 +26,7 @@ export default class SingleBattlegear extends React.Component {
if (battlegear) { if (battlegear) {
return (<Single return (<Single
card={card_data} card={card_data}
col2={<React.Fragment> col2={<>
<div> <div>
<strong>Attributes:</strong><br /> <strong>Attributes:</strong><br />
{battlegear.gsx$attributes} {battlegear.gsx$attributes}
@ -41,7 +41,7 @@ export default class SingleBattlegear extends React.Component {
<strong>Details:</strong><br /> <strong>Details:</strong><br />
{battlegear.gsx$details} {battlegear.gsx$details}
</div> </div>
</React.Fragment>} </>}
/>); />);
} }
else if (card_data) { else if (card_data) {

View File

@ -59,15 +59,15 @@ export default class SingleCreature extends React.Component {
return (<Single return (<Single
card={card_data} card={card_data}
text={<React.Fragment> text={<>
<hr /> <hr />
{creature.gsx$appearance && <React.Fragment> {creature.gsx$appearance && <>
<div> <div>
<strong>Appearance:</strong><br /> <strong>Appearance:</strong><br />
{creature.gsx$appearance} {creature.gsx$appearance}
</div> </div>
<hr /> <hr />
</React.Fragment>} </>}
<div> <div>
<strong>Background:</strong><br /> <strong>Background:</strong><br />
{creature.gsx$background} {creature.gsx$background}
@ -103,13 +103,13 @@ export default class SingleCreature extends React.Component {
{creature.gsx$weight} {creature.gsx$weight}
</div> </div>
<hr /> <hr />
{card_data.gsx$artist && <React.Fragment> {card_data.gsx$artist && <>
<div> <div>
<strong>Artist(s):</strong> <strong>Artist(s):</strong>
<Artist artist={card_data.gsx$artist} /> <Artist artist={card_data.gsx$artist} />
</div> </div>
<hr /> <hr />
</React.Fragment>} </>}
<div> <div>
<strong>Card ID: </strong> <strong>Card ID: </strong>
{card_data.gsx$id} {card_data.gsx$id}
@ -183,7 +183,7 @@ export default class SingleCreature extends React.Component {
<strong>Mugic Ability: </strong> <strong>Mugic Ability: </strong>
{mugic} {mugic}
</div> </div>
</React.Fragment>} </>}
/>); />);
} }
} }

View File

@ -25,13 +25,13 @@ export default class SingleLocation extends React.Component {
if (location) { if (location) {
return (<Single return (<Single
card={card_data} card={card_data}
col0={<React.Fragment> col0={<>
<div> <div>
<strong>Initiative: </strong> <strong>Initiative: </strong>
<Initiative initiative={card_data.gsx$initiative} notitle="true"/> <Initiative initiative={card_data.gsx$initiative} notitle="true"/>
</div> </div>
</React.Fragment>} </>}
col2={<React.Fragment> col2={<>
<div> <div>
<strong>Local Features:</strong><br /> <strong>Local Features:</strong><br />
{location.gsx$localfeatures} {location.gsx$localfeatures}
@ -46,19 +46,19 @@ export default class SingleLocation extends React.Component {
<strong>Details:</strong><br /> <strong>Details:</strong><br />
{location.gsx$details} {location.gsx$details}
</div> </div>
</React.Fragment>} </>}
/>); />);
} }
else if (card_data) { else if (card_data) {
if (card_data.gsx$splash) { if (card_data.gsx$splash) {
return (<Single return (<Single
card={card_data} card={card_data}
col0={<React.Fragment> col0={<>
<div> <div>
<strong>Initiative: </strong> <strong>Initiative: </strong>
<Initiative initiative={card_data.gsx$initiative} notitle="true"/> <Initiative initiative={card_data.gsx$initiative} notitle="true"/>
</div> </div>
</React.Fragment>} </>}
/>); />);
} }
} }

View File

@ -44,7 +44,7 @@ export default class SingleMugic extends React.Component {
if (mugic) { if (mugic) {
return (<Single return (<Single
card={card_data} card={card_data}
col0={<React.Fragment> col0={<>
<div> <div>
<strong>Tribe: </strong> <strong>Tribe: </strong>
<Tribe tribe={mugic.gsx$tribe} /> <Tribe tribe={mugic.gsx$tribe} />
@ -54,8 +54,8 @@ export default class SingleMugic extends React.Component {
<strong>Cost: </strong> <strong>Cost: </strong>
{cost()} {cost()}
</div> </div>
</React.Fragment>} </>}
col2={<React.Fragment> col2={<>
<div> <div>
<strong>Background:</strong><br /> <strong>Background:</strong><br />
{mugic.gsx$background} {mugic.gsx$background}
@ -65,14 +65,14 @@ export default class SingleMugic extends React.Component {
<strong>Details:</strong><br /> <strong>Details:</strong><br />
{mugic.gsx$details} {mugic.gsx$details}
</div> </div>
</React.Fragment>} </>}
/>); />);
} }
else if (card_data) { else if (card_data) {
if (card_data.gsx$splash) { if (card_data.gsx$splash) {
return (<Single return (<Single
card={card_data} card={card_data}
col0={<React.Fragment> col0={<>
<div> <div>
<strong>Tribe: </strong> <strong>Tribe: </strong>
<Tribe tribe={card_data.gsx$tribe} /> <Tribe tribe={card_data.gsx$tribe} />
@ -82,7 +82,7 @@ export default class SingleMugic extends React.Component {
<strong>Cost: </strong> <strong>Cost: </strong>
{cost()} {cost()}
</div> </div>
</React.Fragment>} </>}
/>); />);
} }
} }

View File

@ -9,12 +9,12 @@ import s from '../../../styles/app.style';
// own "name" display function // own "name" display function
function Name(props) { function Name(props) {
let name = props.name.split(","); let name = props.name.split(",");
return (<React.Fragment> return (<>
<span>{name[0]}</span> <span>{name[0]}</span>
{ name.length > 1 && { name.length > 1 &&
<span className="bigger"><br />{name[1].trim()}</span> <span className="bigger"><br />{name[1].trim()}</span>
} }
</React.Fragment>); </>);
} }
function Artist(props) { function Artist(props) {
@ -38,8 +38,8 @@ export default class Single extends React.Component {
} }
render() { render() {
let card = this.props.card; let { card } = this.props;
return (<React.Fragment> return (<>
<div className={"modal" + (this.fullscreen?"":" hidden")}> <div className={"modal" + (this.fullscreen?"":" hidden")}>
<span className="close" onClick={this.close.bind(this)}>&times;</span> <span className="close" onClick={this.close.bind(this)}>&times;</span>
<img className="modal-content" src={API.base_image + card.gsx$splash} /> <img className="modal-content" src={API.base_image + card.gsx$splash} />
@ -60,50 +60,53 @@ export default class Single extends React.Component {
} }
{!this.props.text && {!this.props.text &&
<div className="column"> <div className="column">
{card.gsx$artist && <React.Fragment> {card.gsx$artist && <>
<div> <div>
<strong>Artist(s):</strong> <strong>Artist(s):</strong>
<Artist artist={card.gsx$artist} /> <Artist artist={card.gsx$artist} />
</div> </div>
<hr /> <hr />
</React.Fragment>} </>}
{card.gsx$set && <>
<div> <div>
<strong>Set: </strong> <strong>Set: </strong>
{`${API.sets[card.gsx$set]} (${card.gsx$set})`} {`${API.sets[card.gsx$set]} (${card.gsx$set})`}
</div> </div>
<hr /> <hr />
</>
}
<div> <div>
<strong>Rarity: </strong> <strong>Rarity: </strong>
<Rarity set={card.gsx$set} rarity={card.gsx$rarity} notext="true" /> <Rarity set={card.gsx$set} rarity={card.gsx$rarity} notext="true" />
&nbsp;{card.gsx$rarity} {card.gsx$rarity}
</div> </div>
<hr /> <hr />
<div> <div>
<strong>Card ID: </strong> <strong>Card ID: </strong>
{card.gsx$id} {card.gsx$id}
</div> </div>
{this.props.col0 && <React.Fragment> {this.props.col0 && <>
<hr /> <hr />
{this.props.col0} {this.props.col0}
</React.Fragment>} </>}
{card.gsx$ability && <React.Fragment> {card.gsx$ability && <>
<hr /> <hr />
<div> <div>
<strong>Ability:</strong> <strong>Ability:</strong>
<Ability ability={card.gsx$ability} /> <Ability ability={card.gsx$ability} />
</div> </div>
</React.Fragment>} </>}
{card.gsx$flavortext && <React.Fragment> {card.gsx$flavortext && <>
<hr /> <hr />
<div> <div>
<strong>Card Flavor:</strong><br /> <strong>Card Flavor:</strong><br />
{card.gsx$flavortext} {card.gsx$flavortext}
</div> </div>
</React.Fragment>} </>}
{this.props.col1 && <React.Fragment> {this.props.col1 && <>
<hr /> <hr />
this.props.col1 this.props.col1
</React.Fragment>} </>}
</div> </div>
} }
{!this.props.text && {!this.props.text &&
@ -112,6 +115,6 @@ export default class Single extends React.Component {
</div> </div>
} }
</div> </div>
</React.Fragment>); </>);
} }
} }

View File

@ -28,7 +28,8 @@ export default class Tribes extends React.Component {
API.LoadDB([{ 'cards': 'creatures' }, { 'portal': 'creatures' }, { 'cards': 'mugic' }, { 'portal': 'mugic' }]) API.LoadDB([{ 'cards': 'creatures' }, { 'portal': 'creatures' }, { 'cards': 'mugic' }, { 'portal': 'mugic' }])
.then(() => { .then(() => {
this.loaded = true; this.loaded = true;
}); })
.catch(() => {});
return (<Loading />); return (<Loading />);
} }

View File

@ -41,10 +41,10 @@ export default class Base extends React.Component {
} }
function Routing(props) { function Routing(props) {
const url = props.match.url; const { url } = props.match;
return ( return (
<React.Fragment> <>
<Route exact path={url} component={Home} /> <Route exact path={url} component={Home} />
<Route path={`${url}/Attacks`} render={(props) => <Category {...props} type="Attacks" component={Attack} />} /> <Route path={`${url}/Attacks`} render={(props) => <Category {...props} type="Attacks" component={Attack} />} />
<Route path={`${url}/Battlegear`} render={(props) => <Category {...props} type="Battlegear" component={Battlegear} />} /> <Route path={`${url}/Battlegear`} render={(props) => <Category {...props} type="Battlegear" component={Battlegear} />} />
@ -55,7 +55,7 @@ function Routing(props) {
<Route key={i} path={`${url}/${tribe}`} component={Tribes} /> <Route key={i} path={`${url}/${tribe}`} component={Tribes} />
))} ))}
<Route path={`${url}/Search`} component={Search} /> <Route path={`${url}/Search`} component={Search} />
</React.Fragment> </>
); );
} }