createStylelint.js 748 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const { cosmiconfig } = require('cosmiconfig');
  3. const augmentConfig = require('./augmentConfig');
  4. const FileCache = require('./utils/FileCache');
  5. const IS_TEST = process.env.NODE_ENV === 'test';
  6. const STOP_DIR = IS_TEST ? process.cwd() : undefined;
  7. /**
  8. * @type {import('stylelint')['_createLinter']}
  9. */
  10. module.exports = function createStylelint(options = {}) {
  11. const cwd = options.cwd || process.cwd();
  12. return {
  13. _options: { ...options, cwd },
  14. _extendExplorer: cosmiconfig('', {
  15. transform: augmentConfig.augmentConfigExtended(cwd),
  16. stopDir: STOP_DIR,
  17. }),
  18. _specifiedConfigCache: new Map(),
  19. _postcssResultCache: new Map(),
  20. _fileCache: new FileCache(options.cacheLocation, options.cacheStrategy, cwd),
  21. };
  22. };