Skip to content

Commit

Permalink
feat: support opts for lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mj-hd committed Nov 8, 2019
1 parent dbcd202 commit c1cb555
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion run.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,27 @@ function getHistoryCommits(from, to) {
})
}

function getOptsFromConfig(config) {
return {
parserOpts:
config.parserPreset != null && config.parserPreset.parserOpts != null
? config.parserPreset.parserOpts
: {},
plugins: config.plugins != null ? config.plugins : {},
ignores: config.ignores != null ? config.ignores : [],
defaultIgnores:
config.defaultIgnores != null ? config.defaultIgnores : true,
}
}

const showLintResults = async ([from, to]) => {
const commits = await getHistoryCommits(from, to)
const config = existsSync(configPath)
? await load({}, { file: configPath })
: {}
const opts = getOptsFromConfig(config)
const results = await Promise.all(
commits.map(commit => lint(commit, config.rules)),
commits.map(commit => lint(commit, config.rules, opts)),
)
const formattedResults = format(
{ results },
Expand Down

0 comments on commit c1cb555

Please sign in to comment.