index.js 924 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (c) Microsoft Corporation.
  2. // Licensed under the MIT License.
  3. /**
  4. * @fileoverview ESLint plugin that implements rules intended for static testing during SDL
  5. * @author Antonios Katopodis
  6. */
  7. "use strict";
  8. //------------------------------------------------------------------------------
  9. // Plugin Definition
  10. //------------------------------------------------------------------------------
  11. const path = require("path");
  12. const fs = require('fs');
  13. function readFilesAsMap(relativeDir) {
  14. var absoluteDir = path.resolve(__dirname, relativeDir);
  15. var files = fs.readdirSync(absoluteDir);
  16. var output = {};
  17. files.forEach(filename => {
  18. var file = path.parse(filename);
  19. var obj = require(path.join(absoluteDir, file.base));
  20. output[file.name] = obj;
  21. });
  22. return output;
  23. }
  24. module.exports = {
  25. rules: readFilesAsMap("./rules"),
  26. configs: readFilesAsMap("../config")
  27. }