Skip to content

Instantly share code, notes, and snippets.

@graingert
Created May 8, 2018
Embed
What would you like to do?
eslint.py
import json
with open('./foo.json') as df:
dump = json.load(df)
for f in dump:
fp = f['filePath']
rules = ', '.join(sorted(set(m['ruleId'] for m in f['messages'])))
if not rules:
continue
with open(fp) as rf:
content = rf.read()
with open(fp, 'w') as wf:
wf.write(f'/* eslint-disable {rules} */\n{content}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment