Skip to content

Commit 1b528af

Browse files
authored
Upgrades dependencies to latest + changes required to support latest versions (#265)
* Upgrades dependencies to latest + changes required to support latest versions. * Updates the build to use Node 22 to install and build, while testing for each supported nodejs version * - Removes the automatic linting on test and adds it as a specific test in the cicd * Updates nodejs versions supported. * Removes reference to yarn in `package.json` * adds important dependency that must be fixed in yarn.lock * Updates dependencies * Edits the yarn.lock file to update the dependency version for istanbul-lib-report. Else, it takes an old one and things break. * sets an alpha version to avoid publishing issues
1 parent f077226 commit 1b528af

27 files changed

+2298
-3229
lines changed

.eslintrc.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 22.x]
17+
node-version: [18.x, 20.x, 22.x]
1818

1919
steps:
2020
- uses: actions/checkout@v4
@@ -28,10 +28,12 @@ jobs:
2828
run: |
2929
npm -g i yarn
3030
31-
- name: npm install, build, and test
31+
- name: yarn install, yarn build, and yarn test
3232
run: |
3333
yarn
3434
yarn build
3535
yarn test
3636
env:
3737
CI: true
38+
39+

eslint.config.mjs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { defineConfig } from "eslint/config";
2+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
3+
import prettier from "eslint-plugin-prettier";
4+
import globals from "globals";
5+
import tsParser from "@typescript-eslint/parser";
6+
import path from "node:path";
7+
import { fileURLToPath } from "node:url";
8+
import js from "@eslint/js";
9+
import { FlatCompat } from "@eslint/eslintrc";
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all
17+
});
18+
19+
export default defineConfig([{
20+
files: ["./src/**/*.js", "./src/**/*.jsx", "./src/**/*.ts", "./src/**/*.tsx"],
21+
extends: compat.extends(
22+
"plugin:@typescript-eslint/recommended",
23+
"plugin:prettier/recommended",
24+
),
25+
26+
plugins: {
27+
"@typescript-eslint": typescriptEslint,
28+
prettier,
29+
},
30+
31+
languageOptions: {
32+
globals: {
33+
...globals.browser,
34+
...globals.commonjs,
35+
Atomics: "readonly",
36+
SharedArrayBuffer: "readonly",
37+
},
38+
39+
parser: tsParser,
40+
ecmaVersion: 2018,
41+
sourceType: "script",
42+
},
43+
44+
rules: {
45+
"@typescript-eslint/explicit-function-return-type": ["warn", {
46+
allowExpressions: true,
47+
}],
48+
49+
"@typescript-eslint/explicit-member-accessibility": "off",
50+
"@typescript-eslint/ban-types": "off",
51+
"@typescript-eslint/no-angle-bracket-type-assertion": "off",
52+
"@typescript-eslint/no-explicit-any": "off",
53+
"@typescript-eslint/no-non-null-assertion": "off",
54+
"@typescript-eslint/no-parameter-properties": "off",
55+
"@typescript-eslint/prefer-interface": "off",
56+
"@typescript-eslint/indent": "off",
57+
},
58+
}, {
59+
files: ["**/*.test.ts", "**/*.spec.ts"],
60+
61+
rules: {
62+
"@typescript-eslint/no-empty-function": "off",
63+
"@typescript-eslint/interface-name-prefix": "off",
64+
},
65+
}]);

package.json

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
{
22
"name": "tsyringe",
3-
"version": "4.9.1",
3+
"version": "5.0.0-alpha.1",
44
"description": "Lightweight dependency injection container for JavaScript/TypeScript",
55
"main": "dist/cjs/index.js",
66
"module": "./dist/esm5/index.js",
77
"es2015": "./dist/esm2015/index.js",
88
"typings": "./dist/typings/index.d.ts",
99
"scripts": {
10-
"build": "yarn clean && yarn build:cjs && yarn build:es5 && yarn build:es2015 && yarn build:types",
10+
"build": "yarn clean && yarn build:cjs && yarn build:es5 && yarn build:es2015 && yarn build:es2020 && yarn build:esnext && yarn build:types",
1111
"build:cjs": "tsc",
1212
"build:es5": "tsc -p ./typescript/tsconfig.esm5.json",
1313
"build:es2015": "tsc -p ./typescript/tsconfig.esm2015.json",
14+
"build:es2020": "tsc -p ./typescript/tsconfig.esm2020.json",
15+
"build:esnext": "tsc -p ./typescript/tsconfig.esmnext.json",
1416
"build:types": "tsc -p ./typescript/tsconfig.types.json",
1517
"clean": "rimraf ./dist",
1618
"test": "yarn lint && jest --config test/jest.config.js",
1719
"test:inspect": "yarn lint && node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --config test/jest.config.js",
1820
"test:coverage": "jest --config test/jest.config.js --coverage",
19-
"lint": "eslint --ext \".js,.jsx,.ts,.tsx\" \"./src\"",
20-
"lint:fix": "eslint --fix --ext \".js,.jsx,.ts,.tsx\" \"./src\""
21+
"lint": "eslint",
22+
"lint:fix": "eslint --fix"
2123
},
2224
"repository": {
2325
"type": "git",
@@ -33,7 +35,7 @@
3335
"typescript"
3436
],
3537
"engines": {
36-
"node": ">= 6.0.0"
38+
"node": ">= 18.0.0"
3739
},
3840
"author": "Steven Hobson-Campbell",
3941
"license": "MIT",
@@ -42,22 +44,23 @@
4244
},
4345
"homepage": "https://github.com/Microsoft/tsyringe#readme",
4446
"dependencies": {
45-
"tslib": "^1.9.3"
47+
"tslib": "^2.8.1"
4648
},
4749
"devDependencies": {
48-
"@types/jest": "^24.0.21",
49-
"@types/node": "^8.10.16",
50-
"@typescript-eslint/eslint-plugin": "^2.6.0",
51-
"@typescript-eslint/parser": "^2.6.0",
52-
"eslint": "^6.6.0",
53-
"eslint-config-prettier": "^6.5.0",
54-
"eslint-plugin-prettier": "^3.1.1",
55-
"husky": "^3.0.0",
56-
"jest": "^24.7.1",
57-
"prettier": "1.18.2",
58-
"reflect-metadata": "^0.1.12",
59-
"rimraf": "^3.0.0",
60-
"ts-jest": "^24.0.2",
61-
"typescript": "^3.1.6"
50+
"@types/istanbul-lib-report": "^3.0.3",
51+
"@types/jest": "^29.5.14",
52+
"@types/node": "^22.14.0",
53+
"@typescript-eslint/eslint-plugin": "^8.29.0",
54+
"@typescript-eslint/parser": "^8.29.0",
55+
"eslint": "^9.24.0",
56+
"eslint-config-prettier": "^10.1.1",
57+
"eslint-plugin-prettier": "^5.2.6",
58+
"husky": "^9.1.7",
59+
"jest": "^29.7.0",
60+
"prettier": "^3.5.3",
61+
"reflect-metadata": "^0.2.2",
62+
"rimraf": "^5.0.10",
63+
"ts-jest": "^29.3.1",
64+
"typescript": "^5.8.3"
6265
}
6366
}

src/__tests__/auto-injectable.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ test("@autoInjectable injects parameters beyond those specified manually", () =>
3636
class FooBar {}
3737
@autoInjectable()
3838
class Foo {
39-
constructor(public myFooBar: FooBar, public myBar?: Bar) {}
39+
constructor(
40+
public myFooBar: FooBar,
41+
public myBar?: Bar
42+
) {}
4043
}
4144

4245
const myFooBar = new FooBar();

src/__tests__/child-container.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
/* eslint-disable @typescript-eslint/interface-name-prefix, @typescript-eslint/no-empty-interface */
2-
31
import {instance as globalContainer} from "../dependency-container";
42

53
afterEach(() => {
64
globalContainer.reset();
75
});
86

97
test("child container resolves even when parent doesn't have registration", () => {
8+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
109
interface IFoo {}
1110
class Foo implements IFoo {}
1211

@@ -19,6 +18,7 @@ test("child container resolves even when parent doesn't have registration", () =
1918
});
2019

2120
test("child container resolves using parent's registration when child container doesn't have registration", () => {
21+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
2222
interface IFoo {}
2323
class Foo implements IFoo {}
2424

@@ -31,6 +31,7 @@ test("child container resolves using parent's registration when child container
3131
});
3232

3333
test("child container resolves all even when parent doesn't have registration", () => {
34+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
3435
interface IFoo {}
3536
class Foo implements IFoo {}
3637

@@ -45,6 +46,7 @@ test("child container resolves all even when parent doesn't have registration",
4546
});
4647

4748
test("child container resolves all using parent's registration when child container doesn't have registration", () => {
49+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
4850
interface IFoo {}
4951
class Foo implements IFoo {}
5052

src/__tests__/disposable.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe("Disposable", () => {
1010

1111
it("returns false when dispose method takes too many args", () => {
1212
const specialDisposable = {
13+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1314
dispose(_: any) {}
1415
};
1516

src/__tests__/errors.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ test("Error message composition", () => {
2121

2222
@injectable()
2323
class A {
24-
constructor(public d: Ok, public b: B) {}
24+
constructor(
25+
public d: Ok,
26+
public b: B
27+
) {}
2528
}
2629

2730
expect(() => {

src/__tests__/global-container.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/interface-name-prefix */
2-
31
import {inject, injectable, registry, singleton} from "../decorators";
42
import {
53
instanceCachingFactory,
@@ -558,7 +556,11 @@ test("dependencies of an @singleton can be resolved", () => {
558556
test("passes through the given params", () => {
559557
@injectable()
560558
class MyViewModel {
561-
constructor(public a: any, public b: any, public c: any) {}
559+
constructor(
560+
public a: any,
561+
public b: any,
562+
public c: any
563+
) {}
562564
}
563565

564566
const a = {};
@@ -936,7 +938,7 @@ describe("dispose", () => {
936938
class Baz implements Disposable {
937939
disposed = false;
938940
async dispose(): Promise<void> {
939-
return new Promise(resolve => {
941+
return new Promise((resolve) => {
940942
process.nextTick(() => {
941943
this.disposed = true;
942944
resolve();

src/__tests__/inject-lazy.tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test("DelayedConstructor delays creation until first usage", () => {
1515
}
1616
const delayedConstructor = delay(() => Foo);
1717
expect(delayedConstructor).toBeInstanceOf(DelayedConstructor);
18-
const foo: Foo = delayedConstructor.createProxy(Target => new Target());
18+
const foo: Foo = delayedConstructor.createProxy((Target) => new Target());
1919
expect(created).toBe(false);
2020
expect(foo).toBeInstanceOf(Foo);
2121
expect(created).toBe(true);

0 commit comments

Comments
 (0)