Skip to content

Commit

Permalink
improvement(eslint-config-fluid): Update type import/export rules to …
Browse files Browse the repository at this point in the history
…help prevent runtime side-effects (microsoft#21402)

Adds the
[@typescript-eslint/no-import-type-side-effects](https://typescript-eslint.io/rules/no-import-type-side-effects/)
rule to our strict eslint configuration.

Pre-fixes violations across the repo.
  • Loading branch information
Josmithr authored Jun 13, 2024
1 parent b62a70b commit bbc17a2
Show file tree
Hide file tree
Showing 172 changed files with 673 additions and 697 deletions.
3 changes: 3 additions & 0 deletions common/build/eslint-config-fluid/printed-configs/strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@
"@typescript-eslint/no-implied-eval": [
"error"
],
"@typescript-eslint/no-import-type-side-effects": [
"error"
],
"@typescript-eslint/no-inferrable-types": [
"off"
],
Expand Down
11 changes: 11 additions & 0 deletions common/build/eslint-config-fluid/strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module.exports = {
/**
* Requires that type-only exports be done using `export type`. Being explicit allows the TypeScript
* `isolatedModules` flag to be used, and isolated modules are needed to adopt modern build tools like swc.
*
* @see {@link https://typescript-eslint.io/rules/consistent-type-exports/}
*/
"@typescript-eslint/consistent-type-exports": [
"error",
Expand All @@ -82,12 +84,21 @@ module.exports = {
/**
* Requires that type-only imports be done using `import type`. Being explicit allows the TypeScript
* `isolatedModules` flag to be used, and isolated modules are needed to adopt modern build tools like swc.
*
* @see {@link https://typescript-eslint.io/rules/consistent-type-imports/}
*/
"@typescript-eslint/consistent-type-imports": [
"error",
{ fixStyle: "separate-type-imports" },
],

/**
* Ensures that type-only import statements do not result in runtime side-effects.
*
* @see {@link https://typescript-eslint.io/rules/no-import-type-side-effects/}
*/
"@typescript-eslint/no-import-type-side-effects": "error",

/**
* Prefer Record to index-signature object style. That is, prefer:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import { DataObject } from '@fluidframework/aqueduct/internal';
import type { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions/internal';
import type { IFluidLoadable } from '@fluidframework/core-interfaces';
import { ImplicitFieldSchema } from '@fluidframework/tree';
import type { ImplicitFieldSchema } from '@fluidframework/tree';
import * as React_2 from 'react';
import { SchemaCompatibilityStatus } from '@fluidframework/tree';
import type { SchemaCompatibilityStatus } from '@fluidframework/tree';
import type { SharedObjectKind } from '@fluidframework/shared-object-base';
import { TreeConfiguration } from '@fluidframework/tree';
import { TreeFieldFromImplicitField } from '@fluidframework/tree';
import type { TreeConfiguration } from '@fluidframework/tree';
import type { TreeFieldFromImplicitField } from '@fluidframework/tree';
import { TreeNode } from '@fluidframework/tree';
import { TreeView } from '@fluidframework/tree';
import type { TreeView } from '@fluidframework/tree';

// @public
export interface IReactTreeDataObject<TSchema extends ImplicitFieldSchema> extends ITreeDataObject<TSchema> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import { DataObject } from '@fluidframework/aqueduct/internal';
import type { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions/internal';
import type { IFluidLoadable } from '@fluidframework/core-interfaces';
import { ImplicitFieldSchema } from '@fluidframework/tree';
import type { ImplicitFieldSchema } from '@fluidframework/tree';
import * as React_2 from 'react';
import { SchemaCompatibilityStatus } from '@fluidframework/tree';
import type { SchemaCompatibilityStatus } from '@fluidframework/tree';
import type { SharedObjectKind } from '@fluidframework/shared-object-base';
import { TreeConfiguration } from '@fluidframework/tree';
import { TreeFieldFromImplicitField } from '@fluidframework/tree';
import type { TreeConfiguration } from '@fluidframework/tree';
import type { TreeFieldFromImplicitField } from '@fluidframework/tree';
import { TreeNode } from '@fluidframework/tree';
import { TreeView } from '@fluidframework/tree';
import type { TreeView } from '@fluidframework/tree';

// @public
export interface IReactTreeDataObject<TSchema extends ImplicitFieldSchema> extends ITreeDataObject<TSchema> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import { DataObject } from '@fluidframework/aqueduct/internal';
import type { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions/internal';
import type { IFluidLoadable } from '@fluidframework/core-interfaces';
import { ImplicitFieldSchema } from '@fluidframework/tree';
import type { ImplicitFieldSchema } from '@fluidframework/tree';
import * as React_2 from 'react';
import { SchemaCompatibilityStatus } from '@fluidframework/tree';
import type { SchemaCompatibilityStatus } from '@fluidframework/tree';
import type { SharedObjectKind } from '@fluidframework/shared-object-base';
import { TreeConfiguration } from '@fluidframework/tree';
import { TreeFieldFromImplicitField } from '@fluidframework/tree';
import type { TreeConfiguration } from '@fluidframework/tree';
import type { TreeFieldFromImplicitField } from '@fluidframework/tree';
import { TreeNode } from '@fluidframework/tree';
import { TreeView } from '@fluidframework/tree';
import type { TreeView } from '@fluidframework/tree';

// @public
export interface IReactTreeDataObject<TSchema extends ImplicitFieldSchema> extends ITreeDataObject<TSchema> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import {
import type { IFluidHandle, IFluidLoadable } from "@fluidframework/core-interfaces";
import type { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions/internal";
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
import {
type ITree,
type SchemaCompatibilityStatus,
import type {
ITree,
SchemaCompatibilityStatus,
// eslint-disable-next-line import/no-deprecated
type TreeConfiguration,
type TreeFieldFromImplicitField,
type TreeView,
type ImplicitFieldSchema,
TreeConfiguration,
TreeFieldFromImplicitField,
TreeView,
ImplicitFieldSchema,
} from "@fluidframework/tree";
import { configuredSharedTree, typeboxValidator } from "@fluidframework/tree/internal";
import * as React from "react";
Expand Down
2 changes: 1 addition & 1 deletion packages/common/core-interfaces/src/handles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { type ErasedType } from "./erasedType.js";
import type { ErasedType } from "./erasedType.js";
import type { IRequest, IResponse } from "./fluidRouter.js";

/**
Expand Down
16 changes: 8 additions & 8 deletions packages/dds/cell/api-report/cell.alpha.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
```ts

import { AttributionKey } from '@fluidframework/runtime-definitions/internal';
import { IChannelAttributes } from '@fluidframework/datastore-definitions/internal';
import { IChannelFactory } from '@fluidframework/datastore-definitions/internal';
import { IChannelServices } from '@fluidframework/datastore-definitions/internal';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions/internal';
import { ISharedObject } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import type { AttributionKey } from '@fluidframework/runtime-definitions/internal';
import type { IChannelAttributes } from '@fluidframework/datastore-definitions/internal';
import type { IChannelFactory } from '@fluidframework/datastore-definitions/internal';
import type { IChannelServices } from '@fluidframework/datastore-definitions/internal';
import type { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions/internal';
import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
import type { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { Serializable } from '@fluidframework/datastore-definitions/internal';
import type { Serializable } from '@fluidframework/datastore-definitions/internal';
import { SharedObjectKind } from '@fluidframework/shared-object-base/internal';

```
16 changes: 8 additions & 8 deletions packages/dds/cell/api-report/cell.beta.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
```ts

import { AttributionKey } from '@fluidframework/runtime-definitions/internal';
import { IChannelAttributes } from '@fluidframework/datastore-definitions/internal';
import { IChannelFactory } from '@fluidframework/datastore-definitions/internal';
import { IChannelServices } from '@fluidframework/datastore-definitions/internal';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions/internal';
import { ISharedObject } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import type { AttributionKey } from '@fluidframework/runtime-definitions/internal';
import type { IChannelAttributes } from '@fluidframework/datastore-definitions/internal';
import type { IChannelFactory } from '@fluidframework/datastore-definitions/internal';
import type { IChannelServices } from '@fluidframework/datastore-definitions/internal';
import type { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions/internal';
import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
import type { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { Serializable } from '@fluidframework/datastore-definitions/internal';
import type { Serializable } from '@fluidframework/datastore-definitions/internal';
import { SharedObjectKind } from '@fluidframework/shared-object-base/internal';

```
16 changes: 8 additions & 8 deletions packages/dds/cell/api-report/cell.public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
```ts

import { AttributionKey } from '@fluidframework/runtime-definitions/internal';
import { IChannelAttributes } from '@fluidframework/datastore-definitions/internal';
import { IChannelFactory } from '@fluidframework/datastore-definitions/internal';
import { IChannelServices } from '@fluidframework/datastore-definitions/internal';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions/internal';
import { ISharedObject } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import type { AttributionKey } from '@fluidframework/runtime-definitions/internal';
import type { IChannelAttributes } from '@fluidframework/datastore-definitions/internal';
import type { IChannelFactory } from '@fluidframework/datastore-definitions/internal';
import type { IChannelServices } from '@fluidframework/datastore-definitions/internal';
import type { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions/internal';
import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
import type { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { Serializable } from '@fluidframework/datastore-definitions/internal';
import type { Serializable } from '@fluidframework/datastore-definitions/internal';
import { SharedObjectKind } from '@fluidframework/shared-object-base/internal';

```
28 changes: 14 additions & 14 deletions packages/dds/cell/src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
*/

import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
import {
type IChannelAttributes,
type IFluidDataStoreRuntime,
type Serializable,
type IChannelStorageService,
import type {
IChannelAttributes,
IFluidDataStoreRuntime,
Serializable,
IChannelStorageService,
} from "@fluidframework/datastore-definitions/internal";
import {
MessageType,
type ISequencedDocumentMessage,
} from "@fluidframework/driver-definitions/internal";
import { readAndParse } from "@fluidframework/driver-utils/internal";
import {
type ISummaryTreeWithStats,
type AttributionKey,
import type {
ISummaryTreeWithStats,
AttributionKey,
} from "@fluidframework/runtime-definitions/internal";
import { type IFluidSerializer } from "@fluidframework/shared-object-base/internal";
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
import { SharedObject, createSingleBlobSummary } from "@fluidframework/shared-object-base/internal";

import {
type ICellLocalOpMetadata,
type ICellOptions,
type ISharedCell,
type ISharedCellEvents,
import type {
ICellLocalOpMetadata,
ICellOptions,
ISharedCell,
ISharedCellEvents,
} from "./interfaces.js";

/**
Expand Down
12 changes: 6 additions & 6 deletions packages/dds/cell/src/cellFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
* Licensed under the MIT License.
*/

import {
type IChannelAttributes,
type IChannelFactory,
type IFluidDataStoreRuntime,
type IChannelServices,
import type {
IChannelAttributes,
IChannelFactory,
IFluidDataStoreRuntime,
IChannelServices,
} from "@fluidframework/datastore-definitions/internal";
import { createSharedObjectKind } from "@fluidframework/shared-object-base/internal";

import { SharedCell as SharedCellClass } from "./cell.js";
import { type ISharedCell } from "./interfaces.js";
import type { ISharedCell } from "./interfaces.js";
import { pkgVersion } from "./packageVersion.js";

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/dds/cell/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Licensed under the MIT License.
*/

import { type Serializable } from "@fluidframework/datastore-definitions/internal";
import { type AttributionKey } from "@fluidframework/runtime-definitions/internal";
import {
type ISharedObject,
type ISharedObjectEvents,
import type { Serializable } from "@fluidframework/datastore-definitions/internal";
import type { AttributionKey } from "@fluidframework/runtime-definitions/internal";
import type {
ISharedObject,
ISharedObjectEvents,
} from "@fluidframework/shared-object-base/internal";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/dds/cell/src/test/cell.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {

import { SharedCell } from "../cell.js";
import { CellFactory } from "../cellFactory.js";
import { type ICellOptions, type ISharedCell } from "../interfaces.js";
import type { ICellOptions, ISharedCell } from "../interfaces.js";

function createConnectedCell(
id: string,
Expand Down
4 changes: 2 additions & 2 deletions packages/dds/counter/api-report/counter.alpha.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
```ts

import { ISharedObject } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
import type { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { SharedObjectKind } from '@fluidframework/shared-object-base/internal';

Expand Down
4 changes: 2 additions & 2 deletions packages/dds/counter/api-report/counter.beta.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
```ts

import { ISharedObject } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
import type { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { SharedObjectKind } from '@fluidframework/shared-object-base/internal';

Expand Down
4 changes: 2 additions & 2 deletions packages/dds/counter/api-report/counter.public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
```ts

import { ISharedObject } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
import type { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { SharedObjectKind } from '@fluidframework/shared-object-base/internal';

Expand Down
14 changes: 7 additions & 7 deletions packages/dds/counter/src/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
*/

import { assert } from "@fluidframework/core-utils/internal";
import {
type IChannelAttributes,
type IFluidDataStoreRuntime,
type IChannelStorageService,
import type {
IChannelAttributes,
IFluidDataStoreRuntime,
IChannelStorageService,
} from "@fluidframework/datastore-definitions/internal";
import {
MessageType,
type ISequencedDocumentMessage,
} from "@fluidframework/driver-definitions/internal";
import { readAndParse } from "@fluidframework/driver-utils/internal";
import { type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
import { type IFluidSerializer } from "@fluidframework/shared-object-base/internal";
import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
import { SharedObject, createSingleBlobSummary } from "@fluidframework/shared-object-base/internal";

import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces.js";
import type { ISharedCounter, ISharedCounterEvents } from "./interfaces.js";

/**
* Describes the operation (op) format for incrementing the {@link SharedCounter}.
Expand Down
12 changes: 6 additions & 6 deletions packages/dds/counter/src/counterFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
* Licensed under the MIT License.
*/

import {
type IChannelAttributes,
type IChannelFactory,
type IFluidDataStoreRuntime,
type IChannelServices,
import type {
IChannelAttributes,
IChannelFactory,
IFluidDataStoreRuntime,
IChannelServices,
} from "@fluidframework/datastore-definitions/internal";
import { createSharedObjectKind } from "@fluidframework/shared-object-base/internal";

import { SharedCounter as SharedCounterClass } from "./counter.js";
import { type ISharedCounter } from "./interfaces.js";
import type { ISharedCounter } from "./interfaces.js";
import { pkgVersion } from "./packageVersion.js";

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/dds/counter/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License.
*/

import {
type ISharedObject,
type ISharedObjectEvents,
import type {
ISharedObject,
ISharedObjectEvents,
} from "@fluidframework/shared-object-base/internal";

/**
Expand Down
Loading

0 comments on commit bbc17a2

Please sign in to comment.