.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / utils / isAutoprefixable.js
1 /* @flow */
2 "use strict";
3
4 const autoprefixer = require("autoprefixer");
5 const Browsers = require("autoprefixer/lib/browsers");
6 const Prefixes = require("autoprefixer/lib/prefixes");
7
8 /**
9  * Use Autoprefixer's secret powers to determine whether or
10  * not a certain CSS identifier contains a vendor prefix that
11  * Autoprefixer, given the standardized identifier, could add itself.
12  *
13  * Used by `*-no-vendor-prefix-*` rules to find superfluous
14  * vendor prefixes.
15  */
16
17 const prefixes = new Prefixes(
18   autoprefixer.data.prefixes,
19   new Browsers(autoprefixer.data.browsers, [])
20 );
21
22 /**
23  * Most identifier types have to be looked up in a unique way,
24  * so we're exposing special functions for each.
25  */
26 module.exports = {
27   atRuleName(identifier /*: string*/) /*: boolean*/ {
28     return prefixes.remove[`@${identifier.toLowerCase()}`];
29   },
30
31   selector(identifier /*: string*/) /*: boolean*/ {
32     return prefixes.remove.selectors.some(selectorObj => {
33       return identifier.toLowerCase() === selectorObj.prefixed;
34     });
35   },
36
37   mediaFeatureName(identifier /*: string*/) /*: boolean*/ {
38     return identifier.toLowerCase().indexOf("device-pixel-ratio") !== -1;
39   },
40
41   property(identifier /*: string*/) /*: boolean*/ {
42     return autoprefixer.data.prefixes[
43       prefixes.unprefixed(identifier.toLowerCase())
44     ];
45   },
46
47   propertyValue(prop /*: string*/, value /*: string*/) /*: boolean*/ {
48     const possiblePrefixableValues =
49       prefixes.remove[prop.toLowerCase()] &&
50       prefixes.remove[prop.toLowerCase()].values;
51     return (
52       possiblePrefixableValues &&
53       possiblePrefixableValues.some(valueObj => {
54         return value.toLowerCase() === valueObj.prefixed;
55       })
56     );
57   }
58 };