Skip to content

Commit ee97a73

Browse files
authored
chore(eslint-plugin-tslint): remove lodash dependency (typescript-eslint#6810)
1 parent 304b551 commit ee97a73

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/eslint-plugin-tslint/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
"typecheck": "tsc -p tsconfig.json --noEmit"
3939
},
4040
"dependencies": {
41-
"@typescript-eslint/utils": "5.57.0",
42-
"lodash": "^4.17.21"
41+
"@typescript-eslint/utils": "5.57.0"
4342
},
4443
"peerDependencies": {
4544
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0",

packages/eslint-plugin-tslint/src/rules/config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
import { ESLintUtils } from '@typescript-eslint/utils';
2-
import memoize from 'lodash/memoize';
32
import type { RuleSeverity } from 'tslint';
43
import { Configuration } from 'tslint';
54

65
import { CustomLinter } from '../custom-linter';
76

7+
function memoize<T extends (...args: never[]) => unknown>(
8+
func: T,
9+
resolver: (...args: Parameters<T>) => string,
10+
): T {
11+
const cache = new Map<string, ReturnType<T>>();
12+
const memoized = function (...args) {
13+
const key = resolver(...(args as Parameters<T>));
14+
15+
if (cache.has(key)) {
16+
return cache.get(key)!;
17+
}
18+
const result = func(...args);
19+
cache.set(key, result as ReturnType<T>);
20+
return result;
21+
} as T;
22+
return memoized;
23+
}
24+
825
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
926
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1027
const version: string = require('../../package.json');

0 commit comments

Comments
 (0)