Skip to content

Commit

Permalink
Update PostCSS to v6.0.15 (#3096)
Browse files Browse the repository at this point in the history
* Update PostCSS to v6.0.15

* Remove PostCSS v6.0.15 console warnings

See postcss/postcss@9effd74
  • Loading branch information
ntwb authored and hudochenkov committed Jan 3, 2018
1 parent 4d53e92 commit f38bd78
Show file tree
Hide file tree
Showing 21 changed files with 124 additions and 108 deletions.
14 changes: 8 additions & 6 deletions lib/__tests__/defaultSeverity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ it("`defaultSeverity` option set to warning", () => {
"block-no-empty": true
}
};
return postcssPlugin.process("a {}", {}, config).then(result => {
const warnings = result.warnings();
expect(warnings.length).toBe(1);
expect(warnings[0].text.indexOf("block-no-empty")).not.toBe(-1);
expect(warnings[0].severity).toBe("warning");
});
return postcssPlugin
.process("a {}", { from: undefined }, config)
.then(result => {
const warnings = result.warnings();
expect(warnings.length).toBe(1);
expect(warnings[0].text.indexOf("block-no-empty")).not.toBe(-1);
expect(warnings[0].severity).toBe("warning");
});
});
6 changes: 3 additions & 3 deletions lib/__tests__/disableRanges.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ it("SCSS // line-disabling comment", () => {
}`;
return postcss()
.use(assignDisabledRanges)
.process(scssSource, { syntax: scss })
.process(scssSource, { syntax: scss, from: undefined })
.then(result => {
expect(result.stylelint.disabledRanges).toEqual({
all: [],
Expand All @@ -255,7 +255,7 @@ it("Less // line-disabling comment", () => {
}`;
return postcss()
.use(assignDisabledRanges)
.process(lessSource, { syntax: less })
.process(lessSource, { syntax: less, from: undefined })
.then(result => {
expect(result.stylelint.disabledRanges).toEqual({
all: [],
Expand Down Expand Up @@ -431,6 +431,6 @@ it("enable rule without disabling rule", () => {
function testDisableRanges(source, cb) {
return postcss()
.use(assignDisabledRanges)
.process(source)
.process(source, { from: undefined })
.then(cb);
}
2 changes: 1 addition & 1 deletion lib/__tests__/ignoreDisables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("ignoreDisables with postcssPlugins", () => {
return postcssPlugin
.process(
css,
{},
{ from: undefined },
{
config,
ignoreDisables: true
Expand Down
6 changes: 3 additions & 3 deletions lib/__tests__/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("integration test expecting warnings", () => {
beforeEach(() => {
return postcss()
.use(stylelint(config))
.process(css)
.process(css, { from: undefined })
.then(data => (result = data));
});

Expand Down Expand Up @@ -100,7 +100,7 @@ it("Less integration test", () => {

return postcss()
.use(stylelint({ rules: {} }))
.process(less, { syntax: lessSyntax })
.process(less, { syntax: lessSyntax, from: undefined })
.then(result => {
expect(result.messages.length).toBe(0);
});
Expand All @@ -114,7 +114,7 @@ it("Scss integration test", () => {

return postcss()
.use(stylelint({ rules: {} }))
.process(scss, { syntax: scssSyntax })
.process(scss, { syntax: scssSyntax, from: undefined })
.then(result => {
expect(result.messages.length).toBe(0);
});
Expand Down
90 changes: 49 additions & 41 deletions lib/__tests__/plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,47 +53,55 @@ const processorRelativeAndExtendRelative = postcss().use(
);

it("one plugin runs", () => {
return processorRelative.process(cssWithFoo).then(result => {
expect(result.warnings().length).toBe(2);
expect(result.warnings()[0].text).toBe(
"found .foo (plugin/warn-about-foo)"
);
expect(result.warnings()[0].node).toBeTruthy();
});
return processorRelative
.process(cssWithFoo, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(2);
expect(result.warnings()[0].text).toBe(
"found .foo (plugin/warn-about-foo)"
);
expect(result.warnings()[0].node).toBeTruthy();
});
});

it("another plugin runs", () => {
return processorRelative.process(cssWithoutFoo).then(result => {
expect(result.warnings().length).toBe(1);
expect(result.warnings()[0].text).toBe(
"Unexpected empty block (block-no-empty)"
);
});
return processorRelative
.process(cssWithoutFoo, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(1);
expect(result.warnings()[0].text).toBe(
"Unexpected empty block (block-no-empty)"
);
});
});

it("plugin with absolute path and no configBasedir", () => {
return processorAbsolute.process(cssWithFoo).then(result => {
expect(result.warnings().length).toBe(2);
expect(result.warnings()[0].text).toBe(
"found .foo (plugin/warn-about-foo)"
);
expect(result.warnings()[0].node).toBeTruthy();
});
return processorAbsolute
.process(cssWithFoo, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(2);
expect(result.warnings()[0].text).toBe(
"found .foo (plugin/warn-about-foo)"
);
expect(result.warnings()[0].node).toBeTruthy();
});
});

it("config extending another config that invokes a plugin with a relative path", () => {
return processorExtendRelative.process(cssWithFoo).then(result => {
expect(result.warnings().length).toBe(1);
expect(result.warnings()[0].text).toBe(
"found .foo (plugin/warn-about-foo)"
);
expect(result.warnings()[0].node).toBeTruthy();
});
return processorExtendRelative
.process(cssWithFoo, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(1);
expect(result.warnings()[0].text).toBe(
"found .foo (plugin/warn-about-foo)"
);
expect(result.warnings()[0].node).toBeTruthy();
});
});

it("config with its own plugins extending another config that invokes a plugin with a relative path", () => {
return processorRelativeAndExtendRelative
.process(cssWithFooAndBar)
.process(cssWithFooAndBar, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(2);
expect(result.warnings()[0].text).toBe(
Expand Down Expand Up @@ -130,7 +138,7 @@ describe("plugin using exposed rules via stylelint.rules", () => {
it("with uppercase expectation and lowercase color", () => {
return postcss()
.use(stylelint(config("upper")))
.process(cssWithDirectiveLower)
.process(cssWithDirectiveLower, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(1);
expect(result.warnings()[0].text).toBe(
Expand All @@ -142,7 +150,7 @@ describe("plugin using exposed rules via stylelint.rules", () => {
it("with uppercase expectation and uppercase color", () => {
return postcss()
.use(stylelint(config("upper")))
.process(cssWithDirectiveUpper)
.process(cssWithDirectiveUpper, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(0);
});
Expand All @@ -151,7 +159,7 @@ describe("plugin using exposed rules via stylelint.rules", () => {
it("with lowercase expectation and uppercase color", () => {
return postcss()
.use(stylelint(config("lower")))
.process(cssWithDirectiveUpper)
.process(cssWithDirectiveUpper, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(1);
expect(result.warnings()[0].text).toBe(
Expand All @@ -163,7 +171,7 @@ describe("plugin using exposed rules via stylelint.rules", () => {
it("with lowercase expectation and lowercase color", () => {
return postcss()
.use(stylelint(config("lower")))
.process(cssWithDirectiveLower)
.process(cssWithDirectiveLower, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(0);
});
Expand All @@ -172,7 +180,7 @@ describe("plugin using exposed rules via stylelint.rules", () => {
it("with uppercase expectation and lowercase color without directive", () => {
return postcss()
.use(stylelint(config("upper")))
.process(cssWithoutDirectiveLower)
.process(cssWithoutDirectiveLower, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(0);
});
Expand All @@ -181,7 +189,7 @@ describe("plugin using exposed rules via stylelint.rules", () => {
it("with uppercase expectation and uppercase color without directive", () => {
return postcss()
.use(stylelint(config("lower")))
.process(cssWithoutDirectiveUpper)
.process(cssWithoutDirectiveUpper, { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(0);
});
Expand All @@ -200,7 +208,7 @@ describe("module providing an array of plugins", () => {
it("first plugin works", () => {
return postcss()
.use(stylelint(config))
.process("@@check-color-hex-case a { color: #eee; }")
.process("@@check-color-hex-case a { color: #eee; }", { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(1);
expect(result.warnings()[0].text).toBe(
Expand All @@ -212,7 +220,7 @@ describe("module providing an array of plugins", () => {
it("second plugin works", () => {
return postcss()
.use(stylelint(config))
.process(".foo {}")
.process(".foo {}", { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(1);
expect(result.warnings()[0].text).toBe(
Expand All @@ -232,7 +240,7 @@ it("slashless plugin causes configuration error", () => {

return postcss()
.use(stylelint(config))
.process(".foo {}")
.process(".foo {}", { from: undefined })
.then(() => {
throw new Error("should not have succeeded");
})
Expand All @@ -254,7 +262,7 @@ it("plugin with primary option array", () => {
};
return postcss()
.use(stylelint(config))
.process("a {}")
.process("a {}", { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(0);
});
Expand All @@ -269,7 +277,7 @@ it("plugin with primary option array within options array", () => {
};
return postcss()
.use(stylelint(config))
.process("a {}")
.process("a {}", { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(0);
});
Expand All @@ -284,7 +292,7 @@ it("plugin with async rule", () => {
};
return postcss()
.use(stylelint(config))
.process("a {}")
.process("a {}", { from: undefined })
.then(result => {
expect(result.warnings().length).toBe(1);
});
Expand Down Expand Up @@ -313,7 +321,7 @@ describe("loading a plugin from process.cwd", () => {
beforeEach(() => {
return postcss()
.use(stylelint(config))
.process(".foo {}")
.process(".foo {}", { from: undefined })
.then(data => (result = data));
});

Expand Down
36 changes: 21 additions & 15 deletions lib/__tests__/postcssPlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const postcssPlugin = require("../postcssPlugin");

it("`config` option is `null`", () => {
return postcssPlugin
.process("a {}")
.process("a {}", { from: undefined })
.then(() => {
throw new Error("should not have succeeded");
})
Expand All @@ -19,16 +19,18 @@ it("`configFile` option with absolute path", () => {
const config = {
configFile: path.join(__dirname, "fixtures/config-block-no-empty.json")
};
return postcssPlugin.process("a {}", {}, config).then(postcssResult => {
const warnings = postcssResult.warnings();
expect(warnings.length).toBe(1);
expect(warnings[0].text.indexOf("block-no-empty")).not.toBe(-1);
});
return postcssPlugin
.process("a {}", { from: undefined }, config)
.then(postcssResult => {
const warnings = postcssResult.warnings();
expect(warnings.length).toBe(1);
expect(warnings[0].text.indexOf("block-no-empty")).not.toBe(-1);
});
});

it("`configFile` with bad path", () => {
return postcssPlugin
.process("a {}", {}, { configFile: "./herby.json" })
.process("a {}", { from: undefined }, { configFile: "./herby.json" })
.then(() => {
throw new Error("should not have succeeded");
})
Expand All @@ -42,7 +44,7 @@ it("`configFile` option without rules", () => {
configFile: path.join(__dirname, "fixtures/config-without-rules.json")
};
return postcssPlugin
.process("a {}", {}, config)
.process("a {}", { from: undefined }, config)
.then(() => {
throw new Error("should not have succeeded");
})
Expand All @@ -61,7 +63,7 @@ it("`configFile` option with undefined rule", () => {
};
const ruleName = "unknown-rule";
return postcssPlugin
.process("a {}", {}, config)
.process("a {}", { from: undefined }, config)
.then(() => {
throw new Error("should not have succeeded");
})
Expand All @@ -78,9 +80,11 @@ it("`ignoreFiles` options is not empty and file ignored", () => {
ignoreFiles: "**/foo.css",
from: "foo.css"
};
return postcssPlugin.process("a {}", {}, config).then(postcssResult => {
expect(postcssResult.stylelint.ignored).toBeTruthy();
});
return postcssPlugin
.process("a {}", { from: undefined }, config)
.then(postcssResult => {
expect(postcssResult.stylelint.ignored).toBeTruthy();
});
});

it("`ignoreFiles` options is not empty and file not ignored", () => {
Expand All @@ -91,7 +95,9 @@ it("`ignoreFiles` options is not empty and file not ignored", () => {
ignoreFiles: "**/bar.css",
from: "foo.css"
};
return postcssPlugin.process("a {}", {}, config).then(postcssResult => {
expect(postcssResult.stylelint.ignored).toBeFalsy();
});
return postcssPlugin
.process("a {}", { from: undefined }, config)
.then(postcssResult => {
expect(postcssResult.stylelint.ignored).toBeFalsy();
});
});
2 changes: 1 addition & 1 deletion lib/testUtils/createRuleTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function processGroup(rule, schema, equalityCheck) {

return processor
.use(rule(rulePrimaryOptions, ruleSecondaryOptions))
.process(code, postcssProcessOptions);
.process(code, { postcssProcessOptions, from: undefined });
}

// Apply the basic positive checks unless
Expand Down
Loading

0 comments on commit f38bd78

Please sign in to comment.