From 3536fad3d92918475c947ecb8ba6dd1f1b10350a Mon Sep 17 00:00:00 2001 From: nopeless <38830903+nopeless@users.noreply.github.com> Date: Fri, 26 Aug 2022 23:36:16 -0500 Subject: [PATCH] proof of concept --- thefuck/rules/eslint.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 thefuck/rules/eslint.py diff --git a/thefuck/rules/eslint.py b/thefuck/rules/eslint.py new file mode 100644 index 00000000..2410f158 --- /dev/null +++ b/thefuck/rules/eslint.py @@ -0,0 +1,29 @@ +import re, os +from thefuck.utils import replace_argument, for_app + + +def match(command): + return 'ESLint couldn\'t find the plugin' in command.output + +ex = os.path.exists + +eslint_regex = re.compile("ESLint couldn't find the plugin \"([^\"]+)\"") + +def get_node_package_manager_install_dev(): + if ex("yarn.lock"): + return "yarn add --dev" + return "npm i -D" + + +def get_new_command(command): + package = eslint_regex.search(command.output).group(1) + + if not package: + return None + + npm = get_node_package_manager_install_dev() + + if not npm: + return None + + return npm + " " + package