1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-18 20:11:17 +00:00

proof of concept

This commit is contained in:
nopeless 2022-08-26 23:36:16 -05:00
parent f9768cf929
commit 3536fad3d9

29
thefuck/rules/eslint.py Normal file
View File

@ -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