contentQuotesLinter.js 957 B

123456789101112131415161718
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _utils = require("./utils");
  7. var linter = function linter(key, value, info) {
  8. if (key === 'content') {
  9. // From emotion: https://github.com/emotion-js/emotion/blob/main/packages/serialize/src/index.js#L63
  10. var contentValuePattern = /(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
  11. var contentValues = ['normal', 'none', 'initial', 'inherit', 'unset'];
  12. if (typeof value !== 'string' || contentValues.indexOf(value) === -1 && !contentValuePattern.test(value) && (value.charAt(0) !== value.charAt(value.length - 1) || value.charAt(0) !== '"' && value.charAt(0) !== "'")) {
  13. (0, _utils.lintWarning)("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\"".concat(value, "\"'`."), info);
  14. }
  15. }
  16. };
  17. var _default = exports.default = linter;