structured.lint 894 B

12345678910111213141516171819202122232425262728
  1. # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. def lint(files, logger, **kwargs):
  6. for path in files:
  7. with open(path, 'r') as fh:
  8. for i, line in enumerate(fh.readlines()):
  9. if 'foobar' in line:
  10. logger.lint_error(path=path,
  11. lineno=i+1,
  12. column=1,
  13. rule="no-foobar")
  14. LINTER = {
  15. 'name': "StructuredLinter",
  16. 'description': "It's bad to have the string foobar in js files.",
  17. 'include': [
  18. 'files',
  19. ],
  20. 'type': 'structured_log',
  21. 'extensions': ['.js', '.jsm'],
  22. 'payload': lint,
  23. }