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.

Raspberry Pi local web server for development

July 17, 2017

#Apache #LAMP #Linux #MySQL #PHP #Raspberry Pi #Squid #SSHFS #WordPress

Ideally we never want to be working or testing on a live public-facing installation. But we want our test environment to mimic the actual domain – eg URLs etc. For a while I was using MAMP Pro running under macOS on my development machine. MAMP creates a local Apache/MySQL/PHP stack. Over time however I found this to be a relatively convoluted solution. In particular I found myself having to sometimes solve specific MAMP related issues. Or after a re-installation, I would have to work through how to do set everything up again under MAMP.

A headless Raspberry Pi + LAMP stack running on the local network is a great platform on which to run a local web server for development (it’s important that the Pi is running off a USB stick since constant write cycles would apparently quickly destroy an SD Card). I’m using a Pi 3 connected via wifi. I don’t need to remember a different set of ways of doing stuff – it’s more or less like the actually Linux server environments we work with.

Apache virtual hosting is configured exactly as if the server were on the live internet – with Squid set up such that the Pi also serves as a proxy server. This way all devices on the local network can potentially see the development domains as if they were on the real internet (eg is on the local network during development or testing). Testing or developing under macOS or a desktop Linux, edit /etc/hosts such that points to the local web server address – but on iPads, phones etc this is not trivial – hence the benefit of running a proxy server. Under iOS and Android the proxy settings can be appended to the network connection.

The local webserver is accessed exactly as if it were on the real internet – eg via SSH. Or we can use SSHFS to mount the remote file systems locally – such that the directories and files needed can be browsed locally or opened for editing. Under macOS we can use FUSE.

Visual Studio Code
Visual Studio Code with remote file system mounted via SSHFS using FUSE for macOS

Show All Posts