Last active
October 20, 2016 01:52
-
-
Save sumyapp/c93073903ac7f682d5e8238834e27299 to your computer and use it in GitHub Desktop.
ESLintの出力JSONファイルを読み込み、指摘が1件以上あるルールを発見し、設定ファイルとして出力する。指摘件数はJSONコメントで記載される
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
input_file = 'eslint_result.json' | |
output_file = 'eslint_todo.json' | |
array = JSON.parse open(input_file, &:read) | |
rules_counts = {} | |
array.each do |file| | |
next if file['errorCount'] == 0 && file['warningCount'] == 0 | |
file['messages'].each do |message| | |
rules_counts[message['ruleId']] = 0 unless rules_counts[message['ruleId']] | |
rules_counts[message['ruleId']] += 1 | |
end | |
end | |
results = rules_counts.sort_by { |_, v| -v } | |
File.open(output_file, 'w') do |f| | |
f.puts('{') | |
f.puts(' "rules" : {') | |
results.each { |rule, c| f.puts(" \"#{rule}\" : 0, // #{c} issues found") } | |
f.puts(' }') | |
f.puts('}') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment