sql-lint.js 959 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. CodeMirror.sqlLint = function (text, updateLinting, options, cm) {
  3. // Skipping check if text box is empty.
  4. if (text.trim() === '') {
  5. updateLinting(cm, []);
  6. return;
  7. }
  8. function handleResponse(response) {
  9. var found = [];
  10. for (var idx in response) {
  11. found.push({
  12. // eslint-disable-next-line new-cap
  13. from: CodeMirror.Pos(response[idx].fromLine, response[idx].fromColumn),
  14. // eslint-disable-next-line new-cap
  15. to: CodeMirror.Pos(response[idx].toLine, response[idx].toColumn),
  16. messageHTML: response[idx].message,
  17. severity: response[idx].severity
  18. });
  19. }
  20. updateLinting(cm, found);
  21. }
  22. $.ajax({
  23. method: 'POST',
  24. url: 'index.php?route=/lint',
  25. dataType: 'json',
  26. data: {
  27. 'sql_query': text,
  28. 'server': CommonParams.get('server'),
  29. 'options': options.lintOptions,
  30. 'no_history': true
  31. },
  32. success: handleResponse
  33. });
  34. };