1.7.0 • Published 4 years ago
@cling/eslint-config v1.7.0
@cling/eslint-config
Rules
eslint
Possible Errors
These rules relate to possible syntax or logic errors in JavaScript code:
- enforce "for" loop update clause moving the counter in the right direction. (
for-direction) - enforce
returnstatements in getters (getter-return) - disallow using an async function as a Promise executor (
no-async-promise-executor) - disallow comparing against -0 (
no-compare-neg-zero) - disallow assignment operators in conditional expressions (
no-cond-assign) - disallow constant expressions in conditions (
no-constant-condition) - disallow control characters in regular expressions (
no-control-regex) - disallow the use of
debugger(no-debugger) - disallow duplicate arguments in
functiondefinitions (no-dupe-args) - disallow duplicate conditions in if-else-if chains (
no-dupe-else-if) - disallow duplicate keys in object literals (
no-dupe-keys) - disallow duplicate case labels (
no-duplicate-case) - disallow empty block statements (
no-empty) - disallow empty character classes in regular expressions (
no-empty-character-class) - disallow reassigning exceptions in
catchclauses (no-ex-assign) - disallow unnecessary boolean casts (
no-extra-boolean-cast) - disallow unnecessary semicolons (
no-extra-semi) - disallow reassigning
functiondeclarations (no-func-assign) - disallow assigning to imported bindings (
no-import-assign) - disallow variable or
functiondeclarations in nested blocks (no-inner-declarations) - disallow invalid regular expression strings in
RegExpconstructors (no-invalid-regexp) - disallow irregular whitespace (
no-irregular-whitespace) - disallow characters which are made with multiple code points in character class syntax (
no-misleading-character-class) - disallow calling global object properties as functions (
no-obj-calls) - disallow calling some
Object.prototypemethods directly on objects (no-prototype-builtins) - disallow multiple spaces in regular expressions (
no-regex-spaces) - disallow returning values from setters (
no-setter-return) - disallow sparse arrays (
no-sparse-arrays) - disallow confusing multiline expressions (
no-unexpected-multiline) - disallow unreachable code after
return,throw,continue, andbreakstatements (no-unreachable) - disallow control flow statements in
finallyblocks (no-unsafe-finally) - disallow negating the left operand of relational operators (
no-unsafe-negation) - require calls to
isNaN()when checking forNaN(use-isnan) - enforce comparing
typeofexpressions against valid strings (valid-typeof)
Best Practices
These rules relate to better ways of doing things to help you avoid problems:
- disallow lexical declarations in case clauses (
no-case-declarations) - disallow empty destructuring patterns (
no-empty-pattern) - disallow fallthrough of
casestatements (no-fallthrough) - disallow assignments to native objects or read-only global variables (
no-global-assign) - disallow octal literals (
no-octal) - disallow variable redeclaration (
no-redeclare) - disallow assignments where both sides are exactly the same (
no-self-assign) - disallow unused labels (
no-unused-labels) - disallow unnecessary
catchclauses (no-useless-catch) - disallow unnecessary escape characters (
no-useless-escape) - disallow
withstatements (no-with)
Strict Mode
These rules relate to strict mode directives:
- disallow deleting variables (
no-delete-var) - disallow identifiers from shadowing restricted names (
no-shadow-restricted-names) - disallow the use of undeclared variables unless mentioned in
/*global */comments (no-undef)
Stylistic Issues
These rules relate to style guidelines, and are therefore quite subjective:
- disallow mixed spaces and tabs for indentation (
no-mixed-spaces-and-tabs) - require
super()calls in constructors (constructor-super) - disallow reassigning class members (
no-class-assign) - disallow reassigning
constvariables (no-const-assign) - disallow duplicate class members (
no-dupe-class-members) - disallow
newoperators with theSymbolobject (no-new-symbol) - disallow
this/superbefore callingsuper()in constructors (no-this-before-super) - require generator functions to contain
yield(require-yield)
import
Static analysis
- Ensure imports point to a file/module that can be resolved. (
no-unresolved) - Ensure named imports correspond to a named export in the remote file. (
named) - Ensure a default export is present, given a default import. (
default) - Ensure imported namespaces contain dereferenced properties as they are dereferenced. (
namespace) - Restrict which files can be imported in a given folder (
no-restricted-paths) - Forbid import of modules using absolute paths (
no-absolute-path) - Forbid
require()calls with expressions (no-dynamic-require) - Forbid webpack loader syntax in imports (
no-webpack-loader-syntax) - Forbid a module from importing itself (
no-self-import) - Forbid a module from importing a module with a dependency path back to itself (
no-cycle) - Prevent unnecessary path segments in import and require statements (
no-useless-path-segments) - Prevent importing packages through relative paths (
no-relative-packages)
Helpful warnings
- Report any invalid exports, i.e. re-export of the same name (
export) - Report use of exported name as identifier of default export (
no-named-as-default) - Report use of exported name as property of default export (
no-named-as-default-member) - Report imported names marked with
@deprecateddocumentation tag (no-deprecated) - Forbid the use of extraneous packages (
no-extraneous-dependencies) - Forbid the use of mutable exports with
varorlet. (var) - Report modules without exports, or exports without matching import in another module (
no-unused-modules)
Module systems
- Report potentially ambiguous parse goal (
scriptvs.module) (script) - Report CommonJS
requirecalls andmodule.exportsorexports.*. (require) - Report AMD
requireanddefinecalls. (require) - Forbid imports with CommonJS exports (
no-import-module-exports)
Style guide
- Ensure all imports appear before other statements (
first) - Ensure all exports appear after other statements (
exports-last) - Report repeated import of the same module in multiple places (
no-duplicates) - Forbid namespace (a.k.a. "wildcard"
*) imports (no-namespace) - Ensure consistent use of file extension within the import path (
extensions) - Enforce a convention in module import order (
order) - Enforce a newline after import statements (
newline-after-import) - Prefer a default export if module exports a single name (
prefer-default-export) - Forbid unassigned imports (
no-unassigned-import) - Forbid named default exports (
no-named-default) - Forbid anonymous values as default exports (
no-anonymous-default-export) - Enforce a leading comment with the webpackChunkName for dynamic imports (
dynamic-import-chunkname)
unicorn
Various awesome ESLint rules
- Improve regexes by making them shorter, consistent, and safer. (
unicorn/better-regex) - Enforce a specific parameter name in catch clauses. (
unicorn/catch-error-name) - Use destructured variables over properties. (
unicorn/consistent-destructuring) - Move function definitions to the highest possible scope. (
unicorn/consistent-function-scoping) - Enforce no spaces between braces. (
unicorn/empty-brace-spaces) - Enforce passing a
messagevalue when creating a built-in error. (unicorn/error-message) - Require escape sequences to use uppercase values. (
unicorn/escape-case) - Add expiration conditions to TODO comments. (
unicorn/expiring-todo-comments) - Enforce explicitly comparing the
lengthorsizeproperty of a value. (unicorn/explicit-length-check) - Enforce a case style for filenames. (
unicorn/filename-case) - Enforce specific import styles per module. (
unicorn/import-style) - Enforce the use of
newfor all builtins, exceptString,Number,Boolean,SymbolandBigInt. (unicorn/new-for-builtins) - Enforce specifying rules to disable in
eslint-disablecomments. (unicorn/no-abusive-eslint-disable) - Prevent passing a function reference directly to iterator methods. (
unicorn/no-array-callback-reference) - Disallow using the
thisargument in array methods. (unicorn/no-array-method-this-argument) - Enforce combining multiple
Array#push()into one call. (unicorn/no-array-push-push) - Do not use leading/trailing space between
console.logparameters. (unicorn/no-console-spaces) - Do not use
document.cookiedirectly. (unicorn/no-document-cookie) - Do not use a
forloop that can be replaced with afor-ofloop. (unicorn/no-for-loop) - Enforce the use of Unicode escapes instead of hexadecimal escapes. (
unicorn/no-hex-escape) - Require
Array.isArray()instead ofinstanceof Array. (unicorn/no-instanceof-array) - Disallow
ifstatements as the only statement inifblocks withoutelse. (unicorn/no-lonely-if) - Disallow nested ternary expressions. (
unicorn/no-nested-ternary) - Disallow
new Array(). (unicorn/no-new-array) - Enforce the use of
Buffer.from()andBuffer.alloc()instead of the deprecatednew Buffer(). (unicorn/no-new-buffer) - Disallow the use of objects as default parameters. (
unicorn/no-object-as-default-parameter) - Disallow
process.exit(). (unicorn/no-process-exit) - Forbid classes that only have static members. (
unicorn/no-static-only-class) - Disallow assigning
thisto a variable. (unicorn/no-this-assignment) - Disallow unreadable array destructuring. (
unicorn/no-unreadable-array-destructuring) - Disallow useless
undefined. (unicorn/no-useless-undefined) - Disallow number literals with zero fractions or dangling dots. (
unicorn/no-zero-fractions) - Enforce proper case for numeric literals. (
unicorn/number-literal-case) - Enforce the style of numeric separators by correctly grouping digits. (
unicorn/numeric-separators-style) - Prefer
.addEventListener()and.removeEventListener()overon-functions. (unicorn/prefer-add-event-listener) - Prefer
.find(…)over the first element from.filter(…). (unicorn/prefer-array-find) - Prefer
Array#flat()over legacy techniques to flatten arrays. (unicorn/prefer-array-flat) - Prefer
.flatMap(…)over.map(…).flat(). (unicorn/prefer-array-flat-map) - Prefer
Array#indexOf()overArray#findIndex()when looking for the index of an item. (unicorn/prefer-array-index-of) - Prefer
.some(…)over.filter(…).lengthcheck and.find(…). (unicorn/prefer-array-some) - Prefer
Date.now()to get the number of milliseconds since the Unix Epoch. (unicorn/prefer-date-now) - Prefer default parameters over reassignment. (
unicorn/prefer-default-parameters) - Prefer
Node#append()overNode#appendChild(). (unicorn/prefer-dom-node-append) - Prefer using
.dataseton DOM elements over.setAttribute(…). (unicorn/prefer-dom-node-dataset) - Prefer
childNode.remove()overparentNode.removeChild(childNode). (unicorn/prefer-dom-node-remove) - Prefer
.textContentover.innerText. (unicorn/prefer-dom-node-text-content) - Prefer
.includes()over.indexOf()andArray#some()when checking for existence or non-existence. (unicorn/prefer-includes) - Prefer
KeyboardEvent#keyoverKeyboardEvent#keyCode. (unicorn/prefer-keyboard-event-key) - Enforce the use of
Math.truncinstead of bitwise operators. (unicorn/prefer-math-trunc) - Prefer
.before()over.insertBefore(),.replaceWith()over.replaceChild(), prefer one of.before(),.after(),.append()or.prepend()overinsertAdjacentText()andinsertAdjacentElement(). (unicorn/prefer-modern-dom-apis) - Prefer JavaScript modules (ESM) over CommonJS. (
unicorn/prefer-module) - Prefer negative index over
.length - indexfor{String,Array,TypedArray}#slice(),Array#splice()andArray#at(). (unicorn/prefer-negative-index) - Prefer using the
node:protocol when importing Node.js builtin modules. (unicorn/prefer-node-protocol) - Prefer
Numberstatic properties over global ones. (unicorn/prefer-number-properties) - Prefer omitting the
catchbinding parameter. (unicorn/prefer-optional-catch-binding) - Prefer borrowing methods from the prototype instead of the instance. (
unicorn/prefer-prototype-methods) - Prefer
.querySelector()over.getElementById(),.querySelectorAll()over.getElementsByClassName()and.getElementsByTagName(). (unicorn/prefer-query-selector) - Prefer
Reflect.apply()overFunction#apply(). (unicorn/prefer-reflect-apply) - Prefer
RegExp#test()overString#match()andRegExp#exec(). (unicorn/prefer-regexp-test) - Prefer
Set#has()overArray#includes()when checking for existence or non-existence. (unicorn/prefer-set-has) - Prefer the spread operator over
Array.from(…),Array#concat(…)andArray#slice(). (unicorn/prefer-spread) - Prefer
String#slice()overString#substr()andString#substring(). (unicorn/prefer-string-slice) - Prefer
String#startsWith()&String#endsWith()overRegExp#test(). (unicorn/prefer-string-starts-ends-with) - Prefer
String#trimStart()/String#trimEnd()overString#trimLeft()/String#trimRight(). (unicorn/prefer-string-trim-start-end) - Prefer
switchover multipleelse-if. (unicorn/prefer-switch) - Prefer ternary expressions over simple
if-elsestatements. (unicorn/prefer-ternary) - Enforce throwing
TypeErrorin type checking conditions. (unicorn/prefer-type-error) - Prevent abbreviations. (
unicorn/prevent-abbreviations) - Enforce using the separator argument with
Array#join(). (unicorn/require-array-join-separator) - Enforce using the digits argument with
Number#toFixed(). (unicorn/require-number-to-fixed-digits-argument) - Enforce using the
targetOriginargument withwindow.postMessage(). (unicorn/require-post-message-target-origin) - Require
newwhen throwing an error. (unicorn/throw-new-error)
@ridedott/eslint-plugin
Comment rules
- Single line comments should not be in a block comment. (
@ridedott/no-single-line-comment-block) - There should not be template literals without expressions. (
@ridedott/no-single-line-comment-block)
eslint-plugin-jest
- Enforce assertion to be made in a test body (
expect-expect) - Enforce lowercase test names (
lowercase-name) - Disallow commented out tests (
no-commented-out-tests) - Prevent calling expect conditionally (
no-conditional-expect) - Disallow use of deprecated functions (
no-deprecated-functions) - Disallow disabled tests (
no-disabled-tests) - Avoid using a callback in asynchronous tests and hooks (
no-done-callback) - Disallow using exports in files containing tests (
no-export) - Disallow focused tests (
no-focused-tests) - Disallow string interpolation inside snapshots (
no-interpolation-in-snapshots) - Disallow Jasmine globals (
no-jasmine-globals) - Disallow importing Jest (
no-jest-import) - Disallow manually importing from mocks (
no-mocks-import) - Disallow using expect outside of it or test blocks (
no-standalone-expect) - Suggest using toBeCalledWith() or toHaveBeenCalledWith() (
prefer-called-with) - Suggest using toStrictEqual() (
prefer-strict-equal) - Require a message for toThrow() (
require-to-throw-message) - Require test cases and hooks to be inside a describe block (
require-top-level-describe) - Enforce valid describe() callback (
valid-describe) - Enforce valid expect() usage (
valid-expect) - Enforce having return statement when testing with promises (
valid-expect-in-promise)
typescript-eslint
Supported Rules
- Require that member overloads be consecutive (
@typescript-eslint/adjacent-overload-signatures) - Disallows awaiting a value that is not a Thenable (
@typescript-eslint/await-thenable) - Bans @ts- comments from being used or requires descriptions after directive (
@typescript-eslint/ban-ts-comment) - Bans
// tslint:<rule-flag>comments from being used (@typescript-eslint/ban-tslint-comment) - Bans specific types from being used (
@typescript-eslint/ban-types) - Ensures that literals on classes are exposed in a consistent style (
@typescript-eslint/class-literal-property-style) - Enforce or disallow the use of the record type (
@typescript-eslint/consistent-indexed-object-style) - Consistent with type definition either interface or type (
@typescript-eslint/consistent-type-definitions) - Require explicit return and argument types on exported functions' and classes' public class methods (
@typescript-eslint/explicit-module-boundary-types) - Require a specific member delimiter style for interfaces and type literals (
@typescript-eslint/member-delimiter-style) - Enforces using a particular method signature syntax. (
@typescript-eslint/method-signature-style) - Enforces naming conventions for everything across a codebase 💭(
@typescript-eslint/naming-convention) - Requires that .toString() is only called on objects which provide useful information when stringified 💭(
@typescript-eslint/no-base-to-string) - Disallow non-null assertion in locations that may be confusing (
@typescript-eslint/no-confusing-non-null-assertion) - Requires expressions of type void to appear in statement position 💭(
@typescript-eslint/no-confusing-void-expression) - Disallow the delete operator with computed key expressions (
@typescript-eslint/no-dynamic-delete) - Disallow the declaration of empty interfaces (
@typescript-eslint/no-empty-interface) - Disallow usage of the any type (
@typescript-eslint/no-explicit-any) - Disallow extra non-null assertion (
@typescript-eslint/no-extra-non-null-assertion) - Requires Promise-like values to be handled appropriately (
@typescript-eslint/no-floating-promises) - Disallow iterating over an array with a for-in loop (
@typescript-eslint/no-for-in-array) - Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean (
@typescript-eslint/no-inferrable-types) - Enforce valid definition of new and constructor (
@typescript-eslint/no-misused-new) - Avoid using promises in places not designed to handle them (
@typescript-eslint/no-misused-promises) - Disallow the use of custom TypeScript modules and namespaces (
@typescript-eslint/no-namespace) - Disallows using a non-null assertion after an optional chain expression (
@typescript-eslint/no-non-null-asserted-optional-chain) - Disallow the use of parameter properties in class constructors (
@typescript-eslint/no-parameter-properties) - Disallows invocation of require() (
@typescript-eslint/no-require-imports) - Disallow aliasing this (
@typescript-eslint/no-this-alias) - Warns when a namespace qualifier is unnecessary 💭(
@typescript-eslint/no-unnecessary-qualifier) - Enforces that type arguments will not be used if not required 💭(
@typescript-eslint/no-unnecessary-type-arguments) - Warns if a type assertion does not change the type of an expression ✅ 🔧 💭(
@typescript-eslint/no-unnecessary-type-assertion) - Disallows unnecessary constraints on generic types (
@typescript-eslint/no-unnecessary-type-constraint) - Disallows calling an function with an any type value 💭(
@typescript-eslint/no-unsafe-argument) - Disallows assigning any to variables and properties (
@typescript-eslint/no-unsafe-assignment) - Disallows calling an any type value (
@typescript-eslint/no-unsafe-call) - Disallows member access on any typed variables (
@typescript-eslint/no-unsafe-member-access) - Disallows returning any from a function (
@typescript-eslint/no-unsafe-return) - Disallows the use of require statements except in import statements (
@typescript-eslint/no-var-requires) - Prefers a non-null assertion over explicit type cast when possible 💭(
@typescript-eslint/non-nullable-type-assertion-style) - Prefer usage of as const over literal type (
@typescript-eslint/prefer-as-const) - Prefer initializing each enums member value (
@typescript-eslint/prefer-enum-initializers) - Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated (
@typescript-eslint/prefer-for-of) - Use function types instead of interfaces with call signatures (
@typescript-eslint/prefer-function-type) - Enforce includes method over indexOf method 💭(
@typescript-eslint/prefer-includes) - Require that all enum members be literal values to prevent unintended enum member name shadow issues (
@typescript-eslint/prefer-literal-enum-member) - Require the use of the namespace keyword instead of the module keyword to declare custom TypeScript modules (
@typescript-eslint/prefer-namespace-keyword) - Enforce the usage of the nullish coalescing operator instead of logical chaining 💭(
@typescript-eslint/prefer-nullish-coalescing) - Prefer using concise optional chain expressions instead of chained logical ands (
@typescript-eslint/prefer-optional-chain) - Prefer using type parameter when calling Array#reduce instead of casting 💭(
@typescript-eslint/prefer-reduce-type-parameter) - Enforce that RegExp#exec is used instead of String#match if no global flag is provided ✅ 🔧 💭(
@typescript-eslint/prefer-regexp-exec) - Enforce the use of String#startsWith and String#endsWith instead of other equivalent methods of checking substrings 💭(
@typescript-eslint/prefer-string-starts-ends-with) - Recommends using @ts-expect-error over @ts-ignore (
@typescript-eslint/prefer-ts-expect-error) - Requires any function or method that returns a Promise to be marked async 💭(
@typescript-eslint/promise-function-async) - Requires Array#sort calls to always provide a compareFunction 💭(
@typescript-eslint/require-array-sort-compare) - When adding two variables, operands must both be of type number or of type string (
@typescript-eslint/restrict-plus-operands) - Enforce template literal expressions to be of string type (
@typescript-eslint/restrict-template-expressions) - Enforces that members of a type union/intersection are sorted alphabetically (
@typescript-eslint/sort-type-union-intersection-members) - Restricts the types allowed in boolean expressions 💭(
@typescript-eslint/strict-boolean-expressions) - Exhaustiveness checking in switch with union type 💭(
@typescript-eslint/switch-exhaustiveness-check) - Sets preference level for triple slash directives versus ES6-style import declarations (
@typescript-eslint/triple-slash-reference) - Require consistent spacing around type annotations (
@typescript-eslint/type-annotation-spacing) - Requires type annotations to exist (
@typescript-eslint/typedef) - Enforces unbound methods are called with their expected scope (
@typescript-eslint/unbound-method) - Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter (
@typescript-eslint/unified-signatures) // ## Extension Rules - Enforce consistent brace style for blocks (
@typescript-eslint/brace-style) - Enforces consistent spacing before and after commas (
@typescript-eslint/comma-spacing) - Enforce default parameters to be last (
@typescript-eslint/default-param-last) - enforce dot notation whenever possible 💭(
@typescript-eslint/dot-notation) - Require or disallow spacing between function identifiers and their invocations (
@typescript-eslint/func-call-spacing) - Enforce consistent indentation (
@typescript-eslint/indent) - require or disallow initialization in variable declarations (
@typescript-eslint/init-declarations) - Enforce consistent spacing before and after keywords (
@typescript-eslint/keyword-spacing) - Require or disallow an empty line between class members (
@typescript-eslint/lines-between-class-members) - Disallow generic Array constructors (
@typescript-eslint/no-array-constructor) - Disallow duplicate class members (
@typescript-eslint/no-dupe-class-members) - Disallow duplicate imports (
@typescript-eslint/no-duplicate-imports) - Disallow empty functions (
@typescript-eslint/no-empty-function) - Disallow unnecessary semicolons (
@typescript-eslint/no-extra-semi) - Disallow the use of eval()-like methods (
@typescript-eslint/no-implied-eval) - Disallow this keywords outside of classes or class-like objects (
@typescript-eslint/no-invalid-this) - Disallow function declarations that contain unsafe references inside loop statements (
@typescript-eslint/no-loop-func) - Disallow literal numbers that lose precision (
@typescript-eslint/no-loss-of-precision) - Disallow magic numbers (
@typescript-eslint/no-magic-numbers) - Disallow variable redeclaration (
@typescript-eslint/no-redeclare) - Disallow variable declarations from shadowing variables declared in the outer scope (
@typescript-eslint/no-shadow) - Disallow throwing literals as exceptions 💭(
@typescript-eslint/no-throw-literal) - Disallow unused expressions (
@typescript-eslint/no-unused-expressions) - Disallow unused variables (
@typescript-eslint/no-unused-vars) - Disallow the use of variables before they are defined (
@typescript-eslint/no-use-before-define) - Disallow unnecessary constructors (
@typescript-eslint/no-useless-constructor)
Extension Rules
In some cases, ESLint provides a rule itself, but it doesn't support TypeScript syntax; either it crashes, or it ignores the syntax, or it falsely reports against it. In these cases, we create what we call an extension rule; a rule within our plugin that has the same functionality, but also supports TypeScript.
- Enforce consistent spacing inside braces (
@typescript-eslint/object-curly-spacing) - Disallow async functions which have no await expression (
@typescript-eslint/require-await) - Enforces consistent returning of awaited values (
@typescript-eslint/return-await) - Require or disallow semicolons instead of ASI (
@typescript-eslint/semi) - This rule is aimed at ensuring there are spaces around infix operators. (
@typescript-eslint/space-infix-ops)