Skip to content

Commit f005a8f

Browse files
authored
test(client): examples lint config (#23344)
to expect non-internal exports Use /legacy for most imports, but some /beta and /alpha. In example-utils modelLoader, use tinylicious-driver /test-utils. (example-utils readme notes it has non-production code.) Copied implementation of `delay` from `core-utils` to avoid `/internal` import. Skipped some packages per internal API use: - apps/presence-tracker (pending rewrite in #23020) - benchmarks/odspsnapshotfetch-perftestapp - utils/bundle-size-tests - utils/webpack-fluid-loader There are a number of /internal imports that are suppressed. packages with imported internals: - cell (x3) [AB#26903](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26903) - container-loader (x1) [AB#26907](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26907) - core-interfaces (x1) [AB#26908](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26908) - fluid-static (x1) [AB#26986](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26986) - local-driver (x3) [AB#26987](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26987) - merge-tree (x3) [AB#26905](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26905) - sequence (x8) [AB#26904](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26904) - test-runtime-utils (x2) [AB#26985](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26985) - test-utils (x7) [AB#26906](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26906)
1 parent 29718a0 commit f005a8f

File tree

196 files changed

+626
-441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+626
-441
lines changed

examples/.eslintrc.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*!
2+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
// NOTE: this file isn't recognized by eslint automatically in this location.
7+
// Packages that want to leverage it should extend from it in their local
8+
// `.eslintrc.cjs` and normally after other configurations; so that these
9+
// rules get priority.
10+
11+
const { lintConfig } = require("./.eslintrc.data.cjs");
12+
13+
module.exports = lintConfig;

examples/.eslintrc.data.cjs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*!
2+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
// To facilitate reuse of configuration elements this module exports some
7+
// pieces of configuration and composed configuration.
8+
9+
const importInternalModulesAllowed = [
10+
// Allow import of Fluid Framework external API exports.
11+
"@fluidframework/*/{beta,alpha,legacy}",
12+
"fluid-framework/{beta,alpha,legacy}",
13+
14+
// Experimental package APIs and exports are unknown, so allow any imports from them.
15+
"@fluid-experimental/**",
16+
17+
// Within examples allow import of Fluid Framework non-production test-utils APIs.
18+
"@fluidframework/*/test-utils",
19+
20+
// Within examples assume and allow a progressive API pattern (no legacy).
21+
"@fluid-example/*/{beta,alpha}",
22+
23+
// Allow imports from sibling and ancestral sibling directories,
24+
// but not from cousin directories. Parent is allowed but only
25+
// because there isn't a known way to deny it.
26+
"*/index.js",
27+
];
28+
29+
const importInternalModulesAllowedForTest = importInternalModulesAllowed.concat([
30+
// TODO #26906: `test-utils` internal used in examples (test)
31+
// Should `test-utils` provide support through `/test-utils` instead of `/internal`?
32+
"@fluidframework/test-utils/internal",
33+
34+
// Allow internal reaching within test directories.
35+
// (And also some external packages that aren't setup as modules.)
36+
"*/*.js",
37+
]);
38+
39+
const lintConfig = {
40+
rules: {
41+
/**
42+
* Allow Fluid Framework examples to import from unstable and legacy APIs.
43+
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-internal-modules.md
44+
*/
45+
"import/no-internal-modules": [
46+
"error",
47+
{
48+
allow: importInternalModulesAllowed,
49+
},
50+
],
51+
},
52+
overrides: [
53+
{
54+
files: ["*.spec.ts", "src/test/**", "tests/**"],
55+
rules: {
56+
"import/no-internal-modules": [
57+
"error",
58+
{
59+
allow: importInternalModulesAllowedForTest,
60+
},
61+
],
62+
},
63+
},
64+
],
65+
};
66+
67+
module.exports = {
68+
importInternalModulesAllowed: importInternalModulesAllowed,
69+
importInternalModulesAllowedForTest: importInternalModulesAllowedForTest,
70+
lintConfig: lintConfig,
71+
};

examples/apps/ai-collab/.eslintrc.cjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
* Licensed under the MIT License.
44
*/
55

6+
const { importInternalModulesAllowed } = require("../../.eslintrc.data.cjs");
7+
68
module.exports = {
7-
extends: [require.resolve("@fluidframework/eslint-config-fluid/recommended"), "prettier"],
9+
extends: [
10+
require.resolve("@fluidframework/eslint-config-fluid/recommended"),
11+
"prettier",
12+
"../../.eslintrc.cjs",
13+
],
814
parserOptions: {
915
project: ["./tsconfig.json"],
1016
},
1117
rules: {
1218
"import/no-internal-modules": [
1319
"error",
1420
{
15-
allow: [
16-
"@fluidframework/odsp-client/beta",
17-
"@fluidframework/tree/alpha",
18-
21+
allow: importInternalModulesAllowed.concat([
1922
// NextJS requires reaching to its internal modules
2023
"next/**",
2124

2225
// Path aliases
2326
"@/actions/**",
2427
"@/types/**",
2528
"@/components/**",
26-
27-
// Experimental package APIs and exports are unknown, so allow any imports from them.
28-
"@fluidframework/ai-collab/alpha",
29-
],
29+
]),
3030
},
3131
],
3232
// This is an example/test app; all its dependencies are dev dependencies so as not to pollute the lockfile

examples/apps/attributable-map/.eslintrc.cjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
*/
55

66
module.exports = {
7-
extends: [require.resolve("@fluidframework/eslint-config-fluid"), "prettier"],
7+
extends: [
8+
require.resolve("@fluidframework/eslint-config-fluid"),
9+
"prettier",
10+
"../../.eslintrc.cjs",
11+
],
812
rules: {
913
"@fluid-internal/fluid/no-unchecked-record-access": "warn",
1014
},

examples/apps/attributable-map/src/containerCode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import { getDataStoreEntryPoint } from "@fluid-example/example-utils";
77
import { IProvideRuntimeAttributor, IRuntimeAttributor } from "@fluid-experimental/attributor";
8-
import { IContainer } from "@fluidframework/container-definitions/internal";
9-
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
8+
import { IContainer } from "@fluidframework/container-definitions/legacy";
9+
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/legacy";
1010
import { FluidObject } from "@fluidframework/core-interfaces";
1111

1212
import { HitCounter } from "./dataObject.js";

examples/apps/attributable-map/src/dataObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import type { EventEmitter } from "@fluid-example/example-utils";
77
import { AttributableMap, ISharedMap } from "@fluid-experimental/attributable-map";
8-
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/internal";
8+
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/legacy";
99
import { IFluidHandle } from "@fluidframework/core-interfaces";
1010

1111
export const greenKey = "green";

examples/apps/attributable-map/src/modelContainerRuntimeFactoryWithAttribution.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import {
1010
IContainerContext,
1111
IRuntime,
1212
IRuntimeFactory,
13-
} from "@fluidframework/container-definitions/internal";
14-
import { IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
15-
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
16-
import { NamedFluidDataStoreRegistryEntries } from "@fluidframework/runtime-definitions/internal";
13+
} from "@fluidframework/container-definitions/legacy";
14+
import { IContainerRuntimeOptions } from "@fluidframework/container-runtime/legacy";
15+
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/legacy";
16+
import { NamedFluidDataStoreRegistryEntries } from "@fluidframework/runtime-definitions/legacy";
1717

1818
const containerRuntimeWithAttribution = mixinAttributor();
1919

examples/apps/attributable-map/src/view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* eslint-disable @typescript-eslint/no-non-null-assertion */
77

88
import { IRuntimeAttributor } from "@fluid-experimental/attributor";
9-
import type { AttributionKey } from "@fluidframework/runtime-definitions/internal";
9+
import type { AttributionKey } from "@fluidframework/runtime-definitions/legacy";
1010

1111
import { IHitCounter, ITinyliciousUser, greenKey, redKey } from "./dataObject.js";
1212

examples/apps/collaborative-textarea/.eslintrc.cjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
*/
55

66
module.exports = {
7-
extends: [require.resolve("@fluidframework/eslint-config-fluid"), "prettier"],
7+
extends: [
8+
require.resolve("@fluidframework/eslint-config-fluid"),
9+
"prettier",
10+
"../../.eslintrc.cjs",
11+
],
812
rules: {},
913
};

examples/apps/collaborative-textarea/src/container.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
ModelContainerRuntimeFactory,
88
getDataStoreEntryPoint,
99
} from "@fluid-example/example-utils";
10-
import { IContainer } from "@fluidframework/container-definitions/internal";
11-
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
10+
import { IContainer } from "@fluidframework/container-definitions/legacy";
11+
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/legacy";
1212

1313
import { CollaborativeText } from "./fluid-object/index.js";
1414

0 commit comments

Comments
 (0)