Dev Environment

April 9, 2018

#ESLint #Git #node.js #Raspberry Pi #Samba #Ubuntu #VirtualBox #Visual Studio Code

So previously I was using a Raspberry Pi running LAMP as a development server over a LAN. Editing /etc/hosts to access virtual domains as if they were live online. That was a great solution which I took for granted until I needed to take it on the road – I only realised how Heath Robinson it was when I found myself plugging it in at Starbucks.

So I knew I wanted a virtualised solution – to be able to run a LAMP with virtual hosting on my MacBook (or Linux laptop if I switch at some point) and to be able to access that as if it were networked like the Pi. Also to be able to simply backup / clone the entire installation. It’s important to me that it runs the same environment as the live server – that’s why I don’t just run Apache on localhost. Anyhow it’s much nicer keeping everything contained.

Before the Pi I had been using MAMP / MAMP Pro. But I found that way over – complicated … and sometimes unaccountably flaky. It’s too packaged. And it seemed too much locked into particular versions, upgrade cycles etc. Really I just want to be running the same versions of Ubuntu server + packages as I am using live. Things which try to make things easier always end up needing troubleshooting in my experience. I don’t want to have to know about about MAMP when it goes wrong – or figure out what it has installed on my machine. It’s just another thing to have to know about.

Someone suggested VVV. So I had a look at that. Many of the same issues as MAMP I reckon. And I read a thread at Github full of reasons why upgrading VVV to the latest LTS version of Ubuntu server wasn’t an option. Too many dependencies apparently. Ugh.

In the end the simplest solution was the obvious solution. So now I’m running Ubuntu server via VirtualBox and accessing it as if it were on my local network. Same as I was doing with the Pi. I can start it up headless from the macOS command line and it boots in about 20 secs. Then I log in via SSH. And I’m running Samba on the client with /var/www shared so that I can edit files using Visual Studio Code on my host. Obviously that would be a security issue if it were a real server – but in a sandboxed environment it’s fine. I’ve also installed Git, Node, ESLint.

Actually I suppose the simpler solution would be to just run Linux native. And I wonder how Apple switching away from x86 would impact my current solution.

Validating JavaScript using ESLint in Visual Studio Code

February 9, 2018

#ESLint #JavaScript #jQuery #JSLint #node.js #SSHFS #Visual Studio Code

ESLint / Visual Studio Code
ESLint highlighting sloppy code

I switched to Microsoft Visual Studio Code originally because Brackets seemed to struggle with remote file systems mounted using via SSHFS (using Fuse for macOS).

Brackets has JSLint built in. Various JavaScript linting options exist for Visual Studio Code. I’m using ESLint and this extension which integrates ESLint into VSCode.

ESLint requires node.js & npm. Install node.js locally using the pkg. The npm package manager is installed as part of that. We then use npm to install ESLint globally (sudo npm install -g eslint).

Then run eslint --init from the root directory of any project where you want to use ESLint to validate the code. That will create a project specific configuration file.

Show All Posts