Enable/Disable mode based on project name

OK, here's why. I like prettier-js, enable it and I don't have to worry about coding style anymore. But my team at work are against using it, so, there's a rule: Not using prettier if it's a company project, but if it's my personal project, so I'll enable it.

The idea is, I'll add a hook to typescript-mode (the mode that I'm using for all of my JS projects), to check whenever the current buffer is coming from a project named <put-my-company-project-here>, if it's not, I'll enable prettier-js-mode.

Here's how it look in action:

(add-hook 'typescript-mode-hook (lambda ()
   (if (and (not (string= (projectile-project-name) "project-at-work-001"))
            (not (string= (projectile-project-name) "project-at-work-002")))
       (prettier-js-mode 1))))

This has a caveat, it will run this check everytime I open a JS/TS file, so it'll has some performance impact. But I'll leave it for now, because it's just work.

Date: 2019-05-16 Thu 00:00

Author: Huy Tran

Created: 2019-05-16 Thu 00:28