Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

createStylelint.js 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict';
  2. const _ = require('lodash');
  3. const augmentConfig = require('./augmentConfig');
  4. const createStylelintResult = require('./createStylelintResult');
  5. const getConfigForFile = require('./getConfigForFile');
  6. const getPostcssResult = require('./getPostcssResult');
  7. const isPathIgnored = require('./isPathIgnored');
  8. const lintSource = require('./lintSource');
  9. const path = require('path');
  10. const { cosmiconfig } = require('cosmiconfig');
  11. const IS_TEST = process.env.NODE_ENV === 'test';
  12. const STOP_DIR = IS_TEST ? path.resolve(__dirname, '..') : undefined;
  13. /** @typedef {import('stylelint').StylelintInternalApi} StylelintInternalApi */
  14. /**
  15. * The stylelint "internal API" is passed among functions
  16. * so that methods on a stylelint instance can invoke
  17. * each other while sharing options and caches
  18. * @param {import('stylelint').StylelintStandaloneOptions} options
  19. * @returns {StylelintInternalApi}
  20. */
  21. module.exports = function (options = {}) {
  22. /** @type {Partial<StylelintInternalApi>} */
  23. const stylelint = { _options: options };
  24. options.configOverrides = options.configOverrides || {};
  25. if (options.ignoreDisables) {
  26. options.configOverrides.ignoreDisables = options.ignoreDisables;
  27. }
  28. if (options.reportNeedlessDisables) {
  29. options.configOverrides.reportNeedlessDisables = options.reportNeedlessDisables;
  30. }
  31. if (options.reportInvalidScopeDisables) {
  32. options.configOverrides.reportInvalidScopeDisables = options.reportInvalidScopeDisables;
  33. }
  34. if (options.reportDescriptionlessDisables) {
  35. options.configOverrides.reportDescriptionlessDisables = options.reportDescriptionlessDisables;
  36. }
  37. // Two separate explorers so they can each have their own transform
  38. // function whose results are cached by cosmiconfig
  39. stylelint._fullExplorer = cosmiconfig('stylelint', {
  40. // @ts-ignore TODO TYPES found out which cosmiconfig types are valid
  41. transform: _.partial(
  42. augmentConfig.augmentConfigFull,
  43. /** @type{StylelintInternalApi} */ (stylelint),
  44. ),
  45. stopDir: STOP_DIR,
  46. });
  47. // @ts-ignore TODO TYPES found out which cosmiconfig types are valid
  48. stylelint._extendExplorer = cosmiconfig(null, {
  49. transform: _.partial(
  50. augmentConfig.augmentConfigExtended,
  51. /** @type{StylelintInternalApi} */ (stylelint),
  52. ),
  53. stopDir: STOP_DIR,
  54. });
  55. stylelint._specifiedConfigCache = new Map();
  56. stylelint._postcssResultCache = new Map();
  57. stylelint._createStylelintResult = _.partial(
  58. createStylelintResult,
  59. /** @type{StylelintInternalApi} */ (stylelint),
  60. );
  61. stylelint._getPostcssResult = _.partial(
  62. getPostcssResult,
  63. /** @type{StylelintInternalApi} */ (stylelint),
  64. );
  65. stylelint._lintSource = _.partial(lintSource, /** @type{StylelintInternalApi} */ (stylelint));
  66. stylelint.getConfigForFile = _.partial(
  67. getConfigForFile,
  68. /** @type{StylelintInternalApi} */ (stylelint),
  69. );
  70. stylelint.isPathIgnored = _.partial(
  71. isPathIgnored,
  72. /** @type{StylelintInternalApi} */ (stylelint),
  73. );
  74. return /** @type{StylelintInternalApi} */ (stylelint);
  75. };