Skip to content

Commit

Permalink
feat(tslint-rules): adapt folder structure rules for projects
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed May 18, 2020
1 parent 44efffe commit 187a485
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
"from": "lodash.*"
},
{
"import": "^(?!(range|uniq|memoize|once|groupBy|countBy|flatten|isEqual|intersection|omit)$).*",
"import": "^(?!(range|uniq|memoize|once|groupBy|countBy|flatten|isEqual|intersection|omit|pick)$).*",
"from": "lodash.*"
},
{
Expand Down Expand Up @@ -368,6 +368,11 @@
"filePattern": "^((?!(module|spec)\\.ts).)*$",
"message": "Imports from (other) extensions are not allowed here."
},
{
"from": ".*/projects/.*",
"filePattern": "^((?!(module|spec)\\.ts).)*$",
"message": "Imports from (other) projects are not allowed here."
},
{
"from": ".*/pages/[a-z][a-z0-9-]+/.*",
"filePattern": "^((?!(cypress|\\.module\\.ts$)).)*$",
Expand All @@ -376,8 +381,8 @@
{
"import": "^SharedModule$",
"from": "\\..*",
"filePattern": "^(?!.+(page|extensions/[a-z][a-z0-9-]+/[a-z][a-z0-9-]+\\.module)).+\\.module\\.ts$",
"message": "SharedModule must only be imported in page or extension modules."
"filePattern": "^(?!.+(page|extensions/[a-z][a-z0-9-]+/[a-z][a-z0-9-]+\\.module|projects/[a-z][a-z0-9-]+/src/app/[a-z][a-z0-9-]+\\.module)).+\\.module\\.ts$",
"message": "SharedModule must only be imported in page, extension or project modules."
},
{
"import": "pluck",
Expand Down Expand Up @@ -509,19 +514,19 @@
"^.*/src/app/core/routing/([a-z0-9-]+)/\\1\\.route\\.ts",
"^.*/src/app/core/routing/([a-z0-9-]+)/\\1\\-route\\.pipe\\.ts",
// extra artifacts
"^.*/src/app/(core|extensions/[a-z][a-z0-9-]+)/(service)s/([a-z][a-z0-9-]+)/\\3(\\-[a-z0-9-]+|)\\.\\2[a-z0-9-\\.]*\\.ts",
"^.*/src/app/(core|extensions/[a-z][a-z0-9-]+)/(interceptor|guard|directive|pipe)s/[a-z][a-z0-9-]+.\\2\\.ts",
"^.*(/src/app/core|/src/app/extensions/[a-z][a-z0-9-]+|projects/[a-z][a-z0-9-]+/src/app)/(service)s/([a-z][a-z0-9-]+)/\\3(\\-[a-z0-9-]+|)\\.\\2[a-z0-9-\\.]*\\.ts",
"^.*(/src/app/core|/src/app/extensions/[a-z][a-z0-9-]+|projects/[a-z][a-z0-9-]+/src/app)/(interceptor|guard|directive|pipe)s/[a-z][a-z0-9-]+.\\2\\.ts",
// models
"^.*/src/app/(core|extensions/[a-z][a-z0-9-]+)/models/([a-z][a-z0-9-]+)/\\2\\.(pipe|helper|interface|mapper|types)\\.ts$",
"^.*(/src/app/core|/src/app/extensions/[a-z][a-z0-9-]+|projects/[a-z][a-z0-9-]+/src/app)/models/([a-z][a-z0-9-]+)/\\2\\.(pipe|helper|interface|mapper|types)\\.ts$",
// cms
"^.*/src/app/shared/cms/sfe-adapter/.*\\.ts$",
// facades
"^.*/src/app/(core|extensions/[a-z][a-z0-9-]+)/facades/(index|[a-z][a-z0-9-]+\\.facade)\\.ts$",
"^.*(/src/app/core|/src/app/extensions/[a-z][a-z0-9-]+|projects/[a-z][a-z0-9-]+/src/app)/facades/(index|[a-z][a-z0-9-]+\\.facade)\\.ts$",
// ngrx
"^.*/src/app/.*/store/([a-z][a-z0-9-]+/|)([a-z][a-z0-9-]+)/\\2(\\-[a-z][a-z0-9-]+|)\\.(action|effects|reducer|selectors)\\.ts",
"^.*/src/app/.*/store/([a-z][a-z0-9-]+/|)([a-z][a-z0-9-]+)/index\\.ts",
"^.*/src/app/.*/store/([a-z][a-z0-9-]+)/\\1-store(\\.module|)\\.ts",
"^.*/([a-z][a-z0-9-]+)/store/\\1-store(\\.module|)\\.ts",
"^.*/store/([a-z][a-z0-9-]+/|)([a-z][a-z0-9-]+)/\\2(\\-[a-z][a-z0-9-]+|)\\.(actions|effects|reducer|selectors)\\.ts",
"^.*/store/([a-z][a-z0-9-]+/|)([a-z][a-z0-9-]+)/index\\.ts",
"^.*/store/([a-z][a-z0-9-]+)/\\1-store(\\.module|)\\.ts",
"^.*/([a-z][a-z0-9-]+)(/src/app|)/store/\\1-store(\\.module|)\\.ts",
// ngrx router-store
"^.*/src/app/core/store/router/router\\.(operators|serializer)\\.ts",
// allow only app related content directly in src/app
Expand All @@ -530,9 +535,10 @@
"^.*/src/app/shell/(header|footer)/([a-z][a-z0-9-]+)/\\2\\.component\\.ts$",
"^.*/src/app/shell/[a-z][a-z0-9-]+/configurations/.*\\.ts$",
// specific (lazy loaded) page modules
"^.*/src/app/(|extensions/[a-z][a-z0-9-]+/)pages/([a-z][a-z0-9-]+)/\\2-page\\.(module|component)\\.ts$",
"^.*/src/app/(|extensions/[a-z][a-z0-9-]+/)pages/[a-z][a-z0-9-]+/([a-z][a-z0-9-]+)/\\2\\.component\\.ts$",
"^.*(/src/app|/src/app/extensions/[a-z][a-z0-9-]+|projects/[a-z][a-z0-9-]+/src/app)/pages/([a-z][a-z0-9-]+)/\\2-page\\.(module|component)\\.ts$",
"^.*(/src/app|/src/app/extensions/[a-z][a-z0-9-]+|projects/[a-z][a-z0-9-]+/src/app)/pages/[a-z][a-z0-9-]+/([a-z][a-z0-9-]+)/\\2\\.component\\.ts$",
"^.*/src/app/extensions/([a-z][a-z0-9-]+)/pages/\\1-routing\\.module\\.ts$",
"^.*/projects/([a-z][a-z0-9-]+)/src/app/pages/\\1-routing\\.module\\.ts$",
"^.*/src/app/pages/app[a-z0-9-]*-routing\\.module\\.ts$",
// enforce folder structure for shared components
"^.*/src/app/extensions/[a-z][a-z0-9-]+/shared/[a-z][a-z0-9-]+/([a-z][a-z0-9-]+)/\\1\\.component\\.ts$",
Expand All @@ -544,6 +550,7 @@
// aggregation modules
"^.*/src/app/(shell|shared)/\\1\\.module\\.ts$",
"^.*/src/app/extensions/([a-z][a-z0-9-]+)/\\1\\.module\\.ts$",
"^.*/projects/([a-z][a-z0-9-]+)/src/app/\\1\\.module\\.ts$",
// extension exports
"^.*/src/app/extensions/[a-z][a-z0-9-]+/exports/[a-z][a-z0-9-]+/(lazy-[a-z][a-z0-9-]+)/\\1\\.component\\.ts$",
"^.*/src/app/extensions/([a-z][a-z0-9-]+)/exports/\\1-exports\\.module\\.ts$"
Expand Down Expand Up @@ -645,7 +652,7 @@
},
{
"name": "^(.*)Module$",
"file": ".*(cypress.*|/<kebab>/<kebab>|/core/[a-z][a-z0-9-]+)\\.module\\.ts$"
"file": ".*(cypress.*|/<kebab>/<kebab>|/projects/<kebab>/src/app/<kebab>|/core/[a-z][a-z0-9-]+)\\.module\\.ts$"
},
{
"name": "^(.*)Routes$",
Expand All @@ -671,7 +678,7 @@
// facades
{
"name": "^([A-Z].*)Facade$",
"file": ".*/app/(core|extensions/[a-z][a-z0-9-]+)/facades/<kebab>\\.facade\\.ts$"
"file": ".*(/src/app/core|/src/app/extensions/[a-z][a-z0-9-]+|/projects/[a-z][a-z0-9-]+/src/app)/facades/<kebab>\\.facade\\.ts$"
},
// ngrx
{
Expand Down

0 comments on commit 187a485

Please sign in to comment.