From cae6066647dc9e63a2fe4e01834b2427ae129469 Mon Sep 17 00:00:00 2001 From: Jonny Gerig Meyer Date: Mon, 18 Dec 2023 22:15:35 -0500 Subject: [PATCH] Update lint config --- .eslintrc.cjs | 394 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 295 insertions(+), 99 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 90eeb3370..396151fd8 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -13,120 +13,316 @@ module.exports = { }, "plugins": ["@typescript-eslint", "@stylistic"], "rules": { - // ESLint rules: https://eslint.org/docs/latest/rules/ - // Based off of: https://github.com/eslint/eslint/blob/v8.54.0/packages/js/src/configs/eslint-recommended.js - "constructor-super": 1, // Require `super()` calls in constructors - "curly": 1, // Enforce consistent brace style for all control statements - "for-direction": 1, // Enforce “for” loop update clause moving the counter in the right direction - "getter-return": 1, // Enforce `return` statements in getters - "no-async-promise-executor": 1, // Disallow using an async function as a Promise executor - "no-case-declarations": 1, // Disallow lexical declarations in case clauses - "no-class-assign": 1, // Disallow reassigning class members - "no-compare-neg-zero": 1, // Disallow comparing against -0 - "no-const-assign": 1, // Disallow reassigning `const` variables - "no-constant-condition": 1, // Disallow constant expressions in conditions - "no-control-regex": 1, // Disallow control characters in regular expressions - "no-debugger": 1, // Disallow the use of `debugger` - "no-delete-var": 1, // Disallow deleting variables - "no-dupe-args": 1, // Disallow duplicate arguments in `function` definitions - "no-dupe-class-members": 1, // Disallow duplicate class members - "no-dupe-else-if": 1, // Disallow duplicate conditions in if-else-if chains - "no-dupe-keys": 1, // Disallow duplicate keys in object literals - "no-duplicate-case": 1, // Disallow duplicate case labels - "no-empty-character-class": 1, // Disallow empty character classes in regular expressions - "no-empty-pattern": 1, // Disallow empty destructuring patterns - "no-ex-assign": 1, // Disallow reassigning exceptions in `catch` clauses - "no-extra-boolean-cast": 1, // Disallow unnecessary boolean casts - "no-fallthrough": 1, // Disallow fallthrough of `case` statements - "no-func-assign": 1, // Disallow reassigning `function` declarations - "no-global-assign": 1, // Disallow assignments to native objects or read-only global variables - "no-import-assign": 1, // Disallow assigning to imported bindings - "no-inner-declarations": 1, // Disallow variable or `function` declarations in nested blocks - "no-invalid-regexp": 1, // Disallow invalid regular expression strings in `RegExp` constructors - "no-irregular-whitespace": 1, // Disallow irregular whitespace - "no-misleading-character-class": 1, // Disallow characters which are made with multiple code points in character class syntax - "no-new-symbol": 1, // Disallow `new` operators with the `Symbol` object - "no-nonoctal-decimal-escape": 1, // Disallow `\8` and `\9` escape sequences in string literals - "no-obj-calls": 1, // Disallow calling global object properties as functions - "no-octal": 1, // Disallow octal literals - "no-prototype-builtins": 1, // Disallow calling some `Object.prototype` methods directly on objects - "no-regex-spaces": 1, // Disallow multiple spaces in regular expressions - "no-self-assign": 1, // Disallow assignments where both sides are exactly the same - "no-shadow-restricted-names": 1, // Disallow identifiers from shadowing restricted names - "no-this-before-super": 1, // Disallow `this`/`super` before calling `super()` in constructors - "no-undef": 1, // Disallow the use of undeclared variables unless mentioned in `/*global */` comments - "no-unexpected-multiline": 1, // Disallow confusing multiline expressions - "no-unreachable": 1, // Disallow unreachable code after `return`, `throw`, `continue`, and `break` statements - "no-unsafe-finally": 1, // Disallow control flow statements in `finally` blocks - "no-unsafe-negation": 1, // Disallow negating the left operand of relational operators - "no-unsafe-optional-chaining": 1, // Disallow use of optional chaining in contexts where the `undefined` value is not allowed - "no-unused-labels": 1, // Disallow unused labels - "no-useless-backreference": 1, // Disallow useless backreferences in regular expressions - "no-useless-call": 1, // Disallow unnecessary calls to `.call()` and `.apply()` - "no-useless-catch": 1, // Disallow unnecessary `catch` clauses - "no-useless-escape": 1, // Disallow unnecessary escape characters - "no-with": 1, // Disallow `with` statements - "require-yield": 1, // Require generator functions to contain `yield` - "use-isnan": 1, // Require calls to `isNaN()` when checking for `NaN` - "valid-typeof": 1, // Enforce comparing `typeof` expressions against valid strings + /** + * ESLint rules: https://eslint.org/docs/latest/rules/ + * Based off of: https://github.com/eslint/eslint/blob/v8.54.0/packages/js/src/configs/eslint-recommended.js + */ + // Require `super()` calls in constructors + // https://eslint.org/docs/latest/rules/constructor-super + "constructor-super": 1, + // Enforce curly braces for all control statements + // https://eslint.org/docs/latest/rules/curly + "curly": 1, + // Enforce “for” loop update clause moving the counter in the right direction + // https://eslint.org/docs/latest/rules/for-direction + "for-direction": 1, + // Enforce `return` statements in getters + // https://eslint.org/docs/latest/rules/getter-return + "getter-return": 1, + // Disallow using an async function as a Promise executor + // https://eslint.org/docs/latest/rules/no-async-promise-executor + "no-async-promise-executor": 1, + // Disallow `let`/const`/function`/`class` in `case`/`default` clauses + // https://eslint.org/docs/latest/rules/no-case-declarations + "no-case-declarations": 1, + // Disallow reassigning class members + // https://eslint.org/docs/latest/rules/no-class-assign + "no-class-assign": 1, + // Disallow comparing against -0 + // https://eslint.org/docs/latest/rules/no-compare-neg-zero + "no-compare-neg-zero": 1, + // Disallow reassigning `const` variables + // https://eslint.org/docs/latest/rules/no-const-assign + "no-const-assign": 1, + // Disallow constant expressions in conditions + // https://eslint.org/docs/latest/rules/no-constant-condition + "no-constant-condition": 1, + // Disallow control characters in regular expressions + // https://eslint.org/docs/latest/rules/no-control-regex + "no-control-regex": 1, + // Disallow the use of `debugger` + // https://eslint.org/docs/latest/rules/no-debugger + "no-debugger": 1, + // Disallow deleting variables + // https://eslint.org/docs/latest/rules/no-delete-var + "no-delete-var": 1, + // Disallow duplicate arguments in `function` definitions + // https://eslint.org/docs/latest/rules/no-dupe-args + "no-dupe-args": 1, + // Disallow duplicate class members + // https://eslint.org/docs/latest/rules/no-dupe-class-members + "no-dupe-class-members": 1, + // Disallow duplicate conditions in if-else-if chains + // https://eslint.org/docs/latest/rules/no-dupe-else-if + "no-dupe-else-if": 1, + // Disallow duplicate keys in object literals + // https://eslint.org/docs/latest/rules/no-dupe-keys + "no-dupe-keys": 1, + // Disallow duplicate case labels + // https://eslint.org/docs/latest/rules/no-duplicate-case + "no-duplicate-case": 1, + // Disallow empty character classes in regular expressions + // https://eslint.org/docs/latest/rules/no-empty-character-class + "no-empty-character-class": 1, + // Disallow empty destructuring patterns + // https://eslint.org/docs/latest/rules/no-empty-pattern + "no-empty-pattern": 1, + // Disallow reassigning exceptions in `catch` clauses + // https://eslint.org/docs/latest/rules/no-ex-assign + "no-ex-assign": 1, + // Disallow unnecessary boolean casts + // https://eslint.org/docs/latest/rules/no-extra-boolean-cast + "no-extra-boolean-cast": 1, + // Disallow fallthrough of `case` statements + // unless marked with a comment that matches `/falls?\s?through/i` regex + // https://eslint.org/docs/latest/rules/no-fallthrough + "no-fallthrough": 1, + // Disallow reassigning `function` declarations + // https://eslint.org/docs/latest/rules/no-func-assign + "no-func-assign": 1, + // Disallow assignments to native objects or read-only global variables + // https://eslint.org/docs/latest/rules/no-global-assign + "no-global-assign": 1, + // Disallow assigning to imported bindings + // https://eslint.org/docs/latest/rules/no-import-assign + "no-import-assign": 1, + // Disallow invalid regular expression strings in `RegExp` constructors + // https://eslint.org/docs/latest/rules/no-invalid-regexp + "no-invalid-regexp": 1, + // Disallow whitespace that is not `tab` or `space` except in string literals + // https://eslint.org/docs/latest/rules/no-irregular-whitespace + "no-irregular-whitespace": 1, + // Disallow characters which are made with multiple code points in character class syntax + // https://eslint.org/docs/latest/rules/no-misleading-character-class + "no-misleading-character-class": 1, + // Disallow `new` operators with the `Symbol` object + // https://eslint.org/docs/latest/rules/no-new-symbol + "no-new-symbol": 1, + // Disallow `\8` and `\9` escape sequences in string literals + // https://eslint.org/docs/latest/rules/no-nonoctal-decimal-escape + "no-nonoctal-decimal-escape": 1, + // Disallow calling global object properties as functions + // https://eslint.org/docs/latest/rules/no-obj-calls + "no-obj-calls": 1, + // Disallow octal literals + // https://eslint.org/docs/latest/rules/no-octal + "no-octal": 1, + // Disallow calling some `Object.prototype` methods directly on objects + // https://eslint.org/docs/latest/rules/no-prototype-builtins + "no-prototype-builtins": 1, + // Disallow multiple spaces in regular expressions + // https://eslint.org/docs/latest/rules/no-regex-spaces + "no-regex-spaces": 1, + // Disallow assignments where both sides are exactly the same + // https://eslint.org/docs/latest/rules/no-self-assign + "no-self-assign": 1, + // Disallow identifiers from shadowing restricted names + // https://eslint.org/docs/latest/rules/no-shadow-restricted-names + "no-shadow-restricted-names": 1, + // Disallow `this`/`super` before calling `super()` in constructors + // https://eslint.org/docs/latest/rules/no-this-before-super + "no-this-before-super": 1, + // Disallow the use of undeclared variables unless mentioned in `/*global */` comments + // https://eslint.org/docs/latest/rules/no-undef + // TODO: At-risk; subject to change. + "no-undef": 1, + // Disallow confusing multiline expressions + // https://eslint.org/docs/latest/rules/no-unexpected-multiline + // TODO: At-risk; subject to change. + "no-unexpected-multiline": 1, + // Disallow unreachable code after `return`, `throw`, `continue`, and `break` statements + // https://eslint.org/docs/latest/rules/no-unreachable + "no-unreachable": 1, + // Disallow control flow statements in `finally` blocks + // https://eslint.org/docs/latest/rules/no-unsafe-finally + "no-unsafe-finally": 1, + // Disallow negating the left operand of relational operators + // https://eslint.org/docs/latest/rules/no-unsafe-negation + "no-unsafe-negation": 1, + // Disallow use of optional chaining in contexts where the `undefined` value is not allowed + // https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining + "no-unsafe-optional-chaining": 1, + // Disallow unused labels + // https://eslint.org/docs/latest/rules/no-unused-labels + "no-unused-labels": 1, + // Disallow useless backreferences in regular expressions + // https://eslint.org/docs/latest/rules/no-useless-backreference + "no-useless-backreference": 1, + // Disallow unnecessary calls to `.call()` and `.apply()` + // https://eslint.org/docs/latest/rules/no-useless-call + "no-useless-call": 1, + // Disallow unnecessary `catch` clauses + // https://eslint.org/docs/latest/rules/no-useless-catch + "no-useless-catch": 1, + // Disallow unnecessary escape characters + // https://eslint.org/docs/latest/rules/no-useless-escape + "no-useless-escape": 1, + // Disallow `with` statements + // https://eslint.org/docs/latest/rules/no-with + "no-with": 1, + // Require generator functions to contain `yield` + // https://eslint.org/docs/latest/rules/require-yield + "require-yield": 1, + // Require calls to `isNaN()` when checking for `NaN` + // https://eslint.org/docs/latest/rules/use-isnan + "use-isnan": 1, + // Enforce comparing `typeof` expressions against valid strings + // https://eslint.org/docs/latest/rules/valid-typeof + "valid-typeof": 1, - // ESLint Stylistic rules: https://eslint.style/packages/default#rules - "@stylistic/arrow-spacing": 1, // Enforce consistent spacing before and after the arrow in arrow functions - "@stylistic/brace-style": [1, "stroustrup"], // Enforce consistent brace style for blocks - "@stylistic/comma-spacing": 1, // Enforce consistent spacing before and after commas - "@stylistic/eol-last": 1, // Require newline at the end of files - "@stylistic/indent": [1, "tab", { "SwitchCase": 1, "outerIIFEBody": 0 }], // Enforce consistent indentation - "@stylistic/keyword-spacing": 1, // Enforce consistent spacing before and after keywords - "@stylistic/no-extra-semi": 1, // Disallow unnecessary semicolons - "@stylistic/no-mixed-spaces-and-tabs": [1, "smart-tabs"], // Disallow mixed spaces and tabs for indentation - "@stylistic/no-trailing-spaces": 1, // Disallow trailing whitespace at the end of lines + /** + * ESLint Stylistic rules: https://eslint.style/packages/default#rules + */ + // Enforce a space before and after `=>` in arrow functions + // https://eslint.style/rules/default/arrow-spacing + "@stylistic/arrow-spacing": 1, + // Enforce consistent brace style for blocks + // https://eslint.style/rules/default/brace-style + "@stylistic/brace-style": [1, "stroustrup"], + // Enforce no space before and one or more spaces after a comma + // https://eslint.style/rules/default/comma-spacing + "@stylistic/comma-spacing": 1, + // Require newline at the end of files + // https://eslint.style/rules/default/eol-last + "@stylistic/eol-last": 1, + // Enforce consistent indentation + // https://eslint.style/rules/default/indent + "@stylistic/indent": [1, "tab", { "SwitchCase": 1, "outerIIFEBody": 0 }], + // Enforce consistent spacing before and after keywords + // https://eslint.style/rules/default/keyword-spacing + "@stylistic/keyword-spacing": 1, + // Disallow unnecessary semicolons + // https://eslint.style/rules/default/no-extra-semi + "@stylistic/no-extra-semi": 1, + // Disallow mixed spaces and tabs for indentation + // https://eslint.style/rules/default/no-mixed-spaces-and-tabs + "@stylistic/no-mixed-spaces-and-tabs": [1, "smart-tabs"], + // Disallow trailing whitespace at the end of lines + // https://eslint.style/rules/default/no-trailing-spaces + "@stylistic/no-trailing-spaces": 1, // Enforce the consistent use of double quotes + // https://eslint.style/rules/default/quotes "@stylistic/quotes": [ 1, "double", { "avoidEscape": true, "allowTemplateLiterals": true }, ], - "@stylistic/semi": 1, // Require semicolons instead of ASI - "@stylistic/space-before-function-paren": 1, // Enforce consistent spacing before `function` definition opening parenthesis + // Require semicolons instead of ASI + // https://eslint.style/rules/default/semi + "@stylistic/semi": 1, + // Enforce consistent spacing before `function` definition opening parenthesis + // https://eslint.style/rules/default/space-before-function-paren + "@stylistic/space-before-function-paren": 1, // Enforce consistent spacing after the `//` or `/*` in a comment + // https://eslint.style/rules/default/spaced-comment "@stylistic/spaced-comment": [ 1, "always", { "block": { "exceptions": ["*"] } }, ], - // typescript-eslint rules: https://typescript-eslint.io/rules/ - // Based off of: https://github.com/typescript-eslint/typescript-eslint/blob/v6.13.1/packages/eslint-plugin/src/configs/recommended.ts - "@typescript-eslint/ban-ts-comment": 1, // Disallow `@ts-` comments - "@typescript-eslint/ban-types": 1, // Disallow certain built-in types - "@typescript-eslint/no-array-constructor": 1, // Disallow generic `Array` constructors - "@typescript-eslint/no-duplicate-enum-values": 1, // Disallow duplicate enum member values - "@typescript-eslint/no-extra-non-null-assertion": 1, // Disallow extra non-null assertions - "@typescript-eslint/no-misused-new": 1, // Enforce valid definition of `new` and `constructor` - "@typescript-eslint/no-namespace": 1, // Disallow TypeScript namespaces - "@typescript-eslint/no-non-null-asserted-optional-chain": 1, // Disallow non-null assertions after an optional chain expression - "@typescript-eslint/no-this-alias": 1, // Disallow aliasing `this` - "@typescript-eslint/no-unnecessary-type-constraint": 1, // Disallow unnecessary constraints on generic types - "@typescript-eslint/no-unsafe-declaration-merging": 1, // Disallow unsafe declaration merging - "@typescript-eslint/no-var-requires": 1, // Disallow `require` statements except in import statements - "@typescript-eslint/prefer-as-const": 1, // Enforce the use of `as const` over literal type - "@typescript-eslint/triple-slash-reference": 1, // Disallow certain triple slash directives in favor of ES6-style import declarations + /** + * typescript-eslint rules: https://typescript-eslint.io/rules/ + * Based off of: https://github.com/typescript-eslint/typescript-eslint/blob/v6.13.1/packages/eslint-plugin/src/configs/recommended.ts + */ + // Disallow `@ts-` comments + // https://typescript-eslint.io/rules/ban-ts-comment + "@typescript-eslint/ban-ts-comment": 1, + // Disallow certain built-in types + // https://typescript-eslint.io/rules/ban-types + "@typescript-eslint/ban-types": 1, + // Disallow generic `Array` constructors + // https://typescript-eslint.io/rules/no-array-constructor + "@typescript-eslint/no-array-constructor": 1, + // Disallow duplicate enum member values + // https://typescript-eslint.io/rules/no-duplicate-enum-values + "@typescript-eslint/no-duplicate-enum-values": 1, + // Disallow extra non-null assertions + // https://typescript-eslint.io/rules/no-extra-non-null-assertion + "@typescript-eslint/no-extra-non-null-assertion": 1, + // Enforce valid definition of `new` and `constructor` + // https://typescript-eslint.io/rules/no-misused-new + "@typescript-eslint/no-misused-new": 1, + // Disallow TypeScript namespaces + // https://typescript-eslint.io/rules/no-namespace + "@typescript-eslint/no-namespace": 1, + // Disallow non-null assertions after an optional chain expression + // https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain + "@typescript-eslint/no-non-null-asserted-optional-chain": 1, + // Disallow aliasing `this` + // https://typescript-eslint.io/rules/no-this-alias + "@typescript-eslint/no-this-alias": 1, + // Disallow unnecessary constraints on generic types + // https://typescript-eslint.io/rules/no-unnecessary-type-constraint + "@typescript-eslint/no-unnecessary-type-constraint": 1, + // Disallow unsafe declaration merging + // https://typescript-eslint.io/rules/no-unsafe-declaration-merging + "@typescript-eslint/no-unsafe-declaration-merging": 1, + // Disallow `require` statements except in import statements + // https://typescript-eslint.io/rules/no-var-requires + "@typescript-eslint/no-var-requires": 1, + // Enforce the use of `as const` over literal type + // https://typescript-eslint.io/rules/prefer-as-const + "@typescript-eslint/prefer-as-const": 1, + // Disallow certain triple slash directives in favor of ES6-style import declarations + // https://typescript-eslint.io/rules/triple-slash-reference + "@typescript-eslint/triple-slash-reference": 1, - // Based off of: https://github.com/typescript-eslint/typescript-eslint/blob/v6.13.1/packages/eslint-plugin/src/configs/stylistic.ts - "@typescript-eslint/adjacent-overload-signatures": 1, // Require that function overload signatures be consecutive - "@typescript-eslint/array-type": 1, // Require consistently using `T[]` for arrays instead of `Array` - "@typescript-eslint/ban-tslint-comment": 1, // Disallow `// tslint:` comments - "@typescript-eslint/class-literal-property-style": 1, // Enforce that literals on classes are exposed in a consistent style - "@typescript-eslint/consistent-generic-constructors": 1, // Enforce specifying generic type arguments on type annotation or constructor name of a constructor call - "@typescript-eslint/consistent-indexed-object-style": 1, // Require the `Record` type instead of index signatures - "@typescript-eslint/consistent-type-assertions": 1, // Enforce consistent usage of type assertions - "@typescript-eslint/consistent-type-definitions": 1, // Enforce type definitions to consistently use `interface` instead of `type` - "@typescript-eslint/no-confusing-non-null-assertion": 1, // Disallow non-null assertion in locations that may be confusing - "@typescript-eslint/no-empty-interface": 1, // Disallow the declaration of empty interfaces - "@typescript-eslint/no-inferrable-types": 1, // Disallow explicit type declarations for variables or parameters initialized to a number, string, or boolean - "@typescript-eslint/prefer-for-of": 1, // Enforce the use of `for-of` loop over the standard `for` loop where possible - "@typescript-eslint/prefer-function-type": 1, // Enforce using function types instead of interfaces with call signatures - "@typescript-eslint/prefer-namespace-keyword": 1, // Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules + /** + * Based off of: https://github.com/typescript-eslint/typescript-eslint/blob/v6.13.1/packages/eslint-plugin/src/configs/stylistic.ts + */ + // Require that function overload signatures be consecutive + // https://typescript-eslint.io/rules/adjacent-overload-signatures + "@typescript-eslint/adjacent-overload-signatures": 1, + // Require consistently using `T[]` for arrays instead of `Array` + // https://typescript-eslint.io/rules/array-type + "@typescript-eslint/array-type": 1, + // Disallow `// tslint:` comments + // https://typescript-eslint.io/rules/ban-tslint-comment + "@typescript-eslint/ban-tslint-comment": 1, + // Enforce that literals on classes are exposed in a consistent style + // https://typescript-eslint.io/rules/class-literal-property-style + "@typescript-eslint/class-literal-property-style": 1, + // Enforce specifying generic type arguments on type annotation or constructor name of a constructor call + // https://typescript-eslint.io/rules/consistent-generic-constructors + "@typescript-eslint/consistent-generic-constructors": 1, + // Require the `Record` type instead of index signatures + // https://typescript-eslint.io/rules/consistent-indexed-object-style + "@typescript-eslint/consistent-indexed-object-style": 1, + // Enforce consistent usage of type assertions + // https://typescript-eslint.io/rules/consistent-type-assertions + "@typescript-eslint/consistent-type-assertions": 1, + // Enforce type definitions to consistently use `interface` instead of `type` + // https://typescript-eslint.io/rules/consistent-type-definitions + "@typescript-eslint/consistent-type-definitions": 1, + // Disallow non-null assertion in locations that may be confusing + // https://typescript-eslint.io/rules/no-confusing-non-null-assertion + "@typescript-eslint/no-confusing-non-null-assertion": 1, + // Disallow the declaration of empty interfaces + // https://typescript-eslint.io/rules/no-empty-interface + "@typescript-eslint/no-empty-interface": 1, + // Disallow explicit type declarations for variables or parameters initialized to a number, string, or boolean + // https://typescript-eslint.io/rules/no-inferrable-types + "@typescript-eslint/no-inferrable-types": 1, + // Enforce the use of `for-of` loop over the standard `for` loop where possible + // https://typescript-eslint.io/rules/prefer-for-of + "@typescript-eslint/prefer-for-of": 1, + // Enforce using function types instead of interfaces with call signatures + // https://typescript-eslint.io/rules/prefer-function-type + "@typescript-eslint/prefer-function-type": 1, + // Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules + // https://typescript-eslint.io/rules/prefer-namespace-keyword + "@typescript-eslint/prefer-namespace-keyword": 1, }, "overrides": [ {