Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit b7d6ffd

Browse files
authoredJul 5, 2017
Merge pull request #400 from MoOx/postcss6-upgrade
Postcss6 upgrade
2 parents 1781dc7 + db0f0fa commit b7d6ffd

14 files changed

+10483
-56
lines changed
 

‎.travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ sudo: false
22

33
language: node_js
44
node_js:
5-
- '6'
6-
- '5'
7-
- '4'
8-
- '0.12'
5+
- 8
6+
- 6
7+
- 4
98

109
script:
1110
- npm run test

‎appveyor.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
environment:
44
matrix:
5+
- nodejs_version: 8
56
- nodejs_version: 6
6-
- nodejs_version: 5
77
- nodejs_version: 4
8-
- nodejs_version: 0.12
98

109
version: "{build}"
1110
build: off

‎docs/content/usage.md

+7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ and show provide duplicates in their examples.
8484
(eg: autoprefixer + cssnext - but cssnext already includes autoprefixer).**
8585
_In order to fix this, here is a warning. You are welcome._
8686

87+
## `warnForDeprecations`
88+
89+
_(default: true)_
90+
91+
This option should be left with its default value, unless you are aware of the
92+
risk and plan to handle the situation.
93+
8794
---
8895

8996
**To know all available options, please check corresponding postcss plugin by

‎package-lock.json

+5,254
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+31-31
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,37 @@
2121
"!**/__tests__"
2222
],
2323
"dependencies": {
24-
"autoprefixer": "^6.0.2",
25-
"caniuse-api": "^1.5.3",
26-
"chalk": "^1.1.1",
27-
"pixrem": "^3.0.0",
28-
"pleeease-filters": "^3.0.0",
29-
"postcss": "^5.0.4",
30-
"postcss-apply": "^0.3.0",
31-
"postcss-attribute-case-insensitive": "^1.0.1",
32-
"postcss-calc": "^5.0.0",
33-
"postcss-color-function": "^2.0.0",
34-
"postcss-color-gray": "^3.0.0",
35-
"postcss-color-hex-alpha": "^2.0.0",
36-
"postcss-color-hsl": "^1.0.5",
37-
"postcss-color-hwb": "^2.0.0",
38-
"postcss-color-rebeccapurple": "^2.0.0",
39-
"postcss-color-rgb": "^1.1.4",
40-
"postcss-color-rgba-fallback": "^2.0.0",
41-
"postcss-custom-media": "^5.0.0",
42-
"postcss-custom-properties": "^5.0.0",
43-
"postcss-custom-selectors": "^3.0.0",
44-
"postcss-font-family-system-ui": "^1.0.1",
45-
"postcss-font-variant": "^2.0.0",
46-
"postcss-image-set-polyfill": "^0.3.3",
47-
"postcss-initial": "^1.3.1",
48-
"postcss-media-minmax": "^2.1.0",
49-
"postcss-nesting": "^2.0.5",
50-
"postcss-pseudo-class-any-link": "^1.0.0",
51-
"postcss-pseudoelements": "^3.0.0",
52-
"postcss-replace-overflow-wrap": "^1.0.0",
53-
"postcss-selector-matches": "^2.0.0",
54-
"postcss-selector-not": "^2.0.0"
24+
"autoprefixer": "^7.1.1",
25+
"caniuse-api": "^2.0.0",
26+
"chalk": "^2.0.1",
27+
"pixrem": "^3.0.2",
28+
"pleeease-filters": "^4.0.0",
29+
"postcss": "^6.0.5",
30+
"postcss-apply": "^0.8.0",
31+
"postcss-attribute-case-insensitive": "^2.0.0",
32+
"postcss-calc": "^6.0.0",
33+
"postcss-color-function": "^4.0.0",
34+
"postcss-color-gray": "^4.0.0",
35+
"postcss-color-hex-alpha": "^3.0.0",
36+
"postcss-color-hsl": "^2.0.0",
37+
"postcss-color-hwb": "^3.0.0",
38+
"postcss-color-rebeccapurple": "^3.0.0",
39+
"postcss-color-rgb": "^2.0.0",
40+
"postcss-color-rgba-fallback": "^2.2.0",
41+
"postcss-custom-media": "^6.0.0",
42+
"postcss-custom-properties": "^6.1.0",
43+
"postcss-custom-selectors": "^4.0.1",
44+
"postcss-font-family-system-ui": "^2.0.1",
45+
"postcss-font-variant": "^3.0.0",
46+
"postcss-image-set-polyfill": "^0.3.5",
47+
"postcss-initial": "^2.0.0",
48+
"postcss-media-minmax": "^3.0.0",
49+
"postcss-nesting": "^4.0.1",
50+
"postcss-pseudo-class-any-link": "^4.0.0",
51+
"postcss-pseudoelements": "^4.0.0",
52+
"postcss-replace-overflow-wrap": "^2.0.0",
53+
"postcss-selector-matches": "^3.0.1",
54+
"postcss-selector-not": "^3.0.1"
5555
},
5656
"peerDependencies": {
5757
"caniuse-db": "^1.0.30000670"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
body {
2-
background: rgb(102, 51, 153)
2+
background: #639
33
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
.image {
22
background-image: url(img/test.png);
3+
}@media (min-resolution: 192dpi) {.image {
4+
background-image: url(img/test-2x.png);
35
}
4-
@media (min-resolution: 144dpi) {
5-
.image {
6-
background-image: url(img/test-2x.png);
7-
}
6+
}@media (min-resolution: 600dpi) {.image {
7+
background-image: url(my-img-print.png);
88
}
9-
@media (min-resolution: 600dpi) {
10-
.image {
11-
background-image: url(my-img-print.png);
12-
}
139
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.button {
2-
}
3-
41
.button i {
5-
6-
color: black
2+
color: black;
73
}

‎src/__tests__/option.browsers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tape("cssnext browsers option", function(t) {
1313
)
1414

1515
const customPropsInput = ":root{--foo:bar}baz{qux:var(--foo)}"
16-
const customPropsOutput = "baz{qux: bar}"
16+
const customPropsOutput = "baz{qux:bar}"
1717

1818
// fx 30 doesn't handle custom prop
1919
t.equal(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import tape from "tape"
2+
3+
import postcss from "postcss"
4+
import cssnext from ".."
5+
import { resetWarning } from "../warn-for-deprecations"
6+
7+
const reportFail = (t) => (error) => {
8+
console.log(error)
9+
t.fail()
10+
}
11+
12+
tape("cssnext warnForDeprecation option", (t) => {
13+
const messages = []
14+
resetWarning()
15+
const instance = postcss([
16+
cssnext({
17+
console: { log: (msg) => messages.push(msg) },
18+
}),
19+
])
20+
21+
instance.process("body{}").then(() => {
22+
t.equal(
23+
messages.length,
24+
0,
25+
"should not add warning there is no deprecated stuff"
26+
)
27+
t.end()
28+
}, reportFail(t))
29+
})
30+
31+
tape("cssnext warnForDeprecation option", (t) => {
32+
const messages = []
33+
resetWarning()
34+
const instance = postcss([
35+
cssnext({
36+
console: { log: (msg) => messages.push(msg) },
37+
}),
38+
])
39+
40+
instance.process(`
41+
:root {
42+
--toolbar-theme: {
43+
border: 1px solid green;
44+
};
45+
}
46+
.Toolbar {
47+
@apply --toolbar-theme;
48+
@apply --toolbar-theme;
49+
}
50+
`)
51+
.then(() => {
52+
t.equal(
53+
messages.length,
54+
1,
55+
"should add a single warning if there are deprecated stuff"
56+
)
57+
t.end()
58+
}, reportFail(t))
59+
})

‎src/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { isSupported } from "caniuse-api"
44
import libraryFeatures from "./features"
55
import featuresActivationMap from "./features-activation-map"
66
import warnForDuplicates from "./warn-for-duplicates"
7+
import warnForDeprecations from "./warn-for-deprecations"
78

89
const plugin = postcss.plugin("postcss-cssnext", (options) => {
910
options = {
1011
console: console,
1112
warnForDuplicates: true,
13+
warnForDeprecations: true,
1214
features: {},
1315
// options.browsers is deliberately undefined by default to inherit
1416
// browserslist default behavior
@@ -41,6 +43,12 @@ const plugin = postcss.plugin("postcss-cssnext", (options) => {
4143

4244
const processor = postcss()
4345

46+
if (options.warnForDeprecations) {
47+
processor.use(warnForDeprecations({
48+
console: options.console,
49+
}))
50+
}
51+
4452
// features
4553
Object.keys(libraryFeatures).forEach(key => {
4654
// feature is auto enabled if: not disable && (enabled || no data yet ||

‎src/warn-for-deprecations.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import postcss from "postcss"
2+
import color from "chalk"
3+
4+
let shouldGlobalWarn = true
5+
export const resetWarning = () => shouldGlobalWarn = true
6+
7+
const warnForDeprecations = postcss.plugin(
8+
"postcss-cssnext-warn-for-deprecations",
9+
({ console: messenger }) => {
10+
return (style) => {
11+
// warn for removed @apply
12+
style.walkAtRules("apply", () => {
13+
if (shouldGlobalWarn) {
14+
shouldGlobalWarn = false
15+
messenger.log(
16+
color.yellow.bold(
17+
"You are using @apply rule and custom property sets. \n" +
18+
19+
"This feature won't be included in next the major release "+
20+
"of postcss-cssnext. \n"
21+
) +
22+
23+
color.grey(
24+
"This most likely won't get any more support from browser vendors as the " +
25+
"spec is yet considered deprecated and alternative solutions are being "+
26+
"discussed. \n"
27+
) +
28+
29+
"Read more about the reason here https://github.com/pascalduez/postcss-apply."
30+
)
31+
}
32+
})
33+
}
34+
}
35+
)
36+
37+
export default warnForDeprecations

‎src/warn-for-duplicates.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ const globalWarning = (
1818
export const spotted = []
1919

2020
const warnForDuplicates = postcss.plugin(
21-
"postcss-warn-for-duplicates",
22-
(options) => {
21+
"postcss-cssnext-warn-for-duplicates",
22+
({ keys, console: messenger }) => {
2323
return (style, result) => {
24-
// https://github.com/postcss/postcss/issues/768
25-
const { keys, console: messenger } = options
2624
const pluginNames = []
2725
result.processor.plugins.forEach((plugin) => {
2826
const name = plugin.postcssPlugin

‎yarn.lock

+5,074
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
This repository has been archived.