Skip to content

Commit df08e4c

Browse files
authored
refactor(client/dds): Enable type-only import/export linter rules and fix violations (#25051)
In preparation for these rules becoming default in the next release of our eslint configuration. Type-only imports offer a number of benefits and are considered a best practice. More details can be found here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html
1 parent 9eb71ea commit df08e4c

32 files changed

+172
-102
lines changed

packages/dds/ink/.eslintrc.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,17 @@ module.exports = {
88
parserOptions: {
99
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
1010
},
11+
rules: {
12+
// #region TODO: remove these once eslint-config-fluid has been updated to 5.8.0
13+
"@typescript-eslint/consistent-type-exports": [
14+
"error",
15+
{ fixMixedExportsWithInlineTypeSpecifier: true },
16+
],
17+
"@typescript-eslint/consistent-type-imports": [
18+
"error",
19+
{ fixStyle: "inline-type-imports" },
20+
],
21+
"@typescript-eslint/no-import-type-side-effects": "error",
22+
// #endregion
23+
},
1124
};

packages/dds/ink/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
export { Ink } from "./ink.js";
77
export { InkCanvas } from "./inkCanvas.js";
88
export { InkFactory } from "./inkFactory.js";
9-
export {
9+
export type {
1010
IClearOperation,
1111
IColor,
1212
ICreateStrokeOperation,

packages/dds/ink/src/ink.ts

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

6-
import {
6+
import type {
77
IChannelAttributes,
88
IFluidDataStoreRuntime,
99
IChannelStorageService,
1010
} from "@fluidframework/datastore-definitions/internal";
1111
import {
1212
MessageType,
13-
ISequencedDocumentMessage,
13+
type ISequencedDocumentMessage,
1414
} from "@fluidframework/driver-definitions/internal";
1515
import { readAndParse } from "@fluidframework/driver-utils/internal";
16-
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
16+
import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
1717
import {
18-
IFluidSerializer,
18+
type IFluidSerializer,
1919
SharedObject,
2020
createSingleBlobSummary,
2121
} from "@fluidframework/shared-object-base/internal";
2222
import { v4 as uuid } from "uuid";
2323

2424
import { InkFactory } from "./inkFactory.js";
25-
import {
25+
import type {
2626
IClearOperation,
2727
ICreateStrokeOperation,
2828
IInk,
@@ -33,7 +33,7 @@ import {
3333
IPen,
3434
IStylusOperation,
3535
} from "./interfaces.js";
36-
import { ISerializableInk, InkData } from "./snapshot.js";
36+
import { type ISerializableInk, InkData } from "./snapshot.js";
3737

3838
/**
3939
* Filename where the snapshot is stored.

packages/dds/ink/src/inkCanvas.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import { IColor, IInk, IInkPoint, IInkStroke, IPen, IStylusOperation } from "./interfaces.js";
6+
import type {
7+
IColor,
8+
IInk,
9+
IInkPoint,
10+
IInkStroke,
11+
IPen,
12+
IStylusOperation,
13+
} from "./interfaces.js";
714

815
interface IPoint {
916
x: number;

packages/dds/ink/src/inkFactory.ts

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

6-
import {
6+
import type {
77
IChannelAttributes,
88
IChannelFactory,
99
IFluidDataStoreRuntime,
1010
IChannelServices,
1111
} from "@fluidframework/datastore-definitions/internal";
12-
import { ISharedObject } from "@fluidframework/shared-object-base/internal";
12+
import type { ISharedObject } from "@fluidframework/shared-object-base/internal";
1313

1414
import { Ink } from "./ink.js";
1515
import { pkgVersion } from "./packageVersion.js";

packages/dds/ink/src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import {
6+
import type {
77
ISharedObject,
88
ISharedObjectEvents,
99
} from "@fluidframework/shared-object-base/internal";

packages/dds/ink/src/snapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import { IInkStroke } from "./interfaces.js";
6+
import type { IInkStroke } from "./interfaces.js";
77

88
/**
99
* Ink snapshot interface.

packages/dds/ink/src/test/ink.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import { AttachState } from "@fluidframework/container-definitions";
99
import {
1010
MockContainerRuntimeFactory,
1111
MockContainerRuntimeFactoryForReconnection,
12-
MockContainerRuntimeForReconnection,
12+
type MockContainerRuntimeForReconnection,
1313
MockFluidDataStoreRuntime,
1414
MockSharedObjectServices,
1515
MockStorage,
1616
} from "@fluidframework/test-runtime-utils/internal";
1717

1818
import { Ink } from "../ink.js";
1919
import { InkFactory } from "../inkFactory.js";
20-
import { IPen } from "../interfaces.js";
20+
import type { IPen } from "../interfaces.js";
2121

2222
describe("Ink", () => {
2323
let ink: Ink;

packages/dds/matrix/.eslintrc.cjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ module.exports = {
1212
rules: {
1313
"@typescript-eslint/no-shadow": "off",
1414
"space-before-function-paren": "off", // Off because it conflicts with typescript-formatter
15+
// #region TODO: remove these once eslint-config-fluid has been updated to 5.8.0
16+
"@typescript-eslint/consistent-type-exports": [
17+
"error",
18+
{ fixMixedExportsWithInlineTypeSpecifier: true },
19+
],
20+
"@typescript-eslint/consistent-type-imports": [
21+
"error",
22+
{ fixStyle: "inline-type-imports" },
23+
],
24+
"@typescript-eslint/no-import-type-side-effects": "error",
25+
// #endregion
1526
},
1627
overrides: [
1728
{

packages/dds/shared-object-base/.eslintrc.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,17 @@ module.exports = {
88
parserOptions: {
99
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
1010
},
11+
rules: {
12+
// #region TODO: remove these once eslint-config-fluid has been updated to 5.8.0
13+
"@typescript-eslint/consistent-type-exports": [
14+
"error",
15+
{ fixMixedExportsWithInlineTypeSpecifier: true },
16+
],
17+
"@typescript-eslint/consistent-type-imports": [
18+
"error",
19+
{ fixStyle: "inline-type-imports" },
20+
],
21+
"@typescript-eslint/no-import-type-side-effects": "error",
22+
// #endregion
23+
},
1124
};

0 commit comments

Comments
 (0)