Repository: electron/electron
File: script/lint.js (JavaScript)

Code before:
    process.exit(result.status || 1);
  }
}

function isObjCHeader (filename) {
  return /\/(mac|cocoa)\//.test(filename);
}

const LINTERS = [{
  key: 'c++',
  roots: ['shell'],
  test: filename => filename.endsWith('.cc') || (filename.endsWith('.h') && !isObjCHeader(filename)),
  run: (opts, filenames) => {
    const chunkedFilenames = chunkFilenames(filenames);

    filenames = chunkedFilenames.shift();

    while (filenames) {
      if (opts.fix) {
        spawnAndCheckExitCode('python', ['script/run-clang-format.py', '--fix', ...filenames]);
      } else {
        spawnAndCheckExitCode('python', ['script/run-clang-format.py', ...filenames]);
      }
      cpplint(filenames);

      filenames = chunkedFilenames.shift();
    }
  }
}, {
  key: 'objc',
  roots: ['shell'],
  test: filename => filename.endsWith('.mm') || (filename.endsWith('.h') && isObjCHeader(filename)),
  run: (opts, filenames) => {
    if (opts.fix) {
      spawnAndCheckExitCode('python', ['script/run-clang-format.py', '--fix', ...filenames]);
    } else {
      spawnAndCheckExitCode('python', ['script/run-clang-format.py', ...filenames]);
    }
    const filter = [
      '-readability/braces',
      '-readability/casting',
      '-whitespace/braces',
      '-whitespace/indent',
      '-whitespace/parens'
    ];
    cpplint(['--extensions=mm,h', `--filter=${filter.join(',')}`, ...filenames]);
  }
}, {
  key: 'python',
  roots: ['script'],
  test: filename => filename.endsWith('.py'),

Review comment (suggestion):
Slightly clearer?

```suggestion
    for (const chunk of chunkFilenames(filenames))
    {
      if (opts.fix) {
        spawnAndCheckExitCode('python', ['script/run-clang-format.py', '--fix', ...chunk]);
      } else {
        spawnAndCheckExitCode('python', ['script/run-clang-format.py', ...chunk]);
      }
      cpplint(filenames);
```

Code after:
    process.exit(result.status || 1);
  }
}

function isObjCHeader (filename) {
  return /\/(mac|cocoa)\//.test(filename);
}

const LINTERS = [{
  key: 'c++',
  roots: ['shell'],
  test: filename => filename.endsWith('.cc') || (filename.endsWith('.h') && !isObjCHeader(filename)),
  run: (opts, filenames) => {
    const clangFormatFlags = opts.fix ? ['--fix'] : [];
    for (const chunk of chunkFilenames(filenames)) {
      spawnAndCheckExitCode('python3', ['script/run-clang-format.py', ...clangFormatFlags, ...chunk]);
      cpplint(chunk);
    }
  }
}, {
  key: 'objc',
  roots: ['shell'],
  test: filename => filename.endsWith('.mm') || (filename.endsWith('.h') && isObjCHeader(filename)),
  run: (opts, filenames) => {
    if (opts.fix) {
      spawnAndCheckExitCode('python3', ['script/run-clang-format.py', '-r', '--fix', ...filenames]);
    } else {
      spawnAndCheckExitCode('python3', ['script/run-clang-format.py', '-r', ...filenames]);
    }
    const filter = [
      '-readability/braces',
      '-readability/casting',
      '-whitespace/braces',
      '-whitespace/indent',
      '-whitespace/parens'
    ];
    cpplint(['--extensions=mm,h', `--filter=${filter.join(',')}`, ...filenames]);
  }
}, {
  key: 'python',
  roots: ['script'],
  test: filename => filename.endsWith('.py'),
  run: (opts, filenames) => {
    const rcfile = path.join(DEPOT_TOOLS, 'pylintrc');
    const args = ['--rcfile=' + rcfile, ...filenames];
    const env = Object.assign({ PYTHONPATH: path.join(ELECTRON_ROOT, 'script') }, process.env);
    spawnAndCheckExitCode('pylint-2.7', args, { env });
  }
}, {
  key: 'javascript',
  roots: ['build', 'default_app', 'lib', 'npm', 'script', 'spec', 'spec-main'],