normalizeFixMode.mjs 513 B

12345678910111213141516171819202122
  1. import { DEFAULT_FIX_MODE } from '../constants.mjs';
  2. /** @import { FixMode } from 'stylelint' */
  3. /**
  4. * Normalize the fix mode based on options and configuration.
  5. * If the input is unknown, this returns `undefined`.
  6. *
  7. * @param {unknown} fix
  8. * @returns {FixMode | undefined}
  9. */
  10. export default function normalizeFixMode(fix) {
  11. if (fix === true || fix === 'true' || fix === '' || fix === DEFAULT_FIX_MODE) {
  12. return DEFAULT_FIX_MODE;
  13. }
  14. if (fix === 'strict') {
  15. return 'strict';
  16. }
  17. return undefined;
  18. }