Skip to content

Commit

Permalink
Merge pull request Infinite-Chess#264 from Heinrich-XIAO/main
Browse files Browse the repository at this point in the history
Fix indentation everywhere else
  • Loading branch information
Naviary2 authored Oct 5, 2024
2 parents 65bc09f + d785392 commit cc178d7
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 281 deletions.
14 changes: 7 additions & 7 deletions dev-utils/scripts/bigint.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ const bigint = (function() {

return [product, factor1];
}

// Divides and returns a BigInt with the same factor as the first argument!
function divide([bigint1, factor1], [bigint2, factor2]) {
const adjustedNumerator = bigint1 * factor2;
const quotient = adjustedNumerator / bigint2;

return [quotient, factor1];
}


function bigIntToString([bigInt, factor]) {

const string = bigInt.toString();

// If the factor is 1, no need to insert a decimal point
if (factor === 1n) return string;

const factorLength = factor.toString().length - 1; // Subtract 1 because '10' has 1 zero, '100' has 2 zeros, etc.

if (string.length <= factorLength) {
// If the string length is less than or equal to the factor length, pad with zeros and place a decimal at the start
const padding = '0'.repeat(factorLength - string.length + 1); // +1 for the '0.' before the number
Expand Down Expand Up @@ -90,7 +90,7 @@ const bigint = (function() {
function log10(bigint) {
if (bigint < 0) return NaN;
const s = bigint.toString(10);

return s.length + Math.log10("0." + s.substring(0, 15));
}

Expand All @@ -112,4 +112,4 @@ const bigint = (function() {
getDecimalCountFromScalingFactor
});

})();
})();
97 changes: 48 additions & 49 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,53 @@
/* eslint-disable indent */
import globals from "globals";
import pluginJs from "@eslint/js";

export default [
pluginJs.configs.recommended,
{
rules: { // Overrides the preset defined by "pluginJs.configs.recommended" above
'no-undef': 'error', // Undefined variables not allowed
'no-unused-vars': 'warn', // Unused variables give a warning
'semi': ['error', 'always'], // Enforces semicolons be present at the end of every line.
'semi-spacing': ['error', { // Enforces semicolons have a space after them if they are proceeded by other statements.
before: false,
after: true,
}],
'keyword-spacing': ['error', { // Requires a space be after if, else, for, and while's.
before: true,
after: true,
}],
"space-before-function-paren": ["error", "never"], // Enforces there be NO space between function DECLARATIONS and ()
"space-before-blocks": ["error", "always"], // Enforces there be a space between function parameters and the {} block
"arrow-spacing": ["error", { "before": true, "after": true }], // Requires a space before and after "=>" in arrow functions
"func-call-spacing": ["error", "never"], // Enforces there be NO space between function CALLS and ()
"space-infix-ops": ["error", { "int32Hint": false }], // Enforces a space around infix operators, like "=" in assignments
"no-eval": "error", // Disallows use of `eval()`, as it can lead to security vulnerabilities and performance issues.
'indent': ['error', 'tab', { // All indentation must use tabs
'SwitchCase': 1, // Enforce switch statements to have indentation (they don't by default)
"ignoredNodes": ["ConditionalExpression", "ArrayExpression"] // Ignore conditional expressions "?" & ":" over multiple lines, AND array contents over multiple lines!
}],
"prefer-const": "error", // "let" variables that are never redeclared must be declared as "const"
"no-var": "error", // Disallows declaring variables with "var", as they are function-scoped (not block), so hoisting is very confusing.
"max-depth": ["warn", 4], // Maximum number of nested blocks allowed.
"eqeqeq": ["error", "always"], // Disallows "!=" and "==" to remove type coercion bugs. Use "!==" and "===" instead.
'dot-notation': 'error', // Forces dot notation `.` instead of bracket notation `[""]` wherever possible
'no-empty': 'off', // Disable the no-empty rule so blocks aren't entirely red just as we create them
'no-prototype-builtins': 'off', // Allows Object.hasOwnProperty() to be used
// "no-multi-spaces": "error", // Disallows multiple spaces that isn't indentation.
// "max-lines": ["warn", 500] // Can choose to enable to place a cap on how big files can be, in lines.
// "complexity": ["warn", { "max": 10 }] // Can choose to enable to cap the complexity, or number of independant paths, which can lead to methods.
},
languageOptions: {
sourceType: "module", // Can also be "commonjs", but "import" and "export" statements will give an eslint error
globals: {
...globals.node, // Defines "require" and "exports"
...globals.browser, // Defines all browser environment variables for the game code
// Game code scripts are considered public variables
// MOST OF THE GAME SCRIPTS are ESM scripts, importing their own definitions, so we don't need to list them below.
translations: "readonly", // Injected into the html through ejs
memberHeader: "readonly",
htmlscript: "readonly",
}
}
}
pluginJs.configs.recommended,
{
rules: { // Overrides the preset defined by "pluginJs.configs.recommended" above
'no-undef': 'error', // Undefined variables not allowed
'no-unused-vars': 'warn', // Unused variables give a warning
'semi': ['error', 'always'], // Enforces semicolons be present at the end of every line.
'semi-spacing': ['error', { // Enforces semicolons have a space after them if they are proceeded by other statements.
before: false,
after: true,
}],
'keyword-spacing': ['error', { // Requires a space be after if, else, for, and while's.
before: true,
after: true,
}],
"space-before-function-paren": ["error", "never"], // Enforces there be NO space between function DECLARATIONS and ()
"space-before-blocks": ["error", "always"], // Enforces there be a space between function parameters and the {} block
"arrow-spacing": ["error", { "before": true, "after": true }], // Requires a space before and after "=>" in arrow functions
"func-call-spacing": ["error", "never"], // Enforces there be NO space between function CALLS and ()
"space-infix-ops": ["error", { "int32Hint": false }], // Enforces a space around infix operators, like "=" in assignments
"no-eval": "error", // Disallows use of `eval()`, as it can lead to security vulnerabilities and performance issues.
'indent': ['error', 'tab', { // All indentation must use tabs
'SwitchCase': 1, // Enforce switch statements to have indentation (they don't by default)
"ignoredNodes": ["ConditionalExpression", "ArrayExpression"] // Ignore conditional expressions "?" & ":" over multiple lines, AND array contents over multiple lines!
}],
"prefer-const": "error", // "let" variables that are never redeclared must be declared as "const"
"no-var": "error", // Disallows declaring variables with "var", as they are function-scoped (not block), so hoisting is very confusing.
"max-depth": ["warn", 4], // Maximum number of nested blocks allowed.
"eqeqeq": ["error", "always"], // Disallows "!=" and "==" to remove type coercion bugs. Use "!==" and "===" instead.
'dot-notation': 'error', // Forces dot notation `.` instead of bracket notation `[""]` wherever possible
'no-empty': 'off', // Disable the no-empty rule so blocks aren't entirely red just as we create them
'no-prototype-builtins': 'off', // Allows Object.hasOwnProperty() to be used
// "no-multi-spaces": "error", // Disallows multiple spaces that isn't indentation.
// "max-lines": ["warn", 500] // Can choose to enable to place a cap on how big files can be, in lines.
// "complexity": ["warn", { "max": 10 }] // Can choose to enable to cap the complexity, or number of independant paths, which can lead to methods.
},
languageOptions: {
sourceType: "module", // Can also be "commonjs", but "import" and "export" statements will give an eslint error
globals: {
...globals.node, // Defines "require" and "exports"
...globals.browser, // Defines all browser environment variables for the game code
// Game code scripts are considered public variables
// MOST OF THE GAME SCRIPTS are ESM scripts, importing their own definitions, so we don't need to list them below.
translations: "readonly", // Injected into the html through ejs
memberHeader: "readonly",
htmlscript: "readonly",
}
}
}
];
26 changes: 13 additions & 13 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler",
"target": "ES2020",
"jsx": "react",
"allowImportingTsExtensions": true,
"strictNullChecks": true,
"strictFunctionTypes": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler",
"target": "ES2020",
"jsx": "react",
"allowImportingTsExtensions": true,
"strictNullChecks": true,
"strictFunctionTypes": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
14 changes: 7 additions & 7 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"ignore": [
"./database/**/*",
"./dist/**/*",
"./docs/*"
],
"exec": "npm run build && npm run start",
"ext": "js,html,css,jpg,png,gif,mp3,wav,webp,toml,ejs,json,mjs,md"
"ignore": [
"./database/**/*",
"./dist/**/*",
"./docs/*"
],
"exec": "npm run build && npm run start",
"ext": "js,html,css,jpg,png,gif,mp3,wav,webp,toml,ejs,json,mjs,md"
}
96 changes: 48 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
{
"name": "infinite-chess-server",
"version": "1.4.3",
"description": "infinitechess.org server",
"author": "Naviary",
"license": "AGPL",
"main": "src/server/server.js",
"type": "module",
"dependencies": {
"@swc/core": "^1.7.0",
"bcrypt": "^5.1.1",
"browserslist": "^4.23.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"date-fns": "^2.23.0",
"dotenv": "^16.0.3",
"ejs": "^3.1.10",
"esbuild": "^0.23.1",
"express": "^4.18.2",
"glob": "^11.0.0",
"i18next": "^23.12.1",
"i18next-http-middleware": "^3.6.0",
"jsonwebtoken": "^9.0.2",
"lightningcss": "^1.25.1",
"marked": "^14.1.2",
"node-forge": "^1.3.1",
"nodemailer": "^6.8.0",
"nodemon": "^3.1.4",
"proper-lockfile": "^4.1.2",
"sharp": "^0.33.4",
"smol-toml": "^1.2.2",
"uuid": "^8.3.2",
"ws": "^8.16.0",
"xss": "^1.0.15"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@types/node": "^20.14.10",
"eslint": "^9.9.0",
"globals": "^15.9.0",
"madge": "^8.0.0"
},
"scripts": {
"build": "node build.js",
"watch": "nodemon",
"start": "node .",
"build-images": "node src/server/utility/generateImages.js",
"generate-dependancy-graph": "node src/server/utility/generateDependancyGraph.js"
}
"name": "infinite-chess-server",
"version": "1.4.3",
"description": "infinitechess.org server",
"author": "Naviary",
"license": "AGPL",
"main": "src/server/server.js",
"type": "module",
"dependencies": {
"@swc/core": "^1.7.0",
"bcrypt": "^5.1.1",
"browserslist": "^4.23.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"date-fns": "^2.23.0",
"dotenv": "^16.0.3",
"ejs": "^3.1.10",
"esbuild": "^0.23.1",
"express": "^4.18.2",
"glob": "^11.0.0",
"i18next": "^23.12.1",
"i18next-http-middleware": "^3.6.0",
"jsonwebtoken": "^9.0.2",
"lightningcss": "^1.25.1",
"marked": "^14.1.2",
"node-forge": "^1.3.1",
"nodemailer": "^6.8.0",
"nodemon": "^3.1.4",
"proper-lockfile": "^4.1.2",
"sharp": "^0.33.4",
"smol-toml": "^1.2.2",
"uuid": "^8.3.2",
"ws": "^8.16.0",
"xss": "^1.0.15"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@types/node": "^20.14.10",
"eslint": "^9.9.0",
"globals": "^15.9.0",
"madge": "^8.0.0"
},
"scripts": {
"build": "node build.js",
"watch": "nodemon",
"start": "node .",
"build-images": "node src/server/utility/generateImages.js",
"generate-dependancy-graph": "node src/server/utility/generateDependancyGraph.js"
}
}
28 changes: 14 additions & 14 deletions src/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2020",
"jsx": "react",
"allowImportingTsExtensions": true,
"strictNullChecks": true,
"strictFunctionTypes": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2020",
"jsx": "react",
"allowImportingTsExtensions": true,
"strictNullChecks": true,
"strictFunctionTypes": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
Loading

0 comments on commit cc178d7

Please sign in to comment.