exabugs / WebIDE

0 stars 0 forks source link

Python の Lint を追加する #6

Closed exabugs closed 6 years ago

exabugs commented 6 years ago
pip install hacking

@see: https://qiita.com/kitsuyui/items/5ab4608003a29ff7689f

function lint_python({ fp }, callback) {
  const bin = 'flake8';
  const command = [bin, fp];
  exec(command.join(' '), (err, buff = '') => {
    const reports = buff.split('\n');
    const data = reports.reduce((memo, line) => {
      const info = line.match(/[^:]+:(\d+):(\d+): (.+)/);
      if (info) {
        const [b, l, p, message] = info;
        memo.push({
          from: Pos(l, p),
          to: Pos(l, p + 1),
          message,
          severity: 'warning',
        });
      }
      return memo;
    }, []);
    callback(err, data);
  });
}