properties.mjs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. /** @type {ReadonlySet<string>} */
  2. export const acceptCustomIdentsProperties = new Set([
  3. 'animation',
  4. 'animation-name',
  5. 'font',
  6. 'font-family',
  7. 'counter-increment',
  8. 'grid-row',
  9. 'grid-column',
  10. 'grid-area',
  11. 'list-style',
  12. 'list-style-type',
  13. ]);
  14. /** @type {ReadonlyMap<string, ReadonlySet<string>>} */
  15. export const shorthandToResetToInitialProperty = new Map([
  16. [
  17. 'border',
  18. new Set([
  19. 'border-image',
  20. 'border-image-outset',
  21. 'border-image-repeat',
  22. 'border-image-slice',
  23. 'border-image-source',
  24. 'border-image-width',
  25. ]),
  26. ],
  27. [
  28. /** @see https://www.w3.org/TR/css-fonts-4/#font-prop */
  29. 'font',
  30. new Set([
  31. // prettier-ignore
  32. 'font-feature-settings',
  33. 'font-kerning',
  34. 'font-language-override',
  35. 'font-optical-sizing',
  36. 'font-size-adjust',
  37. 'font-variant-alternates',
  38. 'font-variant-caps',
  39. 'font-variant-east-asian',
  40. 'font-variant-emoji',
  41. 'font-variant-ligatures',
  42. 'font-variant-numeric',
  43. 'font-variant-position',
  44. 'font-variation-settings',
  45. ]),
  46. ],
  47. ]);
  48. /** @type {import('stylelint').LonghandSubPropertiesOfShorthandProperties} */
  49. export const longhandSubPropertiesOfShorthandProperties = new Map([
  50. // Sort alphabetically
  51. [
  52. 'animation',
  53. new Set([
  54. // prettier-ignore
  55. 'animation-name',
  56. 'animation-duration',
  57. 'animation-timing-function',
  58. 'animation-delay',
  59. 'animation-iteration-count',
  60. 'animation-direction',
  61. 'animation-fill-mode',
  62. 'animation-play-state',
  63. ]),
  64. ],
  65. [
  66. 'background',
  67. new Set([
  68. // prettier-ignore
  69. 'background-image',
  70. 'background-size',
  71. 'background-position',
  72. 'background-repeat',
  73. 'background-origin',
  74. 'background-clip',
  75. 'background-attachment',
  76. 'background-color',
  77. ]),
  78. ],
  79. [
  80. 'border',
  81. new Set([
  82. // prettier-ignore
  83. 'border-top-width',
  84. 'border-right-width',
  85. 'border-bottom-width',
  86. 'border-left-width',
  87. 'border-top-style',
  88. 'border-right-style',
  89. 'border-bottom-style',
  90. 'border-left-style',
  91. 'border-top-color',
  92. 'border-right-color',
  93. 'border-bottom-color',
  94. 'border-left-color',
  95. 'border-width',
  96. 'border-style',
  97. 'border-color',
  98. ]),
  99. ],
  100. [
  101. 'border-block',
  102. new Set([
  103. // prettier-ignore
  104. 'border-block-width',
  105. 'border-block-style',
  106. 'border-block-color',
  107. ]),
  108. ],
  109. [
  110. 'border-block-end',
  111. new Set([
  112. // prettier-ignore
  113. 'border-block-end-width',
  114. 'border-block-end-style',
  115. 'border-block-end-color',
  116. ]),
  117. ],
  118. [
  119. 'border-block-start',
  120. new Set([
  121. // prettier-ignore
  122. 'border-block-start-width',
  123. 'border-block-start-style',
  124. 'border-block-start-color',
  125. ]),
  126. ],
  127. [
  128. 'border-bottom',
  129. new Set([
  130. // prettier-ignore
  131. 'border-bottom-width',
  132. 'border-bottom-style',
  133. 'border-bottom-color',
  134. ]),
  135. ],
  136. [
  137. 'border-color',
  138. new Set([
  139. // prettier-ignore
  140. 'border-top-color',
  141. 'border-right-color',
  142. 'border-bottom-color',
  143. 'border-left-color',
  144. ]),
  145. ],
  146. [
  147. 'border-image',
  148. new Set([
  149. // prettier-ignore
  150. 'border-image-source',
  151. 'border-image-slice',
  152. 'border-image-width',
  153. 'border-image-outset',
  154. 'border-image-repeat',
  155. ]),
  156. ],
  157. [
  158. 'border-inline',
  159. new Set([
  160. // prettier-ignore
  161. 'border-inline-width',
  162. 'border-inline-style',
  163. 'border-inline-color',
  164. ]),
  165. ],
  166. [
  167. 'border-inline-end',
  168. new Set([
  169. // prettier-ignore
  170. 'border-inline-end-width',
  171. 'border-inline-end-style',
  172. 'border-inline-end-color',
  173. ]),
  174. ],
  175. [
  176. 'border-inline-start',
  177. new Set([
  178. // prettier-ignore
  179. 'border-inline-start-width',
  180. 'border-inline-start-style',
  181. 'border-inline-start-color',
  182. ]),
  183. ],
  184. [
  185. 'border-left',
  186. new Set([
  187. // prettier-ignore
  188. 'border-left-width',
  189. 'border-left-style',
  190. 'border-left-color',
  191. ]),
  192. ],
  193. [
  194. 'border-radius',
  195. new Set([
  196. // prettier-ignore
  197. 'border-top-left-radius',
  198. 'border-top-right-radius',
  199. 'border-bottom-right-radius',
  200. 'border-bottom-left-radius',
  201. ]),
  202. ],
  203. [
  204. 'border-right',
  205. new Set([
  206. // prettier-ignore
  207. 'border-right-width',
  208. 'border-right-style',
  209. 'border-right-color',
  210. ]),
  211. ],
  212. [
  213. 'border-style',
  214. new Set([
  215. // prettier-ignore
  216. 'border-top-style',
  217. 'border-right-style',
  218. 'border-bottom-style',
  219. 'border-left-style',
  220. ]),
  221. ],
  222. [
  223. 'border-top',
  224. new Set([
  225. // prettier-ignore
  226. 'border-top-width',
  227. 'border-top-style',
  228. 'border-top-color',
  229. ]),
  230. ],
  231. [
  232. 'border-width',
  233. new Set([
  234. // prettier-ignore
  235. 'border-top-width',
  236. 'border-right-width',
  237. 'border-bottom-width',
  238. 'border-left-width',
  239. ]),
  240. ],
  241. [
  242. 'column-rule',
  243. new Set([
  244. // prettier-ignore
  245. 'column-rule-width',
  246. 'column-rule-style',
  247. 'column-rule-color',
  248. ]),
  249. ],
  250. [
  251. 'columns',
  252. new Set([
  253. // prettier-ignore
  254. 'column-width',
  255. 'column-count',
  256. ]),
  257. ],
  258. [
  259. 'flex',
  260. new Set([
  261. // prettier-ignore
  262. 'flex-grow',
  263. 'flex-shrink',
  264. 'flex-basis',
  265. ]),
  266. ],
  267. [
  268. 'flex-flow',
  269. new Set([
  270. // prettier-ignore
  271. 'flex-direction',
  272. 'flex-wrap',
  273. ]),
  274. ],
  275. [
  276. 'font',
  277. new Set([
  278. // prettier-ignore
  279. 'font-style',
  280. /**
  281. * reset explicitly: normal | small-caps
  282. * reset implicitly: all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps
  283. * i.e. either way it will be reset
  284. * {@link https://www.w3.org/TR/css-fonts-4/#font-variant-prop World Wide Web Consortium}
  285. */
  286. 'font-variant',
  287. 'font-weight',
  288. 'font-stretch',
  289. 'font-size',
  290. 'line-height',
  291. 'font-family',
  292. ]),
  293. ],
  294. [
  295. 'font-synthesis',
  296. new Set([
  297. // prettier-ignore
  298. 'font-synthesis-weight',
  299. 'font-synthesis-style',
  300. 'font-synthesis-small-caps',
  301. ]),
  302. ],
  303. [
  304. 'font-variant',
  305. new Set([
  306. // prettier-ignore
  307. 'font-variant-ligatures',
  308. 'font-variant-position',
  309. 'font-variant-caps',
  310. 'font-variant-numeric',
  311. 'font-variant-alternates',
  312. 'font-variant-east-asian',
  313. 'font-variant-emoji',
  314. ]),
  315. ],
  316. [
  317. 'gap',
  318. new Set([
  319. // prettier-ignore
  320. 'row-gap',
  321. 'column-gap',
  322. ]),
  323. ],
  324. [
  325. 'grid',
  326. new Set([
  327. // prettier-ignore
  328. 'grid-template-rows',
  329. 'grid-template-columns',
  330. 'grid-template-areas',
  331. 'grid-auto-rows',
  332. 'grid-auto-columns',
  333. 'grid-auto-flow',
  334. 'grid-column-gap',
  335. 'grid-row-gap',
  336. ]),
  337. ],
  338. [
  339. 'grid-area',
  340. new Set([
  341. // prettier-ignore
  342. 'grid-row-start',
  343. 'grid-column-start',
  344. 'grid-row-end',
  345. 'grid-column-end',
  346. ]),
  347. ],
  348. [
  349. 'grid-column',
  350. new Set([
  351. // prettier-ignore
  352. 'grid-column-start',
  353. 'grid-column-end',
  354. ]),
  355. ],
  356. [
  357. 'grid-gap',
  358. new Set([
  359. // prettier-ignore
  360. 'grid-row-gap',
  361. 'grid-column-gap',
  362. ]),
  363. ],
  364. [
  365. 'grid-row',
  366. new Set([
  367. // prettier-ignore
  368. 'grid-row-start',
  369. 'grid-row-end',
  370. ]),
  371. ],
  372. [
  373. 'grid-template',
  374. new Set([
  375. // prettier-ignore
  376. 'grid-template-columns',
  377. 'grid-template-rows',
  378. 'grid-template-areas',
  379. ]),
  380. ],
  381. [
  382. 'inset',
  383. new Set([
  384. // prettier-ignore
  385. 'top',
  386. 'right',
  387. 'bottom',
  388. 'left',
  389. ]),
  390. ],
  391. [
  392. 'inset-block',
  393. new Set([
  394. // prettier-ignore
  395. 'inset-block-start',
  396. 'inset-block-end',
  397. ]),
  398. ],
  399. [
  400. 'inset-inline',
  401. new Set([
  402. // prettier-ignore
  403. 'inset-inline-start',
  404. 'inset-inline-end',
  405. ]),
  406. ],
  407. [
  408. 'list-style',
  409. new Set([
  410. // prettier-ignore
  411. 'list-style-type',
  412. 'list-style-position',
  413. 'list-style-image',
  414. ]),
  415. ],
  416. [
  417. 'margin',
  418. new Set([
  419. // prettier-ignore
  420. 'margin-top',
  421. 'margin-right',
  422. 'margin-bottom',
  423. 'margin-left',
  424. ]),
  425. ],
  426. [
  427. 'margin-block',
  428. new Set([
  429. // prettier-ignore
  430. 'margin-block-start',
  431. 'margin-block-end',
  432. ]),
  433. ],
  434. [
  435. 'margin-inline',
  436. new Set([
  437. // prettier-ignore
  438. 'margin-inline-start',
  439. 'margin-inline-end',
  440. ]),
  441. ],
  442. [
  443. 'mask',
  444. new Set([
  445. // prettier-ignore
  446. 'mask-image',
  447. 'mask-mode',
  448. 'mask-position',
  449. 'mask-size',
  450. 'mask-repeat',
  451. 'mask-origin',
  452. 'mask-clip',
  453. 'mask-composite',
  454. ]),
  455. ],
  456. [
  457. 'outline',
  458. new Set([
  459. // prettier-ignore
  460. 'outline-color',
  461. 'outline-style',
  462. 'outline-width',
  463. ]),
  464. ],
  465. [
  466. 'overflow',
  467. new Set([
  468. // prettier-ignore
  469. 'overflow-x',
  470. 'overflow-y',
  471. ]),
  472. ],
  473. [
  474. 'overscroll-behavior',
  475. new Set([
  476. // prettier-ignore
  477. 'overscroll-behavior-x',
  478. 'overscroll-behavior-y',
  479. ]),
  480. ],
  481. [
  482. 'padding',
  483. new Set([
  484. // prettier-ignore
  485. 'padding-top',
  486. 'padding-right',
  487. 'padding-bottom',
  488. 'padding-left',
  489. ]),
  490. ],
  491. [
  492. 'padding-block',
  493. new Set([
  494. // prettier-ignore
  495. 'padding-block-start',
  496. 'padding-block-end',
  497. ]),
  498. ],
  499. [
  500. 'padding-inline',
  501. new Set([
  502. // prettier-ignore
  503. 'padding-inline-start',
  504. 'padding-inline-end',
  505. ]),
  506. ],
  507. [
  508. 'place-content',
  509. new Set([
  510. // prettier-ignore
  511. 'align-content',
  512. 'justify-content',
  513. ]),
  514. ],
  515. [
  516. 'place-items',
  517. new Set([
  518. // prettier-ignore
  519. 'align-items',
  520. 'justify-items',
  521. ]),
  522. ],
  523. [
  524. 'place-self',
  525. new Set([
  526. // prettier-ignore
  527. 'align-self',
  528. 'justify-self',
  529. ]),
  530. ],
  531. [
  532. 'scroll-margin',
  533. new Set([
  534. // prettier-ignore
  535. 'scroll-margin-top',
  536. 'scroll-margin-right',
  537. 'scroll-margin-bottom',
  538. 'scroll-margin-left',
  539. ]),
  540. ],
  541. [
  542. 'scroll-margin-block',
  543. new Set([
  544. // prettier-ignore
  545. 'scroll-margin-block-start',
  546. 'scroll-margin-block-end',
  547. ]),
  548. ],
  549. [
  550. 'scroll-margin-inline',
  551. new Set([
  552. // prettier-ignore
  553. 'scroll-margin-inline-start',
  554. 'scroll-margin-inline-end',
  555. ]),
  556. ],
  557. [
  558. 'scroll-padding',
  559. new Set([
  560. // prettier-ignore
  561. 'scroll-padding-top',
  562. 'scroll-padding-right',
  563. 'scroll-padding-bottom',
  564. 'scroll-padding-left',
  565. ]),
  566. ],
  567. [
  568. 'scroll-padding-block',
  569. new Set([
  570. // prettier-ignore
  571. 'scroll-padding-block-start',
  572. 'scroll-padding-block-end',
  573. ]),
  574. ],
  575. [
  576. 'scroll-padding-inline',
  577. new Set([
  578. // prettier-ignore
  579. 'scroll-padding-inline-start',
  580. 'scroll-padding-inline-end',
  581. ]),
  582. ],
  583. [
  584. 'text-decoration',
  585. new Set([
  586. // prettier-ignore
  587. 'text-decoration-line',
  588. 'text-decoration-style',
  589. 'text-decoration-color',
  590. 'text-decoration-thickness',
  591. ]),
  592. ],
  593. [
  594. 'text-emphasis',
  595. new Set([
  596. // prettier-ignore
  597. 'text-emphasis-style',
  598. 'text-emphasis-color',
  599. ]),
  600. ],
  601. [
  602. 'transition',
  603. new Set([
  604. // prettier-ignore
  605. 'transition-property',
  606. 'transition-duration',
  607. 'transition-timing-function',
  608. 'transition-delay',
  609. ]),
  610. ],
  611. ]);
  612. /** @type {ReadonlySet<string>} */
  613. export const singleValueColorProperties = new Set([
  614. 'accent-color',
  615. 'background-color',
  616. 'border-block-color',
  617. 'border-block-end-color',
  618. 'border-block-start-color',
  619. 'border-bottom-color',
  620. 'border-inline-color',
  621. 'border-inline-end-color',
  622. 'border-inline-start-color',
  623. 'border-left-color',
  624. 'border-right-color',
  625. 'border-top-color',
  626. 'caret-color',
  627. 'color',
  628. 'column-rule-color',
  629. 'outline-color',
  630. 'text-decoration-color',
  631. 'text-emphasis-color',
  632. // SVG
  633. 'flood-color',
  634. 'lighting-color',
  635. 'stop-color',
  636. ]);
  637. /** @type {ReadonlySet<string>} */
  638. export const multiValueColorProperties = new Set(['border-color', 'scrollbar-color']);
  639. /** @type {ReadonlySet<string>} */
  640. export const colorProperties = new Set([
  641. ...singleValueColorProperties,
  642. ...multiValueColorProperties,
  643. ]);
  644. /** @type {ReadonlySet<string>} */
  645. export const longhandTimeProperties = new Set([
  646. 'transition-duration',
  647. 'transition-delay',
  648. 'animation-duration',
  649. 'animation-delay',
  650. ]);
  651. /** @type {ReadonlySet<string>} */
  652. export const shorthandTimeProperties = new Set(['transition', 'animation']);
  653. /** @type {ReadonlySet<string>} */
  654. export const pageContextProperties = new Set([
  655. 'direction',
  656. 'background-color',
  657. 'background-image',
  658. 'background-repeat',
  659. 'background-attachment',
  660. 'background-position',
  661. 'background',
  662. 'border-top-width',
  663. 'border-right-width',
  664. 'border-bottom-width',
  665. 'border-left-width',
  666. 'border-width',
  667. 'border-top-color',
  668. 'border-right-color',
  669. 'border-bottom-color',
  670. 'border-left-color',
  671. 'border-color',
  672. 'border-top-style',
  673. 'border-right-style',
  674. 'border-bottom-style',
  675. 'border-left-style',
  676. 'border-style',
  677. 'border-top',
  678. 'border-right',
  679. 'border-bottom',
  680. 'border-left',
  681. 'border',
  682. 'counter-reset',
  683. 'counter-increment',
  684. 'color',
  685. 'font-family',
  686. 'font-size',
  687. 'font-style',
  688. 'font-variant',
  689. 'font-weight',
  690. 'font',
  691. 'height',
  692. 'min-height',
  693. 'max-height',
  694. 'line-height',
  695. 'margin-top',
  696. 'margin-right',
  697. 'margin-bottom',
  698. 'margin-left',
  699. 'margin',
  700. 'outline-width',
  701. 'outline-style',
  702. 'outline-color',
  703. 'outline',
  704. 'padding-top',
  705. 'padding-right',
  706. 'padding-bottom',
  707. 'padding-left',
  708. 'padding',
  709. 'quotes',
  710. 'letter-spacing',
  711. 'text-align',
  712. 'text-decoration',
  713. 'text-indent',
  714. 'text-transform',
  715. 'white-space',
  716. 'word-spacing',
  717. 'visibility',
  718. 'width',
  719. 'min-width',
  720. 'max-width',
  721. ]);
  722. /** @type {ReadonlySet<string>} */
  723. export const marginContextProperties = new Set([
  724. 'direction',
  725. 'unicode-bidi',
  726. 'background-color',
  727. 'background-image',
  728. 'background-repeat',
  729. 'background-attachment',
  730. 'background-position',
  731. 'background',
  732. 'border-top-width',
  733. 'border-right-width',
  734. 'border-bottom-width',
  735. 'border-left-width',
  736. 'border-width',
  737. 'border-top-color',
  738. 'border-right-color',
  739. 'border-bottom-color',
  740. 'border-left-color',
  741. 'border-color',
  742. 'border-top-style',
  743. 'border-right-style',
  744. 'border-bottom-style',
  745. 'border-left-style',
  746. 'border-style',
  747. 'border-top',
  748. 'border-right',
  749. 'border-bottom',
  750. 'border-left',
  751. 'border',
  752. 'counter-reset',
  753. 'counter-increment',
  754. 'content',
  755. 'color',
  756. 'font-family',
  757. 'font-size',
  758. 'font-style',
  759. 'font-variant',
  760. 'font-weight',
  761. 'font',
  762. 'height',
  763. 'min-height',
  764. 'max-height',
  765. 'line-height',
  766. 'margin-top',
  767. 'margin-right',
  768. 'margin-bottom',
  769. 'margin-left',
  770. 'margin',
  771. 'outline-width',
  772. 'outline-style',
  773. 'outline-color',
  774. 'outline',
  775. 'overflow',
  776. 'padding-top',
  777. 'padding-right',
  778. 'padding-bottom',
  779. 'padding-left',
  780. 'padding',
  781. 'quotes',
  782. 'letter-spacing',
  783. 'text-align',
  784. 'text-decoration',
  785. 'text-indent',
  786. 'text-transform',
  787. 'white-space',
  788. 'word-spacing',
  789. 'vertical-align',
  790. 'visibility',
  791. 'width',
  792. 'min-width',
  793. 'max-width',
  794. 'z-index',
  795. ]);