Skip to content

Commit

Permalink
fix(roc-plugin-repo): Ensure safe ignore-pattern
Browse files Browse the repository at this point in the history
Ensure the ignore-pattern passed to ESLint will only contain
files in the build directory, and not accidentally match any
source files
  • Loading branch information
PAkerstrand committed Oct 19, 2017
1 parent 9f6312f commit d087a78
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions extensions/roc-plugin-repo/src/commands/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import log from 'roc/log/default/small';

const eslint = require.resolve('eslint/bin/eslint');

const eslintCommand = (project, fix, config, output, ignoreFile) =>
`${eslint} ${config}${project.path} --ignore-path '${ignoreFile}' --ignore-pattern '${output}' ${fix
const eslintCommand = (project, fix, config, ignorePattern, ignoreFile) =>
`${eslint} ${config}${project.path} --ignore-path '${ignoreFile}' --ignore-pattern '${ignorePattern}' ${fix
? '--fix'
: ''}`;

Expand Down Expand Up @@ -46,11 +46,19 @@ export default projects => ({

return Promise.all(
selected
.map(project =>
execute(
eslintCommand(project, fix, config, settings.output, ignoreFile),
),
)
.map(project => {
const ignorePattern = path.join(
path.relative(
context.directory,
path.resolve(project.path, settings.output),
),
'*',
);

return execute(
eslintCommand(project, fix, config, ignorePattern, ignoreFile),
);
})
.map(promise => promise.then(() => 0, () => 1)),
).then(results => {
const status = results.reduce((previous, current) =>
Expand Down

0 comments on commit d087a78

Please sign in to comment.