Skip to content

Commit 01fcb93

Browse files
authored
chore: import type lint rule and fixes (#1039)
Inspired by [this comment](#1020 (comment)) I've added a lint rule to enforce `import type`, and some additional package changes to add a `lint:fix`. The only changes I made manually here is to add the lint rule, and the package.json script. All the changes are auto-generated by the `lint:fix`. --------- Signed-off-by: Todd Baert <[email protected]>
1 parent 924802b commit 01fcb93

File tree

93 files changed

+348
-278
lines changed

Some content is hidden

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

93 files changed

+348
-278
lines changed

.eslintrc.json

Lines changed: 53 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,54 @@
11
{
2-
"env": {
3-
"browser": true,
4-
"es2021": true
5-
},
6-
"ignorePatterns": ["**/dist/**/*"],
7-
"extends": [
8-
"eslint:recommended",
9-
"plugin:@typescript-eslint/recommended",
10-
"prettier",
11-
"plugin:jsdoc/recommended"
12-
],
13-
"parser": "@typescript-eslint/parser",
14-
"parserOptions": {
15-
"ecmaVersion": "latest",
16-
"sourceType": "module"
17-
},
18-
"plugins": [
19-
"@typescript-eslint",
20-
"check-file",
21-
"jsdoc"
22-
],
23-
"rules": {
24-
"jsdoc/require-jsdoc": [
25-
"warn",
26-
{
27-
"publicOnly": true
28-
}
29-
],
30-
"jsdoc/check-tag-names": [
31-
"warn",
32-
{
33-
"definedTags": [
34-
"experimental"
35-
]
36-
}
37-
],
38-
"linebreak-style": [
39-
"error",
40-
"unix"
41-
],
42-
"quotes": [
43-
"error",
44-
"single",
45-
{
46-
"avoidEscape": true
47-
}
48-
],
49-
"semi": [
50-
"error",
51-
"always"
52-
],
53-
"check-file/filename-naming-convention": [
54-
"error",
55-
{
56-
"**/*.{js,ts}": "KEBAB_CASE"
57-
},
58-
{
59-
"ignoreMiddleExtensions": true
60-
}
61-
]
62-
}
63-
}
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"ignorePatterns": ["**/dist/**/*"],
7+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:jsdoc/recommended"],
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"ecmaVersion": "latest",
11+
"sourceType": "module"
12+
},
13+
"plugins": ["@typescript-eslint", "check-file", "jsdoc"],
14+
"rules": {
15+
"@typescript-eslint/consistent-type-imports": [
16+
"error",
17+
{
18+
"disallowTypeAnnotations": true,
19+
"fixStyle": "separate-type-imports",
20+
"prefer": "type-imports"
21+
}
22+
],
23+
"jsdoc/require-jsdoc": [
24+
"warn",
25+
{
26+
"publicOnly": true
27+
}
28+
],
29+
"jsdoc/check-tag-names": [
30+
"warn",
31+
{
32+
"definedTags": ["experimental"]
33+
}
34+
],
35+
"linebreak-style": ["error", "unix"],
36+
"quotes": [
37+
"error",
38+
"single",
39+
{
40+
"avoidEscape": true
41+
}
42+
],
43+
"semi": ["error", "always"],
44+
"check-file/filename-naming-convention": [
45+
"error",
46+
{
47+
"**/*.{js,ts}": "KEBAB_CASE"
48+
},
49+
{
50+
"ignoreMiddleExtensions": true
51+
}
52+
]
53+
}
54+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"e2e-web": "git submodule update --init --recursive && shx cp test-harness/features/evaluation.feature packages/web/e2e/features && jest --selectProjects=web-e2e --verbose",
1010
"e2e": "npm run e2e-server && npm run e2e-web",
1111
"lint": "npm run lint --workspace=packages/shared --workspace=packages/server --workspace=packages/web --workspace=packages/react --workspace=packages/angular --workspace=packages/nest",
12+
"lint:fix": "npm run lint:fix --workspace=packages/shared --workspace=packages/server --workspace=packages/web --workspace=packages/react --workspace=packages/angular --workspace=packages/nest",
1213
"clean": "shx rm -rf ./dist",
1314
"build": "npm run build --workspace=packages/shared --workspace=packages/server --workspace=packages/web --workspace=packages/react --workspace=packages/angular --workspace=packages/nest",
1415
"publish-all": "npm run publish-if-not-exists --workspace=packages/shared --workspace=packages/server --workspace=packages/web --workspace=packages/react --workspace=packages/angular --workspace=packages/nest",

packages/angular/angular.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"cli": {
4040
"schematicCollections": [
4141
"@angular-eslint/schematics"
42-
]
42+
],
43+
"analytics": false
4344
}
4445
}

packages/angular/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ng": "ng",
66
"start": "ng serve",
77
"lint": "ng lint",
8+
"lint:fix": "ng lint --fix",
89
"watch": "ng build --watch --configuration development",
910
"test": "jest",
1011
"build": "ng build && npm run postbuild",

packages/nest/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"scripts": {
1717
"test": "jest --verbose",
1818
"lint": "eslint ./",
19+
"lint:fix": "eslint ./ --fix",
1920
"clean": "shx rm -rf ./dist",
2021
"build:esm": "esbuild src/index.ts --bundle --external:@nestjs/* --external:@openfeature/server-sdk --sourcemap --target=es2015 --platform=node --format=esm --outfile=./dist/esm/index.js --analyze",
2122
"build:cjs": "esbuild src/index.ts --bundle --external:@nestjs/* --external:@openfeature/server-sdk --sourcemap --target=es2015 --platform=node --format=cjs --outfile=./dist/cjs/index.js --analyze",
@@ -60,4 +61,4 @@
6061
"@types/supertest": "^6.0.0",
6162
"supertest": "^7.0.0"
6263
}
63-
}
64+
}

packages/nest/src/context-factory.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { EvaluationContext } from '@openfeature/core';
2-
import { ExecutionContext, Inject } from '@nestjs/common';
1+
import type { EvaluationContext } from '@openfeature/core';
2+
import type { ExecutionContext} from '@nestjs/common';
3+
import { Inject } from '@nestjs/common';
34

45
/**
56
* A factory function for creating an OpenFeature {@link EvaluationContext} from Nest {@link ExecutionContext}.

packages/nest/src/evaluation-context-interceptor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { CallHandler, ExecutionContext, Inject, Injectable, NestInterceptor } from '@nestjs/common';
2-
import { ContextFactory, ContextFactoryToken } from './context-factory';
1+
import type { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
2+
import { Inject, Injectable } from '@nestjs/common';
3+
import type { ContextFactory} from './context-factory';
4+
import { ContextFactoryToken } from './context-factory';
35
import { Observable } from 'rxjs';
46
import { OpenFeature } from '@openfeature/server-sdk';
57
import { OpenFeatureModule } from './open-feature.module';

packages/nest/src/feature.decorator.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { createParamDecorator, Inject } from '@nestjs/common';
2-
import {
2+
import type {
33
EvaluationContext,
44
EvaluationDetails,
55
FlagValue,
6-
JsonValue,
6+
JsonValue} from '@openfeature/server-sdk';
7+
import {
78
OpenFeature,
89
Client,
910
} from '@openfeature/server-sdk';
1011
import { getOpenFeatureClientToken } from './open-feature.module';
11-
import { from, Observable } from 'rxjs';
12+
import type { Observable } from 'rxjs';
13+
import { from } from 'rxjs';
1214

1315
/**
1416
* Options for injecting an OpenFeature client into a constructor.

packages/nest/src/open-feature.module.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
import {
1+
import type {
22
DynamicModule,
3-
Module,
43
FactoryProvider as NestFactoryProvider,
54
ValueProvider,
65
ClassProvider,
7-
Provider as NestProvider,
6+
Provider as NestProvider} from '@nestjs/common';
7+
import {
8+
Module,
89
ExecutionContext,
910
} from '@nestjs/common';
10-
import {
11+
import type {
1112
Client,
1213
Hook,
13-
OpenFeature,
1414
Provider,
1515
EvaluationContext,
1616
ServerProviderEvents,
1717
EventHandler,
18-
Logger,
18+
Logger} from '@openfeature/server-sdk';
19+
import {
20+
OpenFeature,
1921
AsyncLocalStorageTransactionContextPropagator,
2022
} from '@openfeature/server-sdk';
21-
import { ContextFactory, ContextFactoryToken } from './context-factory';
23+
import type { ContextFactory} from './context-factory';
24+
import { ContextFactoryToken } from './context-factory';
2225
import { APP_INTERCEPTOR } from '@nestjs/core';
2326
import { EvaluationContextInterceptor } from './evaluation-context-interceptor';
2427
import { ShutdownService } from './shutdown.service';

packages/nest/src/shutdown.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Injectable, OnApplicationShutdown } from '@nestjs/common';
1+
import type { OnApplicationShutdown } from '@nestjs/common';
2+
import { Injectable } from '@nestjs/common';
23
import { OpenFeature } from '@openfeature/server-sdk';
34

45
@Injectable()

0 commit comments

Comments
 (0)