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

+13
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

+71
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

+9-9
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

+5-1
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

+2-2
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

+1-1
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

+4-4
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

+1-1
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

+5-1
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

+2-2
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

examples/apps/collaborative-textarea/src/fluid-object/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/internal";
6+
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/legacy";
77
import { IFluidHandle } from "@fluidframework/core-interfaces";
8-
import { SharedString, type ISharedString } from "@fluidframework/sequence/internal";
8+
import { SharedString, type ISharedString } from "@fluidframework/sequence/legacy";
99

1010
/**
1111
* CollaborativeText uses the React CollaborativeTextArea to load a collaborative HTML <textarea>

examples/apps/collaborative-textarea/src/view.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { CollaborativeTextArea, SharedStringHelper } from "@fluid-example/example-utils";
7-
import { SharedString } from "@fluidframework/sequence/internal";
7+
import { SharedString } from "@fluidframework/sequence/legacy";
88
import React from "react";
99

1010
interface CollaborativeTextProps {

examples/apps/contact-collection/.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
extends: [
88
require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
99
"prettier",
10+
"../../.eslintrc.cjs",
1011
],
1112
rules: {},
1213
};

examples/apps/contact-collection/src/containerCode.ts

+2-2
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 { ContactCollectionInstantiationFactory, IContactCollection } from "./dataObject.js";
1414

examples/apps/contact-collection/src/dataObject.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import type { EventEmitter } from "@fluid-example/example-utils";
7-
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/internal";
7+
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/legacy";
88
import { v4 as uuid } from "uuid";
99

1010
/**

examples/apps/data-object-grid/.eslintrc.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ module.exports = {
77
extends: [
88
require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
99
"prettier",
10+
"../../.eslintrc.cjs",
1011
],
1112
rules: {
1213
"@typescript-eslint/strict-boolean-expressions": "off", // Doing undefined checks is nice
1314
"@typescript-eslint/unbound-method": "off", // Used to do binding for react methods
14-
"import/no-internal-modules": "off", // required for dynamically importing css files for react-grid-layout
1515
"import/no-unassigned-import": "off", // required for dynamically importing css files for react-grid-layout
1616
},
1717
};

examples/apps/data-object-grid/src/container.ts

+2-2
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 { DataObjectGrid, IDataObjectGrid } from "./dataObjectGrid.js";
1414

examples/apps/data-object-grid/src/dataObjectGrid.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55

66
import type { EventEmitter } from "@fluid-example/example-utils";
7-
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/internal";
8-
import { Serializable } from "@fluidframework/datastore-definitions/internal";
7+
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/legacy";
8+
import { Serializable } from "@fluidframework/datastore-definitions/legacy";
99
import { Layout } from "react-grid-layout";
1010
import { v4 as uuid } from "uuid";
1111

examples/apps/data-object-grid/src/dataObjectGridView.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IDataObjectGrid, IDataObjectGridItem } from "./dataObjectGrid.js";
1010
import { IDataObjectGridItemEntry, dataObjectRegistry } from "./dataObjectRegistry.js";
1111
import { DataObjectGridToolbar } from "./toolbar.js";
1212

13+
// eslint-disable-next-line import/no-internal-modules
1314
import "react-grid-layout/css/styles.css";
1415
import "./dataObjectGridView.css";
1516

examples/apps/data-object-grid/src/dataObjectRegistry.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import {
2525
ProseMirrorReactView,
2626
} from "@fluid-example/prosemirror";
2727
import { IFluidHandle } from "@fluidframework/core-interfaces";
28-
import { Serializable } from "@fluidframework/datastore-definitions/internal";
28+
import { Serializable } from "@fluidframework/datastore-definitions/legacy";
2929
import {
3030
IFluidDataStoreContext,
3131
IFluidDataStoreFactory,
3232
NamedFluidDataStoreRegistryEntries,
33-
} from "@fluidframework/runtime-definitions/internal";
33+
} from "@fluidframework/runtime-definitions/legacy";
3434
import * as React from "react";
3535

3636
const codeMirrorFactory = new SmdeFactory();

examples/apps/task-selection/.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
extends: [
88
require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
99
"prettier",
10+
"../../.eslintrc.cjs",
1011
],
1112
rules: {},
1213
};

examples/apps/task-selection/src/containerCode.ts

+2-2
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 { IDiceRoller } from "./interface.js";
1414
import { OldestClientDiceRollerInstantiationFactory } from "./oldestClientDiceRoller.js";

examples/apps/task-selection/src/oldestClientDiceRoller.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
*/
55

66
// Lint rule can be disabled once eslint config is upgraded to 5.3.0+
7-
// eslint-disable-next-line import/no-internal-modules
8-
import { OldestClientObserver } from "@fluid-experimental/oldest-client-observer/internal";
9-
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/internal";
10-
import { assert } from "@fluidframework/core-utils/internal";
7+
import { OldestClientObserver } from "@fluid-experimental/oldest-client-observer/legacy";
8+
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/legacy";
9+
import { assert } from "@fluidframework/core-utils/legacy";
1110

1211
import { IDiceRoller } from "./interface.js";
1312

examples/apps/task-selection/src/taskManagerDiceRoller.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/internal";
6+
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/legacy";
77
import { IFluidHandle } from "@fluidframework/core-interfaces";
8-
import { assert } from "@fluidframework/core-utils/internal";
9-
import { TaskManager } from "@fluidframework/task-manager/internal";
8+
import { assert } from "@fluidframework/core-utils/legacy";
9+
import { TaskManager } from "@fluidframework/task-manager/legacy";
1010

1111
import { IDiceRoller } from "./interface.js";
1212

examples/apps/tree-cli-app/.eslintrc.cjs

+5-1
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/strict"), "prettier"],
7+
extends: [
8+
require.resolve("@fluidframework/eslint-config-fluid/strict"),
9+
"prettier",
10+
"../../.eslintrc.cjs",
11+
],
812
parserOptions: {
913
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
1014
},

examples/apps/tree-cli-app/src/test/schema.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
type ICodecOptions,
1414
type ImplicitFieldSchema,
1515
type JsonCompatible,
16-
// eslint-disable-next-line import/no-internal-modules
1716
} from "@fluidframework/tree/alpha";
1817

1918
import { List } from "../schema.js";

0 commit comments

Comments
 (0)