Skip to content

Instantly share code, notes, and snippets.

@graingert
Created May 8, 2018 13:09
Show Gist options
  • Select an option

  • Save graingert/6f8732e1ff8b60c98b5173e8b16963fe to your computer and use it in GitHub Desktop.

Select an option

Save graingert/6f8732e1ff8b60c98b5173e8b16963fe to your computer and use it in GitHub Desktop.
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