createStylelint.cjs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const process = require('node:process');
  5. const cosmiconfig = require('cosmiconfig');
  6. const FileCache = require('./utils/FileCache.cjs');
  7. const augmentConfig = require('./augmentConfig.cjs');
  8. const IS_TEST = process.env.NODE_ENV === 'test';
  9. const STOP_DIR = IS_TEST ? process.cwd() : undefined;
  10. /**
  11. * @type {import('stylelint').PublicApi['_createLinter']}
  12. */
  13. function createStylelint(options = {}) {
  14. if (!options.quietDeprecationWarnings) {
  15. const { emitDeprecationWarning } = require('./utils/emitWarning.cjs');
  16. emitDeprecationWarning(
  17. 'The CommonJS Node.js API is deprecated.',
  18. 'COMMONJS_NODEJS_API',
  19. 'See https://stylelint.io/migration-guide/to-16',
  20. );
  21. }
  22. const cwd = options.cwd || process.cwd();
  23. return {
  24. _options: { ...options, cwd },
  25. _extendExplorer: cosmiconfig.cosmiconfig('', {
  26. transform: augmentConfig.augmentConfigExtended(cwd),
  27. stopDir: STOP_DIR,
  28. searchStrategy: 'global', // for backward compatibility
  29. }),
  30. _specifiedConfigCache: new Map(),
  31. _postcssResultCache: new Map(),
  32. _fileCache: new FileCache(options.cacheLocation, options.cacheStrategy, cwd),
  33. };
  34. }
  35. module.exports = createStylelint;