@fimbul/mimir

0.24.0 • Public • Published

Mímir

Core rules, formatters and configurations of the Fimbullinter project.

npm version npm downloads Renovate enabled CircleCI Build status codecov Join the chat at https://gitter.im/fimbullinter/wotan

Make sure to also read the full documentation of all available modules.

Purpose

This library contains all core rules, formatters and configuration presets of the Fimbullinter project. As a typical user you don't need to explicitly install this package. It's already installed as a dependency of Wotan.

Rules

🔍 requires type information 🔎 works better with type information 🔧 fixable 🔩 configurable not enabled in recommended preset

Rule Description Difference to TSLint rule / Why you should use it
async-function-assignability 🔍 Diallows assinging a Promise-returning function to a void-returning type. No such rule in TSLint.
await-async-result 🔍 Warns about not using the result of a call to an async function inside async functions. TSLint's no-floating-promises requires you to specify a list of Promise names, it checks outside of async functions and only requires you to register the onrejected callback.
await-only-promise 🔍 🔧 Finds uses of await on non-Promise values. Also checks for await loops. Works for all PromiseLike and Thenable types out of the box without any configuration.
ban-dom-globals 🔍 Disallows uses of global variables like name or event. Using these variables is most likely not intended. There's an open PR to add a similar rule to TSLint.
delete-only-optional-property 🔍 Disallows delete of required properties. There's no similar TSLint rule.
generator-require-yield Requires at least one yield inside generator functions. There's no similar TSLint rule.
new-parens 🔧 Requires parentheses when invoking constructors. Performance!
no-case-declaration Disallows let, class and enum in case blocks. TSLint has no similar rule, ESLint has no-case-declarations which forbids function declarations as well.
no-debugger 🔧 Bans debugger; statements from your production code. Performance!
no-duplicate-case 🔎 Detects switch statements where multiple case clauses check for the same value. This implementation tries to infer the value instead of just comparing the source code.
no-duplicate-spread-property 🔍 Detects properties in object literals with object spread that are always overridden. TSLint has no such rule.
no-fallthrough 🔎 Prevents unintentional fallthough in switch statements from one case to another. Allows more comment variants such as fallthrough or fall through.
no-implicit-tostring 🔍 🔩 Disallows implicit conversion of non-string values to string.
no-invalid-assertion 🔍 Disallows asserting a literal type to a different literal type of the same widened type, e.g. 'foo' as 'bar'. TSLint has no similar rule.
no-misused-generics Detects generic type parameters that cannot be inferred from the functions parameters. It also detects generics that don't enforce any constraint between types. There's no similar TSLint rule.
no-nan-compare Disallows comparing with NaN, use isNaN(number) or Number.isNaN(number) instead. Performance!
no-object-spread-of-iterable 🔍 Disallows spreading iterable types into an object.
no-octal-escape 🔧 Disallows octal escape sequences in strings and template strings. No such rule in TSLint.
no-restricted-property-access 🔍 Disallows accessing properties via computed name that would not be accessible using a static name. TSLint has no similar rule.
no-return-await 🔧 Disallows unnecesary return await foo; when you can simply return foo; The same as TSLint's rule. I wrote both, but this one is faster.
no-unassigned-variable Detects variables that are not initialized and never assigned a value. There's no similar TSLint rule.
no-uninferred-type-parameter 🔍 Detects type parameters that are inferred as {} because the compiler cannot infer a type. Really checks every type parameter of function, method and constructor calls. Correctly handles type parameters from JSDoc comments. Recognises type parameter defaults on all merged declarations.
no-unreachable-code 🔎 Disallows statements that will never be executed. TSLint removed their no-unreachable rule in v4.0.0.
no-unsafe-finally Disallows control flow statements return, throw, break and continue inside the finally block of a try statement. Performance!
no-unstable-api-use 🔍 Disallows uses of deprecated or experimental APIs. This rule checks element accesses (foo[bar]), JSX elements, chained function calls (getFn()()) in addition to what TSLint's deprecation rule does and has more useful error reporting.
no-unused-expression 🔩 Disallows side-effect free expressions whose value is not used. This one is a bit stricter than TSLint's no-unused-expression and checks for loops in addition.
no-unused-label 🔧 Disallows labels that are never used. TSLint only has label-position which doesn't check for unused labels.
no-useless-assertion 🔍 🔧 Disallows type assertions that don't change the type or are not necessary in the first place. TSLint's no-unnecessary-type-assertion does not detect assertions needed to silence the compiler warning Variable ... is used before being assigned. The Wotan builtin rule also checks whether the assertion is necessary at all or the receiver accepts the original type.
no-useless-declare 🔧 Disallows the declare keyword on statements without runtime value, e.g. declare type T = any;. TSLint has no such rule.
no-useless-destructuring Detects array and object destructuring that doesn't assign to a variable. TSLint has no such rule.
no-useless-initializer 🔎 🔧 Disallows unnecessary initialization with undefined and useless destructuring defaults. TSLint's rule no-unnecessary-initializer doesn't fix all parameter initializers and gives false positives for destructuring.
no-useless-jump-label 🔧 Disallows continue label; and break label; where the label is not necessary. There's no similar TSLint rule.
no-useless-predicate 🔍 Detects redundant conditions that are either always true or always false. Combination of TSLint's strict-type-predicates, typeof-compare and parts of strict-boolean-expressions.
no-useless-spread 🔧 Disallows redundant array and object spread. There's no similar TSLint rule.
no-useless-strict 🔎 🔧 Disallows redundant 'use strict'; directives. TSLint had a rule to enforce 'use strict' everywhere.
no-useless-try-catch 🔧 Detects try statements or parts thereof that can be removed. There's no similar TSLint rule.
no-writeonly-property-read 🔍 Disallows read access to properties that only have a set accessor. There's no similar TSLint rule.
parameter-properties 🔧 🔩 Enforces or disallows the use of parameter properties. TSlint only has no-parameter-properties to disallow all parameter properties and has no autofixer.
prefer-const 🔧 🔩 Enforces the use of const for variables that are never reassigned. TSLint's prefer-const rule gives some false positives for merged declarations and variables used before being declared which results in a compiler or runtime error after fixing.
prefer-dot-notation 🔍 🔧 Enforces the use of obj.foo instead of obj['foo'] where possible. Similar to TSLint's no-string-literal rule, but more performant and more correct by avoiding compile errors after fixing.
prefer-for-of 🔍 Prefer for...of loops over regular for loops where possible. Avoids the false positives of TSLint's prefer-for-of rule.
prefer-namespace-keyword 🔧 Prefer namespace foo {} over module foo {} to avoid confusion with ECMAScript modules. Same as TSLint's no-internal-module.
prefer-number-methods 🔍 🔧 Prefer ES2015's Number.isNaN and Number.isFinite over the global isNaN and isFinite. No similar rule in TSLint.
prefer-object-spread 🔍 🔧 Prefer object spread over Object.assign for copying properties to a new object. Performance, better handling of parens in fixer and avoids false positives that would cause a compile error when fixed.
return-never-call 🔍 Enforces returning or throwing the result of a function of method call that returns never. TSLint has no similar rule.
syntaxcheck 🔍 Reports syntax errors as lint errors. Used to be part of the deprecated tslint --type-check
trailing-newline 🔧 Enforces a line break at the end of each file. Nothing fancy here :(
try-catch-return-await 🔍 🔧 Enforces the use of return await foo; inside try-catch in async functions where foo is a Promise-like value. TSLint has no similar rule.
type-assertion 🔧 🔩 Enforces a single type assertion style: "classic" <T>obj or "as" obj as T. TSLint has only no-angle-bracket-type-assertion which always enforces as and forgets to add parens when autofixing some cases.
typecheck 🔍 TypeScript's compile errors as lint errors. Like the deprecated tslint --type-check but formatted and can be disabled like any other rule.

Formatters

  • stylish
  • json

Configuration Presets

  • wotan:recommended contains recommended builtin rules. This configuration only adds new rules in major versions.
  • wotan:latest contains recommended builtin rules and is updated in minor versions. Be aware that this might cause your build to break.

License

Apache-2.0 © Klaus Meinhardt

Package Sidebar

Install

npm i @fimbul/mimir

Weekly Downloads

268

Version

0.24.0

License

Apache-2.0

Unpacked Size

452 kB

Total Files

168

Last publish

Collaborators

  • ajaff
  • harbard