Heimdall
Wotan module to use TSLint rules and formatters.
Make sure to also read the full documentation of all available modules.
Purpose
Enable the use of TSLint rules and formatters.
Installation
npm install --save-dev @fimbul/wotan @fimbul/heimdall
yarn add -D @fimbul/wotan @fimbul/heimdall
Using TSLint Formatters
wotan -m @fimbul/heimdall -f code-frame
-f code-frame
refers to the TSLint core CodeFrameFormatter.
The -m @fimbul/heimdall
argument enables a hook that loads TSLint formatters if no Wotan formatter is found.
That means you cannot use a TSLint formatter when a builtin Wotan formatter with the same name exists.
Note that findings with severity suggestion
are reported as warning
through TSLint formatters.
Using TSLint Rules
To enable Heimdall, add the -m @fimbul/heimdall
argument when running wotan
from CLI.
wotan -m @fimbul/heimdall
Specifying TSLint rules in your .wotanrc.yaml
works as follows. Note that you need to specify a prefix for TSLint rules (tslint/
in this example)
---
rulesDirectories:
tslint: .
tcc: ./node_modules/tslint-consistent-codestyle/rules
rules:
no-unused-expression: error
tslint/no-unused-expression: error
tslint/semicolon:
options: always
tcc/no-unused: error
Since all paths in rulesDirectories
are treated as relative paths (i.e. not resolved using node module resolution), you need to provide the relative paths for node modules as shown above.
As an alternative you can resolve the module using require.resolve
. For this to work, you need to rename .wotanrc.yaml
to .wotanrc.js
and change the content as follows:
const path = require('path');
module.exports = {
rulesDirectories: {
tslint: '.'
tcc: path.dirname(require.resolve('tslint-consistent-codestyle'))
}
rules: {
'no-unused-expression': 'error'
'tslint/no-unused-expression': 'error'
'tslint/semicolon': {
options: 'always'
}
'tcc/no-unused': 'error'
}
}
Enable this Plugin Module in Configuration
If you want to always use this plugin module and don't want to add -m @fimbul/heimdall
to the CLI every time, you can add it to your .fimbullinter.yaml
file which contains default values for CLI arguments.
Use wotan save -m @fimbul/heimdall
to create of update .fimbullinter.yaml
. From now on Heimdall will always be loaded unless you override it with another -m
argument.
Why!?
Why should you use Wotan to execute TSLint rules?
- Allows you to reuse existing rules and rules packages without any modification.
- Enables the use of processors, to lint for example Vue Single File Components (see
@fimbul/ve
), that are currently not supported by TSLint. - Configuration goodness provided by Wotan:
- Overrides to change the config by matching glob patterns.
- You can use a rule with the same name from different packages. Because you need to specify a prefix for every package, rules won't get overidden by other packages.
- Aliases
- JSON5 support
- Blazingly fast autofixing, especially when linting the whole project with the
-p
flag. - Smart handling of overlapping fixes avoids destroying your code.
License
Apache-2.0 © Klaus Meinhardt
v0.24.0
:tada: This release contains two major features: caching and code fixes in the LanguageService plugin.
:warning: Breaking Changes:
The changes in the LanguageService plugin require that you update the @fimbul/mithotyn
dependency and the fimbullinter.vscode-plugin
VSCode plugin if you were using one of them.
Features:
- new rule:
no-object-spread-of-iterable
warns about spreading an array into an object - new rule:
no-implicit-tostring
warns about implicit string coercion of certain types - new CLI option:
--cache
enables caching for fast incremental linting. Read more about caching - the LanguageService plugin uses caching to speed up linting in your editor
- the LanguageService plugin now provides fixes for fixable findings