UNPKG

@spscommerce/eslint-config-typescript

Version:
428 lines (427 loc) β€’ 23.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.typescript = void 0; // βœ… = recommended, πŸ”§ = fixable, πŸ’­ = requires type information exports.typescript = { /** * Require that member overloads be consecutive βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md */ "@typescript-eslint/adjacent-overload-signatures": "error", /** * Requires using either `T[]` or `Array<T>` for arrays πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/array-type.md */ "@typescript-eslint/array-type": ["error", { default: "array-simple" }], /** * Disallows awaiting a value that is not a Thenable βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/await-thenable.md */ "@typescript-eslint/await-thenable": "error", /** * Bans `@ts-<directive>` comments from being used or requires descriptions after directive βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/ban-ts-comment.md */ "@typescript-eslint/ban-ts-comment": "error", /** * Bans // tslint:<rule-flag> comments from being used πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/ban-tslint-comment.md */ "@typescript-eslint/ban-tslint-comment": "off", /** * Ensures that literals on classes are exposed in a consistent style πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/class-literal-property-style.md */ "@typescript-eslint/class-literal-property-style": ["error", "fields"], /** * Enforce or disallow the use of the record type πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md */ "@typescript-eslint/consistent-indexed-object-style": ["error", "record"], /** * Enforces consistent usage of type assertions * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-type-assertions.md */ "@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "as" }], /** * Consistent with type definition either `interface` or `type` πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-type-definitions.md */ "@typescript-eslint/consistent-type-definitions": ["error", "interface"], /** * Enforces consistent usage of type imports πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-type-imports.md */ "@typescript-eslint/consistent-type-imports": ["error", { prefer: "type-imports" }], /** * Require explicit return types on functions and class methods * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/explicit-function-return-type.md */ "@typescript-eslint/explicit-function-return-type": "error", /** * Require explicit accessibility modifiers on class properties and methods πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md */ "@typescript-eslint/explicit-member-accessibility": "off", /** * Require explicit return and argument types on exported * functions' and classes' public class methods βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md */ "@typescript-eslint/explicit-module-boundary-types": "error", /** * Require a specific member delimiter style for interfaces and type literals πŸ”§ * https://eslint.style/rules/default/member-delimiter-style#ts-member-delimiter-style */ "@stylistic/member-delimiter-style": "error", /** * Require a consistent member declaration order * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/member-ordering.md */ "@typescript-eslint/member-ordering": "error", /** * Enforces using a particular method signature syntax πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/method-signature-style.md */ "@typescript-eslint/method-signature-style": "error", /** * Enforces naming conventions for everything across a codebase πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/naming-convention.md */ "@typescript-eslint/naming-convention": "off", /** * Requires that `.toString()` is only called on objects * which provide useful information when stringified πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-base-to-string.md */ "@typescript-eslint/no-base-to-string": "error", /** * Disallow non-null assertion in locations that may be confusing πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md */ "@typescript-eslint/no-confusing-non-null-assertion": "error", /** * Requires expressions of type void to appear in statement position πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md */ "@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }], /** * Disallow the delete operator with computed key expressions πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-dynamic-delete.md */ "@typescript-eslint/no-dynamic-delete": "error", /** * Disallow the declaration of empty interfaces βœ… πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-empty-interface.md */ "@typescript-eslint/no-empty-interface": "error", /** * Disallow usage of the `object` type with an object literal * as a type annotation βœ… */ "@typescript-eslint/no-empty-object-type": "error", /** * Disallow usage of the `any` type βœ… πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-explicit-any.md */ "@typescript-eslint/no-explicit-any": "error", /** * Disallow extra non-null assertion βœ… πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-extra-non-null-assertion.md */ "@typescript-eslint/no-extra-non-null-assertion": "error", /** * Forbids the use of classes as namespaces * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-extraneous-class.md */ "@typescript-eslint/no-extraneous-class": "error", /** * Requires Promise-like values to be handled appropriately βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-floating-promises.md */ "@typescript-eslint/no-floating-promises": "error", /** * Disallow iterating over an array with a for-in loop βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-for-in-array.md */ "@typescript-eslint/no-for-in-array": "error", /** * Disallows explicit type declarations for variables or * parameters initialized to a number, string, or boolean βœ… πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-inferrable-types.md */ "@typescript-eslint/no-inferrable-types": "error", /** * Disallows usage of `void` type outside of generic or return types * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-invalid-void-type.md */ "@typescript-eslint/no-invalid-void-type": "warn", /** * Disallow the `void` operator except when used to discard a value πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md */ "@typescript-eslint/no-meaningless-void-operator": "error", /** * Enforce valid definition of `new` and `constructor` βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-misused-new.md */ "@typescript-eslint/no-misused-new": "error", /** * Avoid using promises in places not designed to handle them βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-misused-promises.md */ "@typescript-eslint/no-misused-promises": "error", /** * Disallow the use of custom TypeScript modules and namespaces βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-namespace.md */ "@typescript-eslint/no-namespace": "error", /** * Disallows using a non-null assertion in the left operand of the nullish coalescing operator * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-non-null-asserted-nullish-coalescing.md */ "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error", /** * Disallows using a non-null assertion after an optional chain expression βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md */ "@typescript-eslint/no-non-null-asserted-optional-chain": "error", /** * Disallows non-null assertions using the `!` postfix operator βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-non-null-assertion.md */ "@typescript-eslint/no-non-null-assertion": "error", /** * Disallows invocation of `require()` * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-require-imports.md */ "@typescript-eslint/no-require-imports": "error", /** * Disallow aliasing `this` βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-this-alias.md */ "@typescript-eslint/no-this-alias": "error", /** * Disallow the use of type aliases * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-type-alias.md */ "@typescript-eslint/no-type-alias": "off", /** * Flags unnecessary equality comparisons against boolean literals πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md */ "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", /** * Prevents conditionals where the type is always truthy or always falsy πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md */ "@typescript-eslint/no-unnecessary-condition": "error", /** * Warns when a namespace qualifier is unnecessary πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md */ "@typescript-eslint/no-unnecessary-qualifier": "warn", /** * Enforces that type arguments will not be used if not required πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md */ "@typescript-eslint/no-unnecessary-type-arguments": "error", /** * Warns if a type assertion does not change the type of an expression βœ… πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md */ "@typescript-eslint/no-unnecessary-type-assertion": "error", /** * Disallows unnecessary constraints on generic types πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md */ "@typescript-eslint/no-unnecessary-type-constraint": "error", /** * Disallows calling an function with an `any` type value πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unsafe-argument.md */ "@typescript-eslint/no-unsafe-argument": "error", /** * Disallows assigning `any` to variables and properties βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md */ "@typescript-eslint/no-unsafe-assignment": "error", /** * Disallows calling an `any` type value βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unsafe-call.md */ "@typescript-eslint/no-unsafe-call": "error", /** * Disallows member access on `any` typed variables βœ… πŸ’­ */ "@typescript-eslint/no-unsafe-function-type": "error", /** * Disallows member access on `any` typed variables βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md */ "@typescript-eslint/no-unsafe-member-access": "error", /** * Disallows returning any from a function βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unsafe-return.md */ "@typescript-eslint/no-unsafe-return": "error", /** * Disallows the use of require statements except in import statements βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-var-requires.md */ "@typescript-eslint/no-var-requires": "error", /** * Disallow using confusing built-in primitive class wrappers. */ "@typescript-eslint/no-wrapper-object-types": "error", /** * Prefers a non-null assertion over explicit type cast when possible πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/non-nullable-type-assertion-style.md * Disabled because it enforces use of postfix ! operator, which is banned by * @typescript-eslint/no-non-null-assertion (a recommended rule) */ "@typescript-eslint/non-nullable-type-assertion-style": "off", /** * Prefer usage of as const over literal type βœ… πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-as-const.md */ "@typescript-eslint/prefer-as-const": "error", /** * Prefer initializing each enums member value * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md */ "@typescript-eslint/prefer-enum-initializers": "error", /** * Prefer a β€˜for-of’ loop over a standard β€˜for’ loop if the * index is only used to access the array being iterated * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-for-of.md */ "@typescript-eslint/prefer-for-of": "error", /** * Use function types instead of interfaces with call signatures πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-function-type.md */ "@typescript-eslint/prefer-function-type": "error", /** * Enforce includes method over indexOf method πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-includes.md */ "@typescript-eslint/prefer-includes": "error", /** * Require that all enum members be literal values to * prevent unintended enum member name shadow issues * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md */ "@typescript-eslint/prefer-literal-enum-member": "error", /** * Require the use of the `namespace` keyword instead of the * `module` keyword to declare custom TypeScript modules βœ… πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md */ "@typescript-eslint/prefer-namespace-keyword": "error", /** * Enforce the usage of the nullish coalescing operator instead of logical chaining πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md */ "@typescript-eslint/prefer-nullish-coalescing": "error", /** * Prefer using concise optional chain expressions instead of chained logical ands * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-optional-chain.md */ "@typescript-eslint/prefer-optional-chain": "error", /** * Requires that private members are marked as `readonly` if * they're never modified outside of the constructor πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-readonly.md */ "@typescript-eslint/prefer-readonly": "error", /** * Requires that function parameters are typed as `readonly` * to prevent accidental mutation of inputs πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md */ "@typescript-eslint/prefer-readonly-parameter-types": "off", /** * Prefer using type parameter when calling `Array#reduce` instead of casting πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md */ "@typescript-eslint/prefer-reduce-type-parameter": "error", /** * Enforce that `RegExp#exec` is used instead of `String#match` * if no global flag is provided βœ… πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md */ "@typescript-eslint/prefer-regexp-exec": "error", /** * Enforce that `this` is used when only `this` type is returned πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-return-this-type.md */ "@typescript-eslint/prefer-return-this-type": "error", /** * Enforce the use of `String#startsWith` and `String#endsWith` instead * of other equivalent methods of checking substrings πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md */ "@typescript-eslint/prefer-string-starts-ends-with": "error", /** * Recommends using `@ts-expect-error` over `@ts-ignore` πŸ”§ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md */ "@typescript-eslint/prefer-ts-expect-error": "error", /** * Requires any function or method that returns a Promise to be marked async πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/promise-function-async.md */ "@typescript-eslint/promise-function-async": "off", /** * Requires `Array#sort` calls to always provide a `compareFunction` πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/require-array-sort-compare.md */ "@typescript-eslint/require-array-sort-compare": "error", /** * When adding two variables, operands must both be of type number or of type string βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/restrict-plus-operands.md */ "@typescript-eslint/restrict-plus-operands": "error", /** * Enforce template literal expressions to be of string type βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/restrict-template-expressions.md */ "@typescript-eslint/restrict-template-expressions": "error", /** * Restricts the types allowed in boolean expressions πŸ”§ πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md */ "@typescript-eslint/strict-boolean-expressions": "error", /** * Exhaustiveness checking in switch with union type πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md */ "@typescript-eslint/switch-exhaustiveness-check": "error", /** * Sets preference level for triple slash directives versus ES6-style import declarations βœ… * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/triple-slash-reference.md */ "@typescript-eslint/triple-slash-reference": "error", /** * Require consistent spacing around type annotations πŸ”§ * https://eslint.style/rules/default/type-annotation-spacing#ts-type-annotation-spacing */ "@stylistic/type-annotation-spacing": "error", /** * Requires type annotations to exist * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/typedef.md */ "@typescript-eslint/typedef": "off", /** * Enforces unbound methods are called with their expected scope βœ… πŸ’­ * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/unbound-method.md */ "@typescript-eslint/unbound-method": ["error", { ignoreStatic: true }], /** * Warns for any two overloads that could be unified into * one by using a union or an optional/rest parameter * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/unified-signatures.md */ "@typescript-eslint/unified-signatures": "warn", };