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.

index.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // @ts-nocheck
  2. 'use strict';
  3. const report = require('../../utils/report');
  4. const ruleMessages = require('../../utils/ruleMessages');
  5. const validateOptions = require('../../utils/validateOptions');
  6. const ruleName = 'unicode-bom';
  7. const messages = ruleMessages(ruleName, {
  8. expected: 'Expected Unicode BOM',
  9. rejected: 'Unexpected Unicode BOM',
  10. });
  11. function rule(expectation) {
  12. return (root, result) => {
  13. const validOptions = validateOptions(result, ruleName, {
  14. actual: expectation,
  15. possible: ['always', 'never'],
  16. });
  17. if (
  18. !validOptions ||
  19. root.source.inline ||
  20. root.source.lang === 'object-literal' ||
  21. // Ignore HTML documents
  22. root.document !== undefined
  23. ) {
  24. return;
  25. }
  26. const { hasBOM } = root.source.input;
  27. if (expectation === 'always' && !hasBOM) {
  28. report({
  29. result,
  30. ruleName,
  31. message: messages.expected,
  32. root,
  33. line: 1,
  34. });
  35. }
  36. if (expectation === 'never' && hasBOM) {
  37. report({
  38. result,
  39. ruleName,
  40. message: messages.rejected,
  41. root,
  42. line: 1,
  43. });
  44. }
  45. };
  46. }
  47. rule.ruleName = ruleName;
  48. rule.messages = messages;
  49. module.exports = rule;