Skip to content

Commit 92d632e

Browse files
authored
fix Array.prototype.includes for node v4 (#66)
* fix Array.prototype.includes for node v4 * fix Array.prototype.includes for node v4 * .stylelintrc * fix Array.prototype.includes for node v4
1 parent 99512fe commit 92d632e

14 files changed

+264
-220
lines changed

.eslintrc.json

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
2+
"parserOptions": {
3+
"sourceType": "script",
4+
"impliedStrict": false
5+
},
26
"env": {
3-
"browser": false,
47
"es6": true,
58
"node": true
69
},
@@ -11,21 +14,64 @@
1114
"rules": {
1215
"comma-dangle": [
1316
"error",
14-
"always-multiline"
17+
{
18+
"arrays": "always-multiline",
19+
"objects": "always-multiline",
20+
"imports": "always-multiline",
21+
"exports": "always-multiline",
22+
"functions": "never"
23+
}
24+
],
25+
"comma-spacing": [
26+
"error",
27+
{
28+
"after": true,
29+
"before": false
30+
}
1531
],
1632
"indent": [
1733
"error",
18-
"tab"
34+
"tab",
35+
{
36+
"SwitchCase": 1
37+
}
1938
],
2039
"no-tabs": [
2140
"off"
2241
],
23-
"semi": [
24-
"error",
25-
"always"
42+
"no-var": [
43+
"error"
2644
],
2745
"prefer-arrow-callback": [
2846
"error"
47+
],
48+
"prefer-const": [
49+
"error"
50+
],
51+
"quotes": [
52+
"error",
53+
"double"
54+
],
55+
"semi": [
56+
"error",
57+
"always",
58+
{
59+
"omitLastInOneLineBlock": false
60+
}
61+
],
62+
"strict": [
63+
"error",
64+
"safe"
2965
]
30-
}
66+
},
67+
"overrides": [
68+
{
69+
"files": [
70+
"test/**/*"
71+
],
72+
"env": {
73+
"mocha": true
74+
}
75+
}
76+
]
3177
}

lib/clearAtRule.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
'use strict';
2-
const rePrefix = require('./util').rePrefix;
3-
const unprefixParam = require('./unprefixParam');
1+
"use strict";
2+
const rePrefix = require("./util").rePrefix;
3+
const unprefixParam = require("./unprefixParam");
44

55
function clearAtRule (atRule) {
66
const parent = atRule.parent;
@@ -17,7 +17,7 @@ function clearAtRule (atRule) {
1717
const prefixedAtRule = [];
1818
let unprefixed;
1919

20-
parent.walkAtRules(new RegExp('^(?:-\\w+-)?' + name + '$', 'i'), (atRule) => {
20+
parent.walkAtRules(new RegExp("^(?:-\\w+-)?" + name + "$", "i"), (atRule) => {
2121
if (atRule.parent !== parent) {
2222
return;
2323
}
@@ -26,7 +26,7 @@ function clearAtRule (atRule) {
2626
return;
2727
}
2828

29-
if (atRule.name[0] === '-' || atRuleFixedParams) {
29+
if (atRule.name[0] === "-" || atRuleFixedParams) {
3030
prefixedAtRule.push(atRule);
3131
} else {
3232
unprefixed = atRule;

lib/clearDecl.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
2-
const postcss = require('postcss');
3-
const unprefixDecl = require('./unprefix').decl;
4-
const util = require('./util');
1+
"use strict";
2+
const postcss = require("postcss");
3+
const unprefixDecl = require("./unprefix").decl;
4+
const util = require("./util");
55
function walkDecl (decl) {
66
if (util.rePrefix.test(decl.prop) || /(^|,|\s)-\w+-.+/i.test(decl.value)) {
77
clearDecl(decl);
@@ -14,7 +14,7 @@ function clearDecl (decl) {
1414
let unprefixed;
1515
let lastUnprefixed;
1616

17-
const prefixedDecls = util.getDecls(rule, new RegExp('^-\\w+-' + prop + '$', 'i'));
17+
const prefixedDecls = util.getDecls(rule, new RegExp("^-\\w+-" + prop + "$", "i"));
1818

1919
util.getDecls(rule, unprefixDecl(decl).prop || prop).forEach((decl) => {
2020
lastUnprefixed = unprefixDecl(decl);

lib/clearRule.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
'use strict';
2-
const unprefixSelector = require('./unprefixSelector');
1+
"use strict";
2+
const unprefixSelector = require("./unprefixSelector");
33

44
function clearRule (rule) {
55
let selector = unprefixSelector(rule.selector);

lib/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
'use strict';
2-
const postcss = require('postcss');
3-
const clearDecl = require('./clearDecl');
4-
const clearAtRule = require('./clearAtRule');
5-
const clearRule = require('./clearRule');
1+
"use strict";
2+
const postcss = require("postcss");
3+
const clearDecl = require("./clearDecl");
4+
const clearAtRule = require("./clearAtRule");
5+
const clearRule = require("./clearRule");
66

7-
module.exports = postcss.plugin('postcss-unprefix', () => {
7+
module.exports = postcss.plugin("postcss-unprefix", () => {
88
return function (css) {
99
css.walkAtRules(clearAtRule);
1010
css.walkRules(clearRule);

lib/unprefix.js

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
'use strict';
1+
"use strict";
22

3-
const postcss = require('postcss');
4-
const autoprefixer = require('autoprefixer');
5-
const util = require('./util');
6-
const unprefixFlexDirection = require('./unprefixFlexDirection');
7-
const unprefixBreakInside = require('./unprefixBreakInside');
8-
const unprefixGradient = require('./unprefixGradient');
9-
const unprefixMsGrid = require('./unprefixMsGrid');
10-
const properties = require('known-css-properties').all;
3+
const postcss = require("postcss");
4+
const autoprefixer = require("autoprefixer");
5+
const util = require("./util");
6+
const unprefixFlexDirection = require("./unprefixFlexDirection");
7+
const unprefixBreakInside = require("./unprefixBreakInside");
8+
const unprefixGradient = require("./unprefixGradient");
9+
const unprefixMsGrid = require("./unprefixMsGrid");
10+
const properties = require("known-css-properties").all;
1111
function valMap (reg, prop, valMapData) {
1212
return function valMap (decl) {
1313
if (reg.test(decl.prop)) {
@@ -48,10 +48,10 @@ function getBrotherDecl (decl, prop) {
4848
}
4949

5050
const ALIGN_CONTENT = {
51-
'start': 'flex-start',
52-
'end': 'flex-end',
53-
'justify': 'space-between',
54-
'distribute': 'space-around',
51+
"start": "flex-start",
52+
"end": "flex-end",
53+
"justify": "space-between",
54+
"distribute": "space-around",
5555
};
5656

5757
const RE_BOX_DIRECTION = /^(?:-\w+-)?(?:flex)?box-direction$/i;
@@ -64,10 +64,10 @@ const declUnprefixers = [
6464
brotherFirst(/^(?:-\w+-)?box-flex$/i, /^(?:-\w+-)?flex$/i),
6565
brotherFirst(RE_BOX_ORIENT, RE_FLEX_FLOW),
6666
brotherFirst(RE_BOX_DIRECTION, RE_FLEX_FLOW),
67-
valMap(/^(?:(?:-\w+-)?(?:flex)?box|-ms-flex)-pack$/i, 'justify-content', ALIGN_CONTENT),
68-
valMap(/^(?:(?:-\w+-)?(?:flex)?box|-ms-flex)-line-pack$/i, 'align-content', ALIGN_CONTENT),
69-
valMap(/^(?:(?:-\w+-)?(?:flex)?box|-ms-flex)-item-align$/i, 'align-self', ALIGN_CONTENT),
70-
valMap(/^(?:(?:-\w+-)?(?:flex)?box|-ms-flex)-align$/i, 'align-items', ALIGN_CONTENT),
67+
valMap(/^(?:(?:-\w+-)?(?:flex)?box|-ms-flex)-pack$/i, "justify-content", ALIGN_CONTENT),
68+
valMap(/^(?:(?:-\w+-)?(?:flex)?box|-ms-flex)-line-pack$/i, "align-content", ALIGN_CONTENT),
69+
valMap(/^(?:(?:-\w+-)?(?:flex)?box|-ms-flex)-item-align$/i, "align-self", ALIGN_CONTENT),
70+
valMap(/^(?:(?:-\w+-)?(?:flex)?box|-ms-flex)-align$/i, "align-items", ALIGN_CONTENT),
7171
unprefixFlexDirection,
7272
unprefixBreakInside,
7373
unprefixMsGrid,
@@ -76,11 +76,11 @@ const declUnprefixers = [
7676
if (prop) {
7777
const value = decl.value.toLowerCase();
7878
return {
79-
prop: 'writing-mode',
79+
prop: "writing-mode",
8080
value: {
81-
'lr-tb': 'horizontal-tb',
82-
'tb-rl': 'vertical-rl',
83-
'tb-lr': 'vertical-lr',
81+
"lr-tb": "horizontal-tb",
82+
"tb-rl": "vertical-rl",
83+
"tb-lr": "vertical-lr",
8484
}[value] || value,
8585
};
8686
}
@@ -90,7 +90,7 @@ const declUnprefixers = [
9090
if (display) {
9191
let value;
9292
if ((value = /^(?:-\w+-)?(inline-)?(?:flex)?box$/i.exec(decl.value))) {
93-
value = (value[1] || '') + 'flex';
93+
value = (value[1] || "") + "flex";
9494
} else if ((value = util.rePrefix.exec(decl.value))) {
9595
value = value[1];
9696
} else if (display[1]) {
@@ -100,7 +100,7 @@ const declUnprefixers = [
100100
}
101101

102102
return {
103-
prop: 'display',
103+
prop: "display",
104104
value: value.toLowerCase(),
105105
};
106106
}
@@ -109,27 +109,27 @@ const declUnprefixers = [
109109
let value;
110110
if (/^(?:-\w+-)?image-rendering$/i.test(decl.prop)) {
111111
if (/^-\w+-optimize-contrast$/i.test(decl.value)) {
112-
value = 'crisp-edges';
112+
value = "crisp-edges";
113113
} else if ((value = util.rePrefix.exec(decl.value))) {
114114
value = value[1];
115115
} else {
116116
return;
117117
}
118118
} else if (/^-ms-interpolation-mode$/i.test(decl.prop) && /^nearest-neighbor$/i.test(decl.value)) {
119-
value = 'pixelated';
119+
value = "pixelated";
120120
} else {
121121
return;
122122
}
123123
return {
124-
prop: 'image-rendering',
124+
prop: "image-rendering",
125125
value: value,
126126
};
127127
},
128128
function borderRadius (decl) {
129129
const prop = /^(?:-\w+-)?border-radius-(top|bottom)(left|right)$/i.exec(decl.prop);
130130
if (prop) {
131131
return {
132-
prop: 'border-' + prop[1].toLowerCase() + '-' + prop[2].toLowerCase() + '-radius',
132+
prop: "border-" + prop[1].toLowerCase() + "-" + prop[2].toLowerCase() + "-radius",
133133
value: decl.value,
134134
};
135135
}
@@ -148,51 +148,51 @@ const declUnprefixers = [
148148
];
149149

150150
const PROP_NAME_MAP = {
151-
'border-radius-bottomleft': 'border-bottom-left-radius',
152-
'border-radius-bottomright': 'border-bottom-right-radius',
153-
'border-radius-topleft': 'border-top-left-radius',
154-
'border-radius-topright': 'border-top-right-radius',
151+
"border-radius-bottomleft": "border-bottom-left-radius",
152+
"border-radius-bottomright": "border-bottom-right-radius",
153+
"border-radius-topleft": "border-top-left-radius",
154+
"border-radius-topright": "border-top-right-radius",
155155

156-
'border-after': 'border-block-end',
157-
'border-before': 'border-block-start',
158-
'border-end': 'border-inline-end',
159-
'border-start': 'border-inline-start',
156+
"border-after": "border-block-end",
157+
"border-before": "border-block-start",
158+
"border-end": "border-inline-end",
159+
"border-start": "border-inline-start",
160160

161-
'margin-after': 'margin-block-end',
162-
'margin-before': 'margin-block-start',
163-
'margin-end': 'margin-inline-end',
164-
'margin-start': 'margin-inline-start',
161+
"margin-after": "margin-block-end",
162+
"margin-before": "margin-block-start",
163+
"margin-end": "margin-inline-end",
164+
"margin-start": "margin-inline-start",
165165

166-
'padding-after': 'padding-block-end',
167-
'padding-before': 'padding-block-start',
168-
'padding-end': 'padding-inline-end',
169-
'padding-start': 'padding-inline-start',
166+
"padding-after": "padding-block-end",
167+
"padding-before": "padding-block-start",
168+
"padding-end": "padding-inline-end",
169+
"padding-start": "padding-inline-start",
170170

171-
'mask-box-image': 'mask-border',
172-
'mask-box-image-outset': 'mask-border-outset',
173-
'mask-box-image-repeat': 'mask-border-repeat',
174-
'mask-box-image-slice': 'mask-border-slice',
175-
'mask-box-image-source': 'mask-border-source',
176-
'mask-box-image-width': 'mask-border-width',
171+
"mask-box-image": "mask-border",
172+
"mask-box-image-outset": "mask-border-outset",
173+
"mask-box-image-repeat": "mask-border-repeat",
174+
"mask-box-image-slice": "mask-border-slice",
175+
"mask-box-image-source": "mask-border-source",
176+
"mask-box-image-width": "mask-border-width",
177177

178-
'box-ordinal-group': 'order',
179-
'box-align': 'align-items',
180-
'box-pack': 'justify-content',
181-
'box-flex': 'flex',
182-
'flex-preferred-size': 'flex-basis',
183-
'flex-negative': 'flex-shrink',
184-
'flex-positive': 'flex-grow',
185-
'flex-order': 'order',
178+
"box-ordinal-group": "order",
179+
"box-align": "align-items",
180+
"box-pack": "justify-content",
181+
"box-flex": "flex",
182+
"flex-preferred-size": "flex-basis",
183+
"flex-negative": "flex-shrink",
184+
"flex-positive": "flex-grow",
185+
"flex-order": "order",
186186
};
187187

188188
const PREFIXED_VALUE_NAME_NAME = {
189-
'-moz-available': 'stretch',
189+
"-moz-available": "stretch",
190190
};
191191

192192
const unprefixValue = util.valueUnprefixer([
193193
unprefixGradient,
194194
function unprefixPropInValue (node, prop) {
195-
if (/^(?:-\w+-)?transition(?:-property)?$/.test(prop) && node.type === 'word') {
195+
if (/^(?:-\w+-)?transition(?:-property)?$/.test(prop) && node.type === "word") {
196196
const prefixed = unprefixProp(node.value);
197197
if (prefixed) {
198198
node.value = prefixed;
@@ -206,7 +206,7 @@ const unprefixValue = util.valueUnprefixer([
206206
const data = autoprefixer.data.prefixes[unprefixed];
207207

208208
if (data && (!data.props || data.props.some((propName) => {
209-
return propName === '*' || propName === prop;
209+
return propName === "*" || propName === prop;
210210
}))) {
211211
node.value = unprefixed;
212212
return node;

lib/unprefixBreakInside.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
'use strict';
2-
const util = require('./util');
1+
"use strict";
2+
const util = require("./util");
33

44
function unprefixFlexDirection (decl) {
55
const prop = /^(?:-\w+-)?(page|column)-break-(after|before|inside)/i.exec(decl.prop);
66
if (prop) {
77
const box = prop[2].toLowerCase();
8-
util.getDecls(decl.parent, 'page-break-' + box).forEach((decl) => {
8+
util.getDecls(decl.parent, "page-break-" + box).forEach((decl) => {
99
decl.remove();
1010
});
1111

1212
let value = decl.value.toLowerCase();
13-
if (value === 'avoid') {
14-
value += '-' + prop[1].toLowerCase();
13+
if (value === "avoid") {
14+
value += "-" + prop[1].toLowerCase();
1515
}
1616

1717
return {
18-
prop: 'break-' + box,
18+
prop: "break-" + box,
1919
value: value,
2020
};
2121
}

0 commit comments

Comments
 (0)