const path = require('path');

const buildEslintCommand = (filenames) => {
  // Added --fix flag to automatically fix errors that can be fixed by ESLint
  return `next lint --file ${filenames
    .map((f) => path.relative(process.cwd(), f))
    .join(' --file ')} --fix`;
};

module.exports = {
  '**/*.(ts|tsx)': () => 'yarn tsc --noEmit',
  '*.{js,jsx,ts,tsx}': [buildEslintCommand]
};
