1 | # Valtýr
|
2 |
|
3 | Wotan module to lint according to your existing `tslint.json` and `tslint:disable` comments.
|
4 |
|
5 | [![npm version](https://img.shields.io/npm/v/@fimbul/valtyr.svg)](https://www.npmjs.com/package/@fimbul/valtyr)
|
6 | [![npm downloads](https://img.shields.io/npm/dm/@fimbul/valtyr.svg)](https://www.npmjs.com/package/@fimbul/valtyr)
|
7 | [![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovateapp.com/)
|
8 | [![CircleCI](https://circleci.com/gh/fimbullinter/wotan/tree/master.svg?style=shield)](https://circleci.com/gh/fimbullinter/wotan/tree/master)
|
9 | [![Build status](https://ci.appveyor.com/api/projects/status/a28dpupxvjljibq3/branch/master?svg=true)](https://ci.appveyor.com/project/ajafff/wotan/branch/master)
|
10 | [![codecov](https://codecov.io/gh/fimbullinter/wotan/branch/master/graph/badge.svg)](https://codecov.io/gh/fimbullinter/wotan)
|
11 | [![Join the chat at https://gitter.im/fimbullinter/wotan](https://badges.gitter.im/fimbullinter/wotan.svg)](https://gitter.im/fimbullinter/wotan)
|
12 |
|
13 | Make sure to also read the [full documentation of all available modules](https://github.com/fimbullinter/wotan#readme).
|
14 |
|
15 | ## Purpose
|
16 |
|
17 | Drop-in replacement for TSLint. Uses your existing `tslint.json` files, loads TSLint rules and formatters and honors `tslint:disable` comments.
|
18 |
|
19 | ## Installation
|
20 |
|
21 | ```sh
|
22 | npm install --save-dev @fimbul/wotan @fimbul/valtyr
|
23 | # or
|
24 | yarn add -D @fimbul/wotan @fimbul/valtyr
|
25 | ```
|
26 |
|
27 | ## Usage
|
28 |
|
29 | ```sh
|
30 | wotan -m @fimbul/valtyr
|
31 | ```
|
32 |
|
33 | The `-m @fimbul/valtyr` argument enables this package. It searches `tslint.json` (or `tslint.yaml`) files for configuration like TSLint does. It loads TSLint core rules as well as custom rules with the same rules as TSLint. It uses TSLint formatters to format the result.
|
34 |
|
35 | There are only minor differences:
|
36 |
|
37 | * CLI arguments are still those of the Wotan executable
|
38 | * exception messages are a bit different
|
39 | * `stylish` formatter is used by default
|
40 | * files of external modules are always excluded while `*.d.ts` in your project are included by default
|
41 |
|
42 | ### Using Processors
|
43 |
|
44 | Because `tslint.json` has no field to configure processors, you need to configure them in a separate file.
|
45 | Create a file named `.fimbullinter.yaml`. If it already exists, simply add the new cofiguration under the `valtyr` key.
|
46 |
|
47 | The following example shows how to enable a processor for `.vue` files:
|
48 |
|
49 | ```yaml
|
50 | valtyr:
|
51 | overrides:
|
52 | - files: "*.vue"
|
53 | processor: "@fimbul/ve"
|
54 | ```
|
55 |
|
56 | Note that the configuration for `valtyr` can only contain `overrides`, `settings` and `processor`. Everything else is not supported and will result in an error.
|
57 |
|
58 | ## Why!?
|
59 |
|
60 | Why should you use Wotan to execute TSLint rules?
|
61 |
|
62 | * Allows you to use your existing configuration, rules and formatters without modification.
|
63 | * Avoids using two different lint tool during migration to Wotan.
|
64 | * Blazingly fast autofixing, especially when linting the whole project with the `-p` flag.
|
65 | * Smart handling of overlapping fixes avoids destroying your code.
|
66 | * Allows the use of builtin configurations and shareable configs as CLI argument for `-c`, e.g. `-c tslint:latest` or `-c tslint-config-airbnb`.
|
67 | * Debug output to diagnose crashes.
|
68 | * Configuration caching avoids unnecessary work when linting many directories with the same config.
|
69 | * Optimized line switch parser finds `tslint:disable` comments faster with less overhead, especially in big files.
|
70 | * Reports unused and redundant `tslint:disable` comments with `--report-useless-directives` CLI option.
|
71 | * [Processor support for TSLint rules](https://github.com/palantir/tslint/issues/2099)
|
72 | * Consistently excludes external files and JSON files from linting.
|
73 | * Supports project `references`.
|
74 | * Doesn't execute typed rules on unchecked JavaScript files.
|
75 |
|
76 | ## Caveats
|
77 |
|
78 | * Additional startup time by loading Wotan and TSLint.
|
79 | * Wrapping rules and formatters comes with additional runtime and memory overhead.
|
80 | * For most projects there will be no noticeable difference in performance, smaller projects usually take longer to lint while bigger ones get faster.
|
81 | * Minor differences in handling disable comments:
|
82 | * Disabling a previously disabled rule for a single line doesn't automatically enable the rule after that line.
|
83 | * Having a disable comment in a line that is affected by a singleline disable comment might work differently: `/* tslint:disable-line */ // tslint:disable`. Since this pattern doesn't make sense most cases this shouldn't be noticeable.
|
84 |
|
85 | ## Difference to [Heimdall](https://github.com/fimbullinter/wotan/blob/master/packages/heimdall/README.md)
|
86 |
|
87 | This package allows you to use your existing TSLint configuration.
|
88 | On the other hand you cannot use any of the builtin rules of Wotan or all those other useful configuration features like overrides, aliases, etc.
|
89 | If you want to lint with your existing TSLint config *and* your new Wotan config, you need to run Wotan twice, which adds a lot of overhead.
|
90 |
|
91 | Heimdall requires you to rewrite your linter configuration and switch to `.wotanrc.yaml` (or `.wotanrc.json` if you like that better).
|
92 | In return you can use Wotans fully optimized builtin rules as well as all the other cool features.
|
93 | Heimdall allows you to execute Wotan and TSLint rules in one single run.
|
94 |
|
95 | ## License
|
96 |
|
97 | Apache-2.0 © [Klaus Meinhardt](https://github.com/ajafff)
|