Skip to content

Instantly share code, notes, and snippets.

@blech
Last active February 13, 2019 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blech/6134afe2c00efc28b60dd22ed9c41a1a to your computer and use it in GitHub Desktop.
Save blech/6134afe2c00efc28b60dd22ed9c41a1a to your computer and use it in GitHub Desktop.
BBEdit script to run `eslint --fix` on the current file
#!/usr/bin/env python3
import os
import sys
from copy import copy
from subprocess import run
from warnings import warn
doc_location = os.environ.get('BB_DOC_PATH', None)
if not doc_location.endswith('.js'):
sys.exit(0)
# extract path to project root
offset = doc_location.find('packages')
project_location = doc_location[0:offset]
# eslint lives at ./node_modules/eslint/bin/eslint.js
resp = run(
[
f"{project_location}node_modules/eslint/bin/eslint.js",
"--fix",
doc_location,
],
capture_output=True
)
sys.exit(resp.returncode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment