Skip to content

Commit

Permalink
disallow using barrel imports internally lint rule (iTwin#1846)
Browse files Browse the repository at this point in the history
- add an eslint rule that disallows barrel import usage
- fixed some barrel import usage using the rule
- ignored some barrel files (for now) in some packages where they are being used as a pattern
  • Loading branch information
MichaelBelousov authored Jul 20, 2021
1 parent f419a96 commit e4fe7d1
Show file tree
Hide file tree
Showing 81 changed files with 2,914 additions and 1,619 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,21 @@
"[NODE] Certa Test Runner for Full Stack RPC Interface Tests",
"[BACKEND] Local Backend for Full Stack RPC Interface Tests"
]
},
{
"name": "eslint rule test @bentley/no-internal-barrel-imports",
"presentation": {
"group": "6_Misc"
},
"cwd": "${workspaceFolder}/tools/eslint-plugin",
"type": "pwa-node",
"request": "launch",
"program": "${workspaceFolder}/tools/eslint-plugin/node_modules/mocha/bin/_mocha",
"args": [
"${workspaceFolder}/tools/eslint-plugin/tests/no-internal-barrel-imports.js",
"--timeout 50000" // for easier debugging
],
"console": "integratedTerminal",
}
],
"compounds": [
Expand Down
38 changes: 19 additions & 19 deletions common/api/ecschema-metadata.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2469,7 +2469,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, any, any], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: SchemaItem;
messageArgs?: [string, any, any] | undefined;
Expand All @@ -2481,7 +2481,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: SchemaItem;
messageArgs?: [] | undefined;
Expand Down Expand Up @@ -2541,7 +2541,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [Mixin], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: EntityClass;
messageArgs?: [Mixin] | undefined;
Expand All @@ -2553,7 +2553,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, any, any], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: Mixin;
messageArgs?: [string, any, any] | undefined;
Expand All @@ -2565,7 +2565,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, any, any], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: RelationshipClass;
messageArgs?: [string, any, any] | undefined;
Expand Down Expand Up @@ -2599,7 +2599,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, any, any], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: CustomAttributeClass;
messageArgs?: [string, any, any] | undefined;
Expand All @@ -2622,7 +2622,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, string, string], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: Enumeration;
messageArgs?: [string, string, string] | undefined;
Expand All @@ -2634,7 +2634,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [AnyEnumerator], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: Enumeration;
messageArgs?: [AnyEnumerator] | undefined;
Expand All @@ -2646,7 +2646,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [AnyEnumerator, string, any, any], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: Enumeration;
messageArgs?: [AnyEnumerator, string, any, any] | undefined;
Expand All @@ -2658,7 +2658,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, any, any], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: KindOfQuantity;
messageArgs?: [string, any, any] | undefined;
Expand All @@ -2670,7 +2670,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [Format | OverrideFormat], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: KindOfQuantity;
messageArgs?: [Format | OverrideFormat] | undefined;
Expand All @@ -2682,7 +2682,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, any, any], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: PropertyCategory;
messageArgs?: [string, any, any] | undefined;
Expand All @@ -2694,7 +2694,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, any, any], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: Format;
messageArgs?: [string, any, any] | undefined;
Expand All @@ -2706,7 +2706,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [Unit | InvertedUnit], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: Format;
messageArgs?: [Unit | InvertedUnit] | undefined;
Expand All @@ -2718,7 +2718,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [Unit | InvertedUnit, string | undefined, string | undefined], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: Format;
messageArgs?: [Unit | InvertedUnit, string | undefined, string | undefined] | undefined;
Expand All @@ -2730,7 +2730,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, string, string], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: Format;
messageArgs?: [string, string, string] | undefined;
Expand All @@ -2742,7 +2742,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, string, string], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: InvertedUnit;
messageArgs?: [string, string, string] | undefined;
Expand All @@ -2754,7 +2754,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, string, string], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: InvertedUnit;
messageArgs?: [string, string, string] | undefined;
Expand All @@ -2766,7 +2766,7 @@ export const SchemaCompareDiagnostics: {
new (ecDefinition: SchemaItem, messageArgs: [string, string, string], category?: DiagnosticCategory): {
readonly code: string;
readonly messageText: string;
readonly schema: Schema;
readonly schema: Schema; /** Required message parameters: CustomAttributeClass name */
readonly diagnosticType: DiagnosticType;
ecDefinition: Constant;
messageArgs?: [string, string, string] | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/backend-itwin-client",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/backend-itwin-client",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/ecschema-metadata",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/ecschema-metadata",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/eslint-plugin",
"comment": "add and recommend no-internal-barrel-imports rule",
"type": "none"
}
],
"packageName": "@bentley/eslint-plugin",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/frontend-devtools",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/frontend-devtools",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/geometry-core",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/geometry-core",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/imodeljs-backend",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/imodeljs-backend",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/imodeljs-common",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/imodeljs-common",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/imodeljs-frontend",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/imodeljs-frontend",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/mobile-manager",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/mobile-manager",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/presentation-components",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/presentation-components",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/ui-abstract",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/ui-abstract",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/ui-components",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/ui-components",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/ui-core",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/ui-core",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/ui-framework",
"comment": "remove internal barrel-import usage",
"type": "none"
}
],
"packageName": "@bentley/ui-framework",
"email": "[email protected]"
}
4 changes: 4 additions & 0 deletions common/config/rush/browser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@
"name": "@typescript-eslint/parser",
"allowedCategories": [ "tools" ]
},
{
"name": "@typescript-eslint/typescript-estree",
"allowedCategories": [ "tools" ]
},
{
"name": "@ungap/url-search-params",
"allowedCategories": [ "common" ]
Expand Down
Loading

0 comments on commit e4fe7d1

Please sign in to comment.