File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ import { convertPreferConst } from "./converters/prefer-const";
8686import { convertPreferForOf } from "./converters/prefer-for-of" ;
8787import { convertPreferFunctionOverMethod } from "./converters/prefer-function-over-method" ;
8888import { convertPreferObjectSpread } from "./converters/prefer-object-spread" ;
89+ import { convertPreferReadonly } from "./converters/prefer-readonly" ;
8990import { convertPreferTemplate } from "./converters/prefer-template" ;
9091import { convertPromiseFunctionAsync } from "./converters/promise-function-async" ;
9192import { convertRadix } from "./converters/radix" ;
@@ -194,6 +195,7 @@ export const converters = new Map([
194195 [ "one-variable-per-declaration" , convertOneVariablePerDeclaration ] ,
195196 [ "prefer-const" , convertPreferConst ] ,
196197 [ "prefer-function-over-method" , convertPreferFunctionOverMethod ] ,
198+ [ "prefer-readonly" , convertPreferReadonly ] ,
197199 [ "prefer-template" , convertPreferTemplate ] ,
198200 [ "space-before-function-paren" , convertSpaceBeforeFunctionParen ] ,
199201 [ "switch-default" , convertSwitchDefault ] ,
Original file line number Diff line number Diff line change 1+ import { RuleConverter } from "../converter" ;
2+
3+ export const convertPreferReadonly : RuleConverter = tslintRule => {
4+ return {
5+ rules : [
6+ {
7+ ...( tslintRule . ruleArguments . length !== 0 &&
8+ tslintRule . ruleArguments [ 0 ] === "only-inline-lambdas" && {
9+ ruleArguments : [ { onlyInlineLambdas : true } ] ,
10+ } ) ,
11+ ruleName : "prefer-readonly" ,
12+ } ,
13+ ] ,
14+ } ;
15+ } ;
Original file line number Diff line number Diff line change 1+ import { convertPreferReadonly } from "../prefer-readonly" ;
2+
3+ describe ( convertPreferReadonly , ( ) => {
4+ test ( "conversion without arguments" , ( ) => {
5+ const result = convertPreferReadonly ( {
6+ ruleArguments : [ ] ,
7+ } ) ;
8+
9+ expect ( result ) . toEqual ( {
10+ rules : [
11+ {
12+ ruleName : "prefer-readonly" ,
13+ } ,
14+ ] ,
15+ } ) ;
16+ } ) ;
17+
18+ test ( "conversion with an argument" , ( ) => {
19+ const result = convertPreferReadonly ( {
20+ ruleArguments : [ "only-inline-lambdas" ] ,
21+ } ) ;
22+
23+ expect ( result ) . toEqual ( {
24+ rules : [
25+ {
26+ ruleArguments : [ { onlyInlineLambdas : true } ] ,
27+ ruleName : "prefer-readonly" ,
28+ } ,
29+ ] ,
30+ } ) ;
31+ } ) ;
32+ } ) ;
You can’t perform that action at this time.
0 commit comments