Skip to content

Commit

Permalink
chore(eslint-plugin): remove lodash from dependencies (#3478)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jun 20, 2021
1 parent e2e76a7 commit c50f70b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@typescript-eslint/scope-manager": "4.27.0",
"debug": "^4.3.1",
"functional-red-black-tree": "^1.0.1",
"lodash": "^4.17.21",
"regexpp": "^3.1.0",
"semver": "^7.3.5",
"tsutils": "^3.21.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/util/astUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';
import escapeRegExp from 'lodash/escapeRegExp';
import { escapeRegExp } from './escapeRegExp';

// deeply re-export, for convenience
export * from '@typescript-eslint/experimental-utils/dist/ast-utils';
Expand Down
12 changes: 12 additions & 0 deletions packages/eslint-plugin/src/util/escapeRegExp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Lodash <https://lodash.com/>
* Released under MIT license <https://lodash.com/license>
*/
const reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
const reHasRegExpChar = RegExp(reRegExpChar.source);

export function escapeRegExp(string = ''): string {
return string && reHasRegExpChar.test(string)
? string.replace(reRegExpChar, '\\$&')
: string;
}

0 comments on commit c50f70b

Please sign in to comment.