1 | # Bifröst
|
2 |
|
3 | Compatiblity layer for TSLint rules and formatters.
|
4 |
|
5 | [![npm version](https://img.shields.io/npm/v/@fimbul/bifrost.svg)](https://www.npmjs.com/package/@fimbul/bifrost)
|
6 | [![npm downloads](https://img.shields.io/npm/dm/@fimbul/bifrost.svg)](https://www.npmjs.com/package/@fimbul/bifrost)
|
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 | Allows TSLint rule authors to provide the same rules for Wotan without any refactoring.
|
18 | Although `@fimbul/heimdall` already allows users to use your rules and formatters in Wotan, they still need to remember to use `-m @fimbul/heimdall` when running Wotan.
|
19 | You can help these users by providing your rules in a format that Wotan understands without any plugin.
|
20 |
|
21 | It also provides the exact opposite functionality: using rules originally written for Fimbullinter (wotan) as TSLint rule.
|
22 |
|
23 | ## Installation
|
24 |
|
25 | ```sh
|
26 | npm install --save @fimbul/bifrost
|
27 | # or
|
28 | yarn add @fimbul/bifrost
|
29 | ```
|
30 |
|
31 | ## Using TSLint Rules and Formatters in Wotan
|
32 |
|
33 | ### Rules
|
34 |
|
35 | Given a TSLint rule `my-foo` in a file `myFooRule.ts`, you simply create a file `my-foo.ts` with the following content:
|
36 |
|
37 | ```ts
|
38 | import {wrapTslintRule} from '@fimbul/bifrost';
|
39 | import {Rule} from './myFooRule.ts';
|
40 |
|
41 | const Wrapped = wrapTslintRule(Rule, 'my-foo');
|
42 | export {Wrapped as Rule};
|
43 | ```
|
44 |
|
45 | If you want to use a different directory for your TSLint rules and their Wotan wrapper, you just need to adjust the paths in the above example.
|
46 |
|
47 | ### Formatters
|
48 |
|
49 | Given a TSLint formatter `my-foo` in a file `myFooFormatter.ts`, you simply create a file `my-foo.ts` with the following content:
|
50 |
|
51 | ```ts
|
52 | import {wrapTslintFormatter} from '@fimbul/bifrost';
|
53 | import {Formatter} from './myFooFormatter.ts';
|
54 |
|
55 | const Wrapped = wrapTslintFormatter(Formatter);
|
56 | export {Wrapped as Formatter};
|
57 | ```
|
58 |
|
59 | Note that findings with severity `suggestion` are reported as `warning` through TSLint formatters.
|
60 |
|
61 | ## Using Fimbullinter Rules in TSLint
|
62 |
|
63 | Given a Fimbullinter rule `my-foo` in a file `my-foo.ts`, you simply create a file `myFooRule.ts` with the following content:
|
64 |
|
65 | ```ts
|
66 | import {wrapRuleForTslint} from '@fimbul/bifrost';
|
67 | import {Rule} from './my-foo.ts';
|
68 |
|
69 | const Wrapped = wrapRuleForTslint(Rule);
|
70 | export {Wrapped as Rule};
|
71 | ```
|
72 |
|
73 | ## License
|
74 |
|
75 | Apache-2.0 © [Klaus Meinhardt](https://github.com/ajafff)
|