@@ -158,3 +158,39 @@ Some appropriate operators are:
158
158
consider carefully if this is the right operator for your use case. mergeMap will flatten
159
159
observables but not care about the order. If ordering is important use ` concatMap ` . If you only
160
160
care about the latest value use ` switchMap ` .
161
+
162
+ ## Import statements
163
+
164
+ We have a couple of guidelines for import statements, which are enforced using the eslint rules
165
+ [ ` no-restricted-imports ` ] ( https://eslint.org/docs/latest/rules/no-restricted-imports ) ,
166
+ [ ` import/order ` ] ( https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md ) ,
167
+ and
168
+ [ ` import/no-restricted-paths ` ] ( https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-restricted-paths.md ) .
169
+
170
+ These rules aim to:
171
+
172
+ - Prevent relative imports across package boundaries.
173
+ - Restrict packages from importing application specific code.
174
+ - Enforce a convention for the order of import statements.
175
+
176
+ ### Imports within the same package
177
+
178
+ Use relative imports when importing within the same package. For example, ` MyNewService ` and
179
+ ` LogService ` are both in the ` @bitwarden/common ` package.
180
+
181
+ ``` typescript
182
+ import { LogService } from " ../../abstractions/log.service" ;
183
+
184
+ export class MyNewService {}
185
+ ```
186
+
187
+ ### Imports from different packages
188
+
189
+ For imports from different packages, use absolute imports. For example ` DifferentPackageService ` is
190
+ not in ` @bitwarden/common ` and needs to import ` LogService ` from ` @bitwarden/common ` .
191
+
192
+ ``` typescript
193
+ import { LogService } from " @bitwarden/common/platform/abstractions/log.service" ;
194
+
195
+ export class DifferentPackageService {}
196
+ ```
0 commit comments