mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-20 23:44:08 +00:00
02e15da51b
This replaces the old arclint eslint setup 1:1 rule wise, only porting the configuration to a format recent eslint can read. Further remove the arclint setup as it is no longer of use. Thanks to Stan for reviewing all needed fixes to Javascript code to allow for adding this without compromises. Fixes: #7812 Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
140 lines
3.1 KiB
JavaScript
140 lines
3.1 KiB
JavaScript
// Hack to get eslint run via pre-commit to find the braces plugin in the pre-commit cache,
|
|
// should be 'import braceRules from "eslint-plugin-brace-rules";'
|
|
import { createRequire } from 'node:module';
|
|
const require = createRequire(import.meta.url);
|
|
const braceRules = require("eslint-plugin-brace-rules");
|
|
|
|
|
|
const configIgnores = {
|
|
"ignores": [
|
|
"binaries/data/mods/mod/globalscripts/sprintf.js",
|
|
"libraries/",
|
|
"source/tools/profiler2/jquery*",
|
|
"source/tools/replayprofile/jquery*",
|
|
"source/tools/templatesanalyzer/tablefilter/",
|
|
],
|
|
};
|
|
|
|
|
|
const configEslintBase = {
|
|
"rules": {
|
|
"no-caller": 1,
|
|
"no-cond-assign": 1,
|
|
|
|
"no-constant-condition": ["error", {
|
|
"checkLoops": false,
|
|
}],
|
|
|
|
"no-dupe-args": 1,
|
|
"no-dupe-keys": 1,
|
|
"no-duplicate-case": 1,
|
|
"no-empty": 1,
|
|
"no-extra-boolean-cast": 0,
|
|
"no-extra-parens": 0,
|
|
"no-extra-semi": 1,
|
|
"no-floating-decimal": 1,
|
|
"no-func-assign": 1,
|
|
"no-negated-in-lhs": 1,
|
|
"no-obj-calls": 1,
|
|
"no-unreachable": 1,
|
|
"no-use-before-define": ["error", "nofunc"],
|
|
"use-isnan": 1,
|
|
"valid-jsdoc": 0,
|
|
"valid-typeof": 1,
|
|
"block-scoped-var": 0,
|
|
"consistent-return": 1,
|
|
"default-case": 1,
|
|
"dot-notation": 1,
|
|
"no-else-return": 1,
|
|
"no-invalid-this": 1,
|
|
"no-loop-func": 0,
|
|
|
|
"no-multi-spaces": ["warn", {
|
|
"ignoreEOLComments": true,
|
|
}],
|
|
|
|
"no-new": 1,
|
|
"no-redeclare": 0,
|
|
"no-return-assign": 1,
|
|
"no-self-assign": 1,
|
|
"no-self-compare": 1,
|
|
"no-unmodified-loop-condition": 1,
|
|
"no-unused-expressions": 1,
|
|
"no-unused-labels": 1,
|
|
"no-useless-concat": 0,
|
|
"yoda": 1,
|
|
"no-delete-var": 1,
|
|
"no-label-var": 1,
|
|
"no-shadow-restricted-names": 1,
|
|
"no-shadow": 1,
|
|
"no-undef": 0,
|
|
"no-undef-init": 1,
|
|
"no-unused-vars": 0,
|
|
"comma-spacing": 1,
|
|
|
|
"indent": ["warn", "tab", {
|
|
"outerIIFEBody": 0,
|
|
}],
|
|
|
|
"key-spacing": 1,
|
|
"new-cap": 0,
|
|
"new-parens": 1,
|
|
"no-mixed-spaces-and-tabs": ["warn", "smart-tabs"],
|
|
"no-multi-assign": 1,
|
|
"no-trailing-spaces": 1,
|
|
"no-unneeded-ternary": 1,
|
|
"no-irregular-whitespace": 1,
|
|
"object-curly-spacing": ["warn", "always"],
|
|
"operator-assignment": 1,
|
|
"operator-linebreak": ["warn", "after"],
|
|
"quote-props": 1,
|
|
"semi": 1,
|
|
"semi-spacing": 1,
|
|
"space-before-function-paren": ["warn", "never"],
|
|
"space-in-parens": 1,
|
|
"space-unary-ops": 1,
|
|
"spaced-comment": ["warn", "always"],
|
|
"no-class-assign": 1,
|
|
"no-const-assign": 1,
|
|
"no-dupe-class-members": 1,
|
|
"prefer-const": 1,
|
|
}
|
|
};
|
|
|
|
|
|
const configBracesRules = {
|
|
"plugins": {
|
|
"brace-rules": braceRules
|
|
},
|
|
|
|
"rules": {
|
|
"brace-rules/brace-on-same-line": [
|
|
"warn",
|
|
{
|
|
"FunctionDeclaration": "never",
|
|
"FunctionExpression": "ignore",
|
|
"ArrowFunctionExpression": "always",
|
|
"IfStatement": "never",
|
|
"TryStatement": "ignore",
|
|
"CatchClause": "ignore",
|
|
"DoWhileStatement": "never",
|
|
"WhileStatement": "never",
|
|
"ForStatement": "never",
|
|
"ForInStatement": "never",
|
|
"ForOfStatement": "never",
|
|
"SwitchStatement": "never",
|
|
},
|
|
{
|
|
"allowSingleLine": true,
|
|
}
|
|
],
|
|
}
|
|
};
|
|
|
|
|
|
const configs = [configIgnores, configEslintBase];
|
|
configs[1].plugins = { ...configBracesRules.plugins };
|
|
Object.assign(configs[1].rules, configBracesRules.rules);
|
|
|
|
export default configs;
|