144 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			144 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
// @ts-check
 | 
						|
import tseslint from "typescript-eslint";
 | 
						|
 | 
						|
const MAX_DEPTH = 4;
 | 
						|
const MAX_NESTED_CALLBACKS = 4;
 | 
						|
const MAX_PARAMS = 5;
 | 
						|
 | 
						|
/**
 | 
						|
 * ESLint configuration for JavaScript authentik projects.
 | 
						|
 */
 | 
						|
export const javaScriptConfig = tseslint.config({
 | 
						|
    rules: {
 | 
						|
        // TODO: Clean up before enabling.
 | 
						|
        "accessor-pairs": "off",
 | 
						|
        "array-callback-return": "error",
 | 
						|
        "block-scoped-var": "error",
 | 
						|
        "consistent-return": ["error", { treatUndefinedAsUnspecified: false }],
 | 
						|
        "consistent-this": ["error", "that"],
 | 
						|
        "curly": "off",
 | 
						|
        "dot-notation": [
 | 
						|
            "error",
 | 
						|
            {
 | 
						|
                allowKeywords: true,
 | 
						|
            },
 | 
						|
        ],
 | 
						|
        "eqeqeq": "error",
 | 
						|
        "func-names": ["error", "as-needed"],
 | 
						|
        "guard-for-in": "error",
 | 
						|
        "max-depth": ["error", MAX_DEPTH],
 | 
						|
        "max-nested-callbacks": ["error", MAX_NESTED_CALLBACKS],
 | 
						|
        "max-params": ["error", MAX_PARAMS],
 | 
						|
        // TODO: Clean up before enabling.
 | 
						|
        // "new-cap": "error",
 | 
						|
        "no-alert": "error",
 | 
						|
        "no-array-constructor": "error",
 | 
						|
        "no-bitwise": [
 | 
						|
            "error",
 | 
						|
            {
 | 
						|
                allow: ["~"],
 | 
						|
                int32Hint: true,
 | 
						|
            },
 | 
						|
        ],
 | 
						|
        "no-caller": "error",
 | 
						|
        "no-case-declarations": "error",
 | 
						|
        "no-class-assign": "error",
 | 
						|
        "no-cond-assign": "error",
 | 
						|
        "no-const-assign": "error",
 | 
						|
        "no-constant-condition": "error",
 | 
						|
        "no-control-regex": "error",
 | 
						|
        "no-debugger": "error",
 | 
						|
        "no-delete-var": "error",
 | 
						|
        "no-div-regex": "error",
 | 
						|
        "no-dupe-args": "error",
 | 
						|
        "no-dupe-keys": "error",
 | 
						|
        "no-duplicate-case": "error",
 | 
						|
        "no-else-return": "error",
 | 
						|
        "no-empty": "error",
 | 
						|
        "no-empty-character-class": "error",
 | 
						|
        "no-empty-function": ["error", { allow: ["constructors"] }],
 | 
						|
        "no-labels": "error",
 | 
						|
        "no-eq-null": "error",
 | 
						|
        "no-eval": "error",
 | 
						|
        "no-ex-assign": "error",
 | 
						|
        "no-extend-native": "error",
 | 
						|
        "no-extra-bind": "error",
 | 
						|
        "no-extra-boolean-cast": "error",
 | 
						|
        "no-extra-label": "error",
 | 
						|
        "no-fallthrough": "error",
 | 
						|
        "no-func-assign": "error",
 | 
						|
        "no-implied-eval": "error",
 | 
						|
        "no-implicit-coercion": "error",
 | 
						|
        "no-implicit-globals": "error",
 | 
						|
        "no-inner-declarations": ["error", "functions"],
 | 
						|
        "no-invalid-regexp": "error",
 | 
						|
        "no-irregular-whitespace": "error",
 | 
						|
        "no-iterator": "error",
 | 
						|
        "no-label-var": "error",
 | 
						|
        "no-lone-blocks": "error",
 | 
						|
        "no-lonely-if": "error",
 | 
						|
        "no-loop-func": "error",
 | 
						|
        "no-multi-str": "error",
 | 
						|
        // TODO: Clean up before enabling.
 | 
						|
        "no-negated-condition": "off",
 | 
						|
        "no-new": "error",
 | 
						|
        "no-new-func": "error",
 | 
						|
        "no-new-wrappers": "error",
 | 
						|
        "no-obj-calls": "error",
 | 
						|
        "no-octal": "error",
 | 
						|
        "no-octal-escape": "error",
 | 
						|
        "no-param-reassign": ["error", { props: false }],
 | 
						|
        "no-proto": "error",
 | 
						|
        "no-redeclare": "error",
 | 
						|
        "no-regex-spaces": "error",
 | 
						|
        "no-restricted-syntax": ["error", "WithStatement"],
 | 
						|
        "no-script-url": "error",
 | 
						|
        "no-self-assign": "error",
 | 
						|
        "no-self-compare": "error",
 | 
						|
        "no-sequences": "error",
 | 
						|
        // TODO: Clean up before enabling.
 | 
						|
        // "no-shadow": "error",
 | 
						|
        "no-shadow-restricted-names": "error",
 | 
						|
        "no-sparse-arrays": "error",
 | 
						|
        "no-this-before-super": "error",
 | 
						|
        "no-throw-literal": "error",
 | 
						|
        "no-trailing-spaces": "off", // Handled by Prettier.
 | 
						|
        "no-undef": "off",
 | 
						|
        "no-undef-init": "off",
 | 
						|
        "no-unexpected-multiline": "error",
 | 
						|
        "no-useless-constructor": "error",
 | 
						|
        "no-unmodified-loop-condition": "error",
 | 
						|
        "no-unneeded-ternary": "error",
 | 
						|
        "no-unreachable": "error",
 | 
						|
        "no-unused-expressions": "error",
 | 
						|
        "no-unused-labels": "error",
 | 
						|
        "no-use-before-define": "error",
 | 
						|
        "no-useless-call": "error",
 | 
						|
        "no-dupe-class-members": "error",
 | 
						|
        "no-var": "error",
 | 
						|
        "no-void": "error",
 | 
						|
        "no-with": "error",
 | 
						|
        "prefer-arrow-callback": "error",
 | 
						|
        "prefer-const": "error",
 | 
						|
        "prefer-rest-params": "error",
 | 
						|
        "prefer-spread": "error",
 | 
						|
        "prefer-template": "error",
 | 
						|
        "radix": "error",
 | 
						|
        "require-yield": "error",
 | 
						|
        "strict": ["error", "global"],
 | 
						|
        "use-isnan": "error",
 | 
						|
        "valid-typeof": "error",
 | 
						|
        "vars-on-top": "error",
 | 
						|
        "yoda": ["error", "never"],
 | 
						|
 | 
						|
        "no-console": ["error", { allow: ["debug", "warn", "error"] }],
 | 
						|
        // SonarJS is not yet compatible with ESLint 9.  Commenting these out
 | 
						|
        // until it is.
 | 
						|
        //    "sonarjs/cognitive-complexity": ["off", MAX_COGNITIVE_COMPLEXITY],
 | 
						|
        //    "sonarjs/no-duplicate-string": "off",
 | 
						|
        //    "sonarjs/no-nested-template-literals": "off",
 | 
						|
    },
 | 
						|
});
 | 
						|
 | 
						|
export default javaScriptConfig;
 |