File tree Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ import { convertNoShadowedVariable } from "./converters/no-shadowed-variable";
7676import { convertNoSparseArrays } from "./converters/no-sparse-arrays" ;
7777import { convertNoStringLiteral } from "./converters/no-string-literal" ;
7878import { convertNoStringThrow } from "./converters/no-string-throw" ;
79+ import { convertNoSubmoduleImports } from "./converters/no-submodule-imports" ;
7980import { convertNoSwitchCaseFallThrough } from "./converters/no-switch-case-fall-through" ;
8081import { convertNoThisAssignment } from "./converters/no-this-assignment" ;
8182import { convertNoTrailingWhitespace } from "./converters/no-trailing-whitespace" ;
@@ -200,6 +201,7 @@ export const converters = new Map([
200201 [ "no-sparse-arrays" , convertNoSparseArrays ] ,
201202 [ "no-string-literal" , convertNoStringLiteral ] ,
202203 [ "no-string-throw" , convertNoStringThrow ] ,
204+ [ "no-submodule-imports" , convertNoSubmoduleImports ] ,
203205 [ "no-switch-case-fall-through" , convertNoSwitchCaseFallThrough ] ,
204206 [ "no-this-assignment" , convertNoThisAssignment ] ,
205207 [ "no-trailing-whitespace" , convertNoTrailingWhitespace ] ,
Original file line number Diff line number Diff line change 1+ import { RuleConverter } from "../converter" ;
2+
3+ export const convertNoSubmoduleImports : RuleConverter = tslintRule => {
4+ const ruleArguments : string [ ] = [ ] ;
5+
6+ if (
7+ ! (
8+ tslintRule . ruleArguments . length === 0 ||
9+ tslintRule . ruleArguments [ 0 ] === false ||
10+ tslintRule . ruleArguments . length < 2
11+ )
12+ ) {
13+ ruleArguments . push (
14+ ...tslintRule . ruleArguments . map ( ruleArg => {
15+ if ( typeof ruleArg === "string" ) {
16+ return ruleArg . concat ( "/*" ) ;
17+ }
18+ return ruleArg ;
19+ } ) ,
20+ ) ;
21+ }
22+
23+ return {
24+ rules : [
25+ {
26+ ruleName : "import/no-internal-modules" ,
27+ ...{
28+ ruleArguments :
29+ ruleArguments . length > 0 ? [ { allow : ruleArguments } ] : undefined ,
30+ } ,
31+ } ,
32+ ] ,
33+ plugins : [ "eslint-plugin-import" ] ,
34+ } ;
35+ } ;
Original file line number Diff line number Diff line change 1+ import { convertNoSubmoduleImports } from "../no-submodule-imports" ;
2+
3+ describe ( convertNoSubmoduleImports , ( ) => {
4+ test ( "conversion without arguments" , ( ) => {
5+ const result = convertNoSubmoduleImports ( {
6+ ruleArguments : [ ] ,
7+ } ) ;
8+
9+ expect ( result ) . toEqual ( {
10+ rules : [
11+ {
12+ ruleName : "import/no-internal-modules" ,
13+ } ,
14+ ] ,
15+ plugins : [ "eslint-plugin-import" ] ,
16+ } ) ;
17+ } ) ;
18+
19+ test ( "conversion with arguments" , ( ) => {
20+ const result = convertNoSubmoduleImports ( {
21+ ruleArguments : [ true , "rxjs" ] ,
22+ } ) ;
23+
24+ expect ( result ) . toEqual ( {
25+ rules : [
26+ {
27+ ruleName : "import/no-internal-modules" ,
28+ ruleArguments : [ { allow : [ true , "rxjs/*" ] } ] ,
29+ } ,
30+ ] ,
31+ plugins : [ "eslint-plugin-import" ] ,
32+ } ) ;
33+ } ) ;
34+ } ) ;
You can’t perform that action at this time.
0 commit comments