I would like for tern to work only on React related files and Tern to only activate when working on React files with Web Mode turned on. Currently, I have tern generally set up with Web Mode, but the issue is that when I edit, let's say, a php file, Tern activates even though it does not need to. So, I would like for Tern to work in the context of Web Mode when I edit a React file only and NOT when I edit other Web Mode related files. Is this possible? Below is my setup, please assume Company is set up as well.
web mode setup
(use-package web-mode :defer 2 :after (add-node-modules-path) :ensure t :mode ("\\.html?\\'" "/themes/.*\\.php?\\'" "/\\(components\\|containers\\|src\\)/.*\\.js[x]?\\'" "\\.\\(handlebars\\|hbs\\)\\'") :config (progn (setq web-mode-markup-indent-offset 2 web-mode-css-indent-offset 2 web-mode-code-indent-offset 2 web-mode-enable-auto-closing t web-mode-enable-auto-opening t web-mode-enable-auto-pairing t web-mode-enable-auto-indentation t web-mode-enable-auto-quoting t web-mode-enable-current-column-highlight t web-mode-enable-current-element-highlight t web-mode-content-types-alist '(("jsx" . "/\\(components\\|containers\\|src\\)/.*\\.js[x]?\\'")))))
(use-package tern :ensure t :ensure-system-package (tern . "npm i -g tern") :config (add-hook 'js2-mode-hook 'tern-mode) (add-hook 'web-mode-hook 'tern-mode)) (use-package company-tern :requires tern :ensure t :config (add-to-list 'company-backends 'company-tern))